cc-2055: switch to init.d
-allow install script to be created from any location (no hardcoded paths) -make python install scripts return 1 on error -daemon now started automatically on boot using rc.local autostart -change all prints to logs instead -create airtime-uninstall shell script (and remove pypo user in here) -create pypo user in shell script
This commit is contained in:
parent
079d9d36b0
commit
6ab5ac4582
23 changed files with 179 additions and 224 deletions
|
@ -14,7 +14,7 @@ import shutil
|
|||
import string
|
||||
import platform
|
||||
from configobj import ConfigObj
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from subprocess import Popen
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
|
@ -29,27 +29,6 @@ def create_path(path):
|
|||
else:
|
||||
print "Directory already exists " + path
|
||||
|
||||
def create_user(username):
|
||||
print "Checking for user "+username
|
||||
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
output = p.stdout.read()
|
||||
if (output[0:3] != "uid"):
|
||||
# Make the pypo user
|
||||
print "Creating user "+username
|
||||
os.system("adduser --system --quiet --group --shell /bin/bash "+username)
|
||||
|
||||
#set pypo password
|
||||
p = os.popen('/usr/bin/passwd pypo 1>/dev/null 2>&1', 'w')
|
||||
p.write('pypo\n')
|
||||
p.write('pypo\n')
|
||||
p.close()
|
||||
else:
|
||||
print "User already exists."
|
||||
#add pypo to audio group
|
||||
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
|
||||
#add pypo to pulse-access group
|
||||
#os.system("adduser " + username + " pulse-access 1>/dev/null 2>&1")
|
||||
|
||||
def copy_dir(src_dir, dest_dir):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
#print "Removing old directory "+dest_dir
|
||||
|
@ -61,7 +40,6 @@ def copy_dir(src_dir, dest_dir):
|
|||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
#print current_script_dir[0:index]
|
||||
return current_script_dir[0:index]
|
||||
|
||||
def is_natty():
|
||||
|
@ -86,18 +64,13 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
current_script_dir = get_current_script_dir()
|
||||
#print "Checking and removing any existing pypo processes"
|
||||
#os.system("python %s/pypo-uninstall.py 1>/dev/null 2>&1"% current_script_dir)
|
||||
#time.sleep(5)
|
||||
|
||||
p = Popen("/etc/init.d/airtime-playout stop", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
# Create users
|
||||
create_user("pypo")
|
||||
|
||||
create_path(config["pypo_log_dir"])
|
||||
os.system("chmod -R 755 " + config["pypo_log_dir"])
|
||||
os.system("chown -R pypo:pypo "+config["pypo_log_dir"])
|
||||
|
@ -148,9 +121,13 @@ try:
|
|||
print "Installing pypo daemon"
|
||||
shutil.copy(config["bin_dir"]+"/bin/airtime-playout-init-d", "/etc/init.d/airtime-playout")
|
||||
|
||||
p = Popen("update-rc.d airtime-playout defaults", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
print "Waiting for processes to start..."
|
||||
p = Popen("/etc/init.d/airtime-playout start", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
||||
|
|
|
@ -15,15 +15,6 @@ PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
|||
def remove_path(path):
|
||||
os.system("rm -rf " + path)
|
||||
|
||||
def remove_user(username):
|
||||
os.system("killall -u %s 1>/dev/null 2>&1" % 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 + " 1>/dev/null 2>&1")
|
||||
|
||||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
|
@ -35,9 +26,10 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
os.system("/etc/init.d/airtime-playout stop")
|
||||
os.system("rm -f /etc/init.d/airtime-playout")
|
||||
|
||||
print "Removing cache directories"
|
||||
remove_path(config["cache_base_dir"])
|
||||
|
@ -48,7 +40,6 @@ try:
|
|||
print "Removing pypo files"
|
||||
remove_path(config["bin_dir"])
|
||||
|
||||
remove_user("pypo")
|
||||
print "Pypo uninstall complete."
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue