Jump to content
ElementaryOS France

[Python] Script post installation EOS.


Recommended Posts

Script 1.

 

A adapter selon vos besoins.

 

#!/usr/bin/python
#coding:utf-8
import os, sys

def eos1():
   global maj
   action = raw_input('Voulez-vous procèdez au mises à jours d\'elementary OS ? (o/n)')
   if action == 'o':
       maj = True
   elif action == 'n':
       maj = False
   else:
       eos1()

def eos2():
   global tweaks
   action = raw_input('Voulez-vous procèdez à l\'installation de Elementary-tweaks - Thèmes Interfaces - Thèmes Icônes - Thèmes Plank ? (o/n)')
   if action == 'o':
       tweaks = True
   elif action == 'n':
       tweaks = False
   else:
       eos2()

def eos3():
   global tiers
   action = raw_input('Voulez-vous procèdez à l\'installation de logiciels tiers - inkscape - scribus - eog - gcolor2 - gnome-system-monitor - rar - filezilla - gparted - brasero - vlc - transmission - gnome-system-monitor - audience - rsync ? (o/n)')
   if action == 'o':
       tiers = True
   elif action == 'n':
       tiers = False
   else:
       eos3()

def eos4():
   global gimp
   action = raw_input('Voulez-vous procèdez à l\'installation de GIMP + PPA ? (o/n)')
   if action == 'o':
       gimp = True
   elif action == 'n':
       gimp = False
   else:
       eos4()

def eos5():
   global converseen
   action = raw_input('Voulez-vous procèdez à l\'installation de converseen + PPA ? (o/n)')
   if action == 'o':
       converseen = True
   elif action == 'n':
       converseen = False
   else:
       eos5()

def eos6():
   global blender
   action = raw_input('Voulez-vous procèdez à l\'installation de Blender + PPA ? (o/n)')
   if action == 'o':
       blender = True
   elif action == 'n':
       blender = False
   else:
       eos6()

def eos7():
   global mypaint
   action = raw_input('Voulez-vous procèdez à l\'installation de MyPaint ? (o/n)')
   if action == 'o':
       mypaint = True
   elif action == 'n':
       mypaint = False
   else:
       eos7()

def eos8():
   global libreoffice
   action = raw_input('Voulez-vous procèdez à l\'installation de Libre Office 4 + PPA ? (o/n)')
   if action == 'o':
       libreoffice = True
   elif action == 'n':
       libreoffice = False
   else:
       eos8()

def eos9():
   global numix
   action = raw_input('Voulez-vous procèdez à l\'installation de numix-circle + PPA ? (o/n)')
   if action == 'o':
       numix = True
   elif action == 'n':
       numix = False
   else:
       eos9()

def eos10():
   global youtubedl
   action = raw_input('Voulez-vous procèdez à l\'installation de youtube-dl + PPA ? (o/n)')
   if action == 'o':
       youtubedl = True
   elif action == 'n':
       youtubedl = False
   else:
       eos10()

def eos11():
   global librecad
   action = raw_input('Voulez-vous procèdez à l\'installation de librecad + PPA ? (o/n)')
   if action == 'o':
       librecad = True
   elif action == 'n':
       librecad = False
   else:
       eos11()

def eos12():
global google
action = raw_input('Voulez-vous installer le navigateur google chrome? (o/n)')
if action == 'o':
	google = True
elif action == 'n':
	google = False
else:
	eos12()

def eos13():
global sup
action = raw_input('Voulez-vous supprimer des softs tiers ? (o/n)')
if action == 'o':
	sup = True
elif action == 'n':
	sup = False
else:
	eos13()

def installation():
   if maj == True:
       os.system("sudo apt-get update && sudo apt-get dist-upgrade && clear")
       print("Installation des mises à jours terminées.")

   if tweaks == True:
       os.system("sudo apt-add-repository ppa:versable/elementary-update && sudo apt-get update && sudo apt-get install elementary-tweaks elementary-dark-theme elementary-plastico-theme elementary-whit-e-theme elementary-harvey-theme elementary-elfaenza-icons elementary-nitrux-icons elementary-plank-themes && clear")
       print("Installation de Elementary-tweaks - Thèmes Interfaces - Thèmes Icônes - Thèmes Plank terminées.")

   if tiers == True:
       os.system("sudo apt-get install inkscape scribus eog gcolor2 unrar filezilla gparted brasero brasero-contracts vlc transmission gnome-system-monitor audience rsync && clear")
       print("Installation logiciels tiers.")

   if gimp == True:
       os.system("sudo add-apt-repository ppa:otto-kesselgulasch/gimp && sudo apt-get update && sudo apt-get install gimp && clear")
       print("Installation de GIMP + PPA terminé.")

   if converseen == True:
       os.system("sudo add-apt-repository ppa:faster3ck/converseen && sudo apt-get update && sudo apt-get install converseen && clear")
       print("Installation de Inkscape + PPA terminé.")

   if blender == True:
       os.system("sudo add-apt-repository ppa:irie/blender && sudo apt-get update && sudo apt-get install blender && clear")
       print("Installation de Blender + PPA terminé.")

   if mypaint == True:
       os.system("sudo add-apt-repository ppa:achadwick/mypaint-testing && sudo apt-get update && sudo apt-get install mypaint && clear")
       print("Installation de mypaint terminé.")

   if libreoffice == True:
       os.system("sudo add-apt-repository ppa:libreoffice/libreoffice-4-0 && sudo apt-get update && sudo apt-get install libreoffice libreoffice-l10n-fr && clear")
       print("Installation de Libre Office + PPA terminé.")

   if numix == True:
       os.system("sudo add-apt-repository ppa:numix/ppa && sudo apt-get update && sudo apt-get install numix-icon-theme numix-icon-theme-circle")
       print("Installation de numix-icons + PPA terminé.")

   if youtubedl == True:
       os.system("sudo add-apt-repository ppa:nilarimogard/webupd8 && sudo apt-get update && sudo apt-get upgrade && sudo apt-get install youtube-dl && clear")
       print("Installation de youtube-dl + PPA terminé.")

   if librecad == True:
       os.system("sudo add-apt-repository ppa:librecad-dev/librecad-daily && sudo apt-get update && sudo apt-get upgrade && sudo apt-get install librecad && clear")
       print("Installation de Librecad + PPA terminé.")

   if google == True:
os.system("wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - && su -c 'echo \"deb https://dl.google.com/linux/chrome/deb/ stable main\" >> /etc/apt/sources.list.d/google.list' && sudo apt-get update")
		print('Ajout du dépot terminée')
		os.system("sudo apt-get install google-chrome-stable")
		print('Installation de google chrome terminé.')

   if sup == True:
       os.system("sudo apt-get remove --purge totem empathy software-center update-manager midori-granite && sudo apt-get update && sudo apt-get upgrade && clear")
       print("suppression softs terminé")

def end():
   print("Dernière vérification de mises à jours.")
   os.system("sudo apt-get update && sudo apt-get dist-upgrade")
   print("Script d'installation terminé.")
   sys.exit()

eos1()
eos2()
eos3()
eos4()
eos5()
eos6()
eos7()
eos8()
eos9()
eos10()
eos11()
eos12()
eos13()
installation()
end()

Edited by insomniaque
Link to comment
Share on other sites

Script 2 (Variante).

 

#!/usr/bin/python
#coding:utf-8

import os, sys

def affiche():
global maj, tweaks, tiers, gimp, converseen, blender
global mypaint, libreoffice, numix, youtubedl, librecad, google

print('\
Mise à jour:\n\
 [a] Mise à jour elementary OS\n\n\
Installer:\n\
 [b] elementary-tweaks \n\
 [c] inkscape, Scribus, eog, gcolor2, gnome-system-monitor, rar, filezilla, gparted, brasero et vlc \n\
 [d] gimp \n\
 [e] converseen \n\
 [f] blender \n\
 [g] mypaint \n\
 [h] libreOffice \n\
 [i] numix-circle \n\
 [j] youtube-dl \n\
 [k] librecad \n\
 [l] google chrome\n\n\
Supprimer:\n\
 [m] totem, empathy, software-center, update-manager, midori-granite\n\n\
Quitter:\n\
 [0] exit\n')

