Just writing up a python script for post install on openSUSE machines. Just thought I would share on here. Currently it just updates your machine post install but im looking to add more features to it possibly with argparse for adding specific packages.
Linky to Github here
Just working on it when I can, if you have anything you always do after fresh install feel free to suggest here, or create an issue on Github. Its very experimental just now and will be broken and fixed regularly.
On 2014-02-03, williamfleming <firstname.lastname@example.org> wrote:
> Just writing up a python script for post install on openSUSE machines.
> Just thought I would share on here. Currently it just updates your
> machine post install but im looking to add more features to it possibly
> with argparse for adding specific packages.
> ‘Linky to Github here’ (https://github.com/william20111/opensusepy)
For those who are interested, I’ve postscripted the contributed code to this message.
William - thanks for your contribution. I just have three questions:
- Exactly who are your target users for this code?
- What advantage did you envisage using Python rather than simple bash?
- If you intending to make life easier for new openSUSE users, have you considered programming for YaST (which has
recently been ported from YCP to Ruby)? It would mean coding in Ruby rather than Python but they are very similar.
P.S. William’s Python code (indentation on HTML broken because of openSUSE’s borked NNTP->HTML conversion for code - a
particularly rubbish bug for Python code!):
# Post install script for opensuse 13.1
# William Fleming
from subprocess import Popen, PIPE
_LOGFILE = "/tmp/opensusepy"
_SPLIT = "---------------------------------------"
_FAIL = "[FAIL]"
_PASS = "[PASS]"
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
self.HEADER = ''
self.OKBLUE = ''
self.OKGREEN = ''
self.WARNING = ''
self.FAIL = ''
self.ENDC = ''
plt = platform.linux_distribution()
if plt == "12.3":
print(bcolors.OKGREEN + "You are running " + plt + " " + _PASS + bcolors.ENDC)
print(bcolors.FAIL + "Your not running a supported version of Opensuse " + _FAIL + bcolors.ENDC)
uid = os.geteuid()
if uid == 0:
print(bcolors.OKGREEN + "You have root privileges " + _PASS + bcolors.ENDC)
print(bcolors.FAIL + "You do not have root privileges " + _PASS + bcolors.ENDC)
with open(os.devenull, 'w') as tempf:
upgrd = Popen("zypper", "up", "--non-interactive", "--quiet"], stdout=tempf).communicate()
print(bcolors.FAIL + " " + _FAIL + bcolors.ENDC)
with open(os.devnull, 'w') as tempf:
pydev = Popen("zypper", "in","python3","python-pip","--non-interactive", "quiet"], stdout=tempf).communicate()
""" Start the script"""
if __name__ == "__main__":
print("This is version 0.1 of opensuse.py" + "
" + _SPLIT)
m = methods()