forked from nicolargo/ubuntupostinstall
-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
70 lines (56 loc) · 2.11 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
import subprocess
import distro
config_file = "NoconfigFile"
def install_ubuntu_24(config_file):
print('Installation pour Ubuntu 24')
config_file = "ubuntu-24.04-postinstall.cfg"
return config_file
def install_ubuntu_22(config_file):
print('Installation pour Ubuntu 22')
config_file = "ubuntu-22.04-postinstall.cfg"
return config_file
def install_ubuntu_20(config_file):
print('Installation pour Ubuntu 20')
config_file = "ubuntu-20.04-unity-postinstall.cfg "
return config_file
def install_ubuntu_18(config_file):
print('Installation pour Ubuntu 18')
config_file = "ubuntu-18.04-unity-postinstall.cfg"
return config_file
def install_kubuntu_22(config_file):
print('Installation pour Kubuntu 22')
config_file = "kubuntu-22.04.cfg"
return config_file
def install_kubuntu_20(config_file):
print('Installation pour Kubuntu 20')
config_file = "kubuntu-20.04.cfg"
return config_file
def install_mint_21(config_file):
print('Installation pour Mint 21')
config_file = "mint21.cfg"
return config_file
# Dictionnaire des options
options = {
('noble', 'ubuntu'): install_ubuntu_24,
('jammy', 'ubuntu'): install_ubuntu_22,
('focal', 'ubuntu'): install_ubuntu_20,
('bionic', 'ubuntu'): install_ubuntu_18,
('jammy', 'kubuntu'): install_kubuntu_22,
('focal', 'kubuntu'): install_kubuntu_20,
('vanessa', 'linuxmint'): install_mint_21,
('vera', 'linuxmint'): install_mint_21,
('victoria', 'linuxmint'): install_mint_21
}
# Obtention des valeurs pertinentes pour la distribution
distro_codename = distro.codename()
distro_id = distro.id()
# Recherche de la fonction appropriée dans le dictionnaire
install_function = options.get((distro_codename, distro_id))
# Exécution de la fonction si elle existe, sinon affichage d'un message d'erreur
if install_function:
config_file = install_function(config_file)
print(" config file is "+config_file)
subprocess.run(['python2.7', 'ubuntu-14.04-postinstall.py', '-c', config_file])
else:
print('Installation non prise en charge pour cette distribution.')