action = raw_input('Veuillez faire votre choix, entrer les lettres correspondants. ex: a,c,e,f\n')
if action == "0":
		exit()
install(action)

def install(action):
choix = action.split(',')
for element in choix:
	if element == "a":
		os.system("sudo apt-get update && sudo apt-get dist-upgrade -y && clear")
		print("Installation des mises à jours terminées.")
	if element == "b":
		os.system("sudo apt-add-repository ppa:versable/elementary-update && sudo apt-get update && sudo apt-get install elementary-tweaks elementary-dark-theme elementary-plastico-theme elementary-whit-e-theme elementary-harvey-theme elementary-elfaenza-icons elementary-nitrux-icons elementary-plank-themes && clear")
		print("Installation de Elementary-tweaks - Thèmes Interfaces - Thèmes Icônes - Thèmes Plank terminées.")
	if element == "c":
		os.system("sudo apt-get install inkscape scribus eog gcolor2 unrar filezilla gparted brasero brasero-contracts vlc && clear")
		print("Installation logiciels tiers.")
	if element == "d":
		os.system("sudo add-apt-repository ppa:otto-kesselgulasch/gimp && sudo apt-get update && sudo apt-get install gimp && clear")
		print("Installation de GIMP + PPA terminée.")
	if element == "e":
		os.system("sudo add-apt-repository ppa:faster3ck/converseen && sudo apt-get update && sudo apt-get install converseen && clear")
		print("Installation de Inkscape + PPA terminée.")
	if element == "f":
		os.system("sudo add-apt-repository ppa:irie/blender && sudo apt-get update && sudo apt-get install blender && clear")
		print("Installation de Blender + PPA terminée.")
	if element == "g":
		os.system("sudo add-apt-repository ppa:achadwick/mypaint-testing && sudo apt-get update && sudo apt-get install mypaint && clear")
		print("Installation de mypaint terminée.")
	if element == "h":
		os.system("sudo add-apt-repository ppa:libreoffice/libreoffice-4-0 && sudo apt-get update && sudo apt-get install libreoffice libreoffice-l10n-fr && clear")
		print("Installation de Libre Office + PPA terminée.")
	if element == "i":
		os.system("sudo add-apt-repository ppa:upubuntu-com/nitrux && sudo apt-get update && sudo apt-get install nitruxos && clear")
		print("Installation de numix-icons + PPA terminée.")
	if element == "j":
		os.system("sudo add-apt-repository ppa:nilarimogard/webupd8 && sudo apt-get update && sudo apt-get install youtube-dl && clear")
		print("Installation de youtube-dl + PPA terminée.")
	if element == "k":
		os.system("sudo add-apt-repository ppa:librecad-dev/librecad-daily && sudo apt-get update && sudo apt-get install librecad && clear")
		print("Installation de Librecad + PPA terminée.")
	if element == "l":
		os.system("wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - && su -c 'echo \"deb https://dl.google.com/linux/chrome/deb/ stable main\" >> /etc/apt/sources.list.d/google.list' && sudo apt-get update")
		print('Ajout du dépot terminée.')
		os.system("sudo apt-get install google-chrome-stable")
		print('Installation de google chrome terminée.')
	if element == "m":
		os.system("sudo apt-get purge totem empathy software-center update-manager midori-granite")

print("Script d'installation terminé.")
sys.exit()

affiche()

Link to comment
Share on other sites

Pas mal je constate qu'on as tous nos variantes de scripts de post_install.

Sinon pour les personnes ne connaissant pas le python, il faudrait que tu rajoutes comment lancer le script ^^

 

python script.py

 

 

 

PS : chez moi le script déconne (v1) avec cette erreur.

 

File "script.py", line 27
   action = raw_input('Voulez-vous procèdez à l\'installation de logiciels tiers - inkscape - scribus - eog - gcolor2 - gnome-system-monitor - rar - 
                                                                                                                                                     ^
SyntaxError: EOL while scanning string literal

 

En faite c'est des "enter" qui se sont mis entre certaines commandes, surement du au c/c à partir du post, peut être mettre le script sur un serveur externe pour le récupérer directement pour éviter ce genre d'erreur.

Edited by Hitsouburaiken
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...