diff --git a/pypo/install/pypo-install.py b/pypo/install/pypo-install.py index da6d11835..8f91f33d3 100644 --- a/pypo/install/pypo-install.py +++ b/pypo/install/pypo-install.py @@ -91,6 +91,7 @@ try: shutil.copy("pypo-daemontools-logger.sh", "/etc/service/pypo-fetch/log/run") os.system("chmod -R 755 /etc/service/pypo-fetch") os.system("chown -R pypo:pypo /etc/service/pypo-fetch") + time.sleep(1) os.system("svc -t /etc/service/pypo-fetch") print "Installing daemontool script pypo-push" @@ -100,6 +101,7 @@ try: shutil.copy("pypo-daemontools-logger.sh", "/etc/service/pypo-push/log/run") os.system("chmod -R 755 /etc/service/pypo-push") os.system("chown -R pypo:pypo /etc/service/pypo-push") + time.sleep(1) os.system("svc -t /etc/service/pypo-push") print "Installing daemontool script pypo-liquidsoap" @@ -111,8 +113,12 @@ try: shutil.copy("pypo-daemontools-logger.sh", "/etc/service/pypo-liquidsoap/log/run") os.system("chmod -R 755 /etc/service/pypo-liquidsoap") os.system("chown -R pypo:pypo /etc/service/pypo-liquidsoap") + time.sleep(1) os.system("svc -u /etc/service/pypo-liquidsoap") + print "Waiting for processes to start..." + time.sleep(2) + p = Popen('svstat /etc/service/pypo-fetch', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) output = p.stdout.read() if (output.find("unable to open supervise/ok: file does not exist") >= 0): diff --git a/pypo/install/pypo-uninstall.py b/pypo/install/pypo-uninstall.py new file mode 100644 index 000000000..956ed7e38 --- /dev/null +++ b/pypo/install/pypo-uninstall.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys +import time + +if os.geteuid() != 0: + print "Please run this as root." + sys.exit(1) + +BASE_PATH = '/opt/pypo/' + +def remove_path(path): + os.system("rm -rf " + path) + +def remove_user(username): + os.system("killall -u " + username) + + #allow all process to be completely closed before we attempt to delete user + print "Waiting for processes to close..." + time.sleep(5) + + os.system("deluser --remove-home " + username) + #os.system("delgroup " + username) + +try: + print "Removing log directories" + remove_path("/var/log/pypo") + + print "Removing pypo files" + remove_path(BASE_PATH) + + print "Removing daemontool script pypo-fetch" + os.system("svc -dx /etc/service/pypo-fetch") + remove_path("rm -rf /etc/service/pypo-fetch") + + print "Removing daemontool script pypo-push" + os.system("svc -dx /etc/service/pypo-push") + remove_path("rm -rf /etc/service/pypo-push") + + print "Removing daemontool script pypo-liquidsoap" + os.system("svc -dx /etc/service/pypo-liquidsoap") + remove_path("rm -rf /etc/service/pypo-liquidsoap") + + remove_user("pypo") +except Exception, e: + print "exception:" + str(e) \ No newline at end of file