Removed many unnecessary files and started changing pypo to use setuptools

This commit is contained in:
Duncan Sommerville 2014-12-17 16:22:40 -05:00
parent 144923c353
commit 97805ad271
169 changed files with 5 additions and 8620 deletions

View file

@ -1,12 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# Hostname
host = 'localhost'
base_port = 80
base_dir = '/'

View file

@ -1,31 +0,0 @@
import os
import shutil
import sys
from configobj import ConfigObj
def get_current_script_dir():
return os.path.dirname(os.path.realpath(__file__))
def copy_dir(src_dir, dest_dir):
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
shutil.rmtree(dest_dir)
if not (os.path.exists(dest_dir)):
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
shutil.copytree(src_dir, dest_dir)
PATH_INI_FILE = '/etc/airtime/api_client.cfg'
current_script_dir = get_current_script_dir()
if not os.path.exists(PATH_INI_FILE):
shutil.copy('%s/../api_client.cfg'%current_script_dir, PATH_INI_FILE)
"""load config file"""
try:
config = ConfigObj("%s/../api_client.cfg" % current_script_dir)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
#copy python files
copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"])

View file

@ -1,21 +0,0 @@
import os
import sys
from configobj import ConfigObj
def remove_path(path):
os.system('rm -rf "%s"' % path)
def get_current_script_dir():
return os.path.dirname(os.path.realpath(__file__))
current_script_dir = get_current_script_dir()
"""load config file"""
try:
config = ConfigObj("%s/../api_client.cfg" % current_script_dir)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
print " * Removing API Client files"
remove_path(config["bin_dir"])

View file

@ -1,32 +0,0 @@
import os
import sys
from subprocess import Popen, PIPE, STDOUT
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 "+username)
else:
print "User already exists."
#add pypo to audio group
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
#add pypo to www-data group
os.system("adduser " + username + " www-data 1>/dev/null 2>&1")
#add pypo to pulse group
os.system("adduser " + username + " pulse 1>/dev/null 2>&1")
#add pypo to pulse-access group
os.system("adduser " + username + " pulse-access 1>/dev/null 2>&1")
if __name__ == "__main__":
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
create_user("pypo")

View file

@ -1,70 +0,0 @@
import os
import shutil
import sys
import subprocess
import random
import string
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
def get_current_script_dir():
current_script_dir = os.path.realpath(__file__)
index = current_script_dir.rindex('/')
return current_script_dir[0:index]
def copy_dir(src_dir, dest_dir):
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
shutil.rmtree(dest_dir)
if not (os.path.exists(dest_dir)):
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
shutil.copytree(src_dir, dest_dir)
def create_dir(path):
try:
os.makedirs(path)
# TODO : fix this, at least print the error
except Exception, e:
pass
def get_rand_string(length=10):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
try:
# Absolute path this script is in
current_script_dir = get_current_script_dir()
if not os.path.exists(PATH_INI_FILE):
shutil.copy('%s/../media-monitor.cfg'%current_script_dir, PATH_INI_FILE)
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
#copy monit files
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True, close_fds=True)
shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/')
#create log dir
create_dir(config['log_dir'])
#copy python files
copy_dir("%s/.."%current_script_dir, config["bin_dir"])
# mm2
mm2_source = os.path.realpath(os.path.join(current_script_dir,
"../../media-monitor2"))
copy_dir(mm2_source, os.path.join( config["bin_dir"], "mm2" ))
#copy init.d script
shutil.copy(config["bin_dir"]+"/airtime-media-monitor-init-d", "/etc/init.d/airtime-media-monitor")
except Exception, e:
print e

View file

@ -1,21 +0,0 @@
import subprocess
import os
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
try:
#create media-monitor dir under /var/tmp/airtime
if not os.path.exists("/var/tmp/airtime/media-monitor"):
os.makedirs("/var/tmp/airtime/media-monitor")
#update-rc.d init script
subprocess.call("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
#Start media-monitor daemon
if "airtime_service_start" in os.environ and os.environ["airtime_service_start"] == "t":
print "* Waiting for media-monitor processes to start..."
subprocess.call("invoke-rc.d airtime-media-monitor start", shell=True)
except Exception, e:
print e

View file

@ -1,44 +0,0 @@
import os
import shutil
import sys
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
def remove_file(path):
try:
os.remove(path)
except Exception, e:
pass
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
try:
#remove init.d script
print " * Removing Media-Monitor init.d Script"
remove_file("/etc/init.d/airtime-media-monitor")
#remove bin dir
print " * Removing Media-Monitor Program Directory"
shutil.rmtree(config['bin_dir'], ignore_errors=True)
#remove log dir
print " * Removing Media-Monitor Log Directory"
shutil.rmtree(config['log_dir'], ignore_errors=True)
#remove monit files
print " * Removing Media-Monitor Monit Files"
remove_file("/etc/monit/conf.d/monit-airtime-media-monitor.cfg")
remove_file("/etc/monit/conf.d/monit-airtime-generic.cfg")
except Exception, e:
print e

View file

@ -1,19 +0,0 @@
import subprocess
import os
import sys
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
try:
print "Waiting for media-monitor processes to stop...",
if (os.path.exists('/etc/init.d/airtime-media-monitor')):
subprocess.call("invoke-rc.d airtime-media-monitor stop", shell=True)
print "OK"
else:
print "Wasn't running"
subprocess.call("update-rc.d -f airtime-media-monitor remove".split(" "))
except Exception, e:
print e

View file

@ -1,50 +0,0 @@
# -*- coding: utf-8 -*-
import os
import sys
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
def remove_path(path):
os.system('rm -rf "%s"' % path)
def get_current_script_dir():
current_script_dir = os.path.realpath(__file__)
index = current_script_dir.rindex('/')
return current_script_dir[0:index]
def remove_monit_file():
os.system("rm -f /etc/monit/conf.d/monit-airtime-media-monitor.cfg")
try:
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
os.system("invoke-rc.d airtime-media-monitor stop")
os.system("rm -f /etc/init.d/airtime-media-monitor")
os.system("update-rc.d -f airtime-media-monitor remove >/dev/null 2>&1")
print "Removing monit file"
remove_monit_file()
print "Removing log directories"
remove_path(config["log_dir"])
print "Removing symlinks"
os.system("rm -f /usr/bin/airtime-media-monitor")
print "Removing application files"
remove_path(config["bin_dir"])
print "Uninstall complete."
except Exception, e:
print "exception:" + str(e)

View file

@ -1,9 +0,0 @@
set daemon 10 # Poll at 5 second intervals
set logfile /var/log/monit.log
set httpd port 2812
check process airtime-media-monitor
with pidfile "/var/run/airtime/airtime-media-monitor.pid"
start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-media-monitor stop"

View file

@ -1,32 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = I6EUOJM0D1EIGSMZ9T70
web_server_user = www-data
airtime_dir = /usr/share/airtime
base_url = localhost
base_port = 80
base_dir = '/'
;How many hours ahead of time should Airtime playout engine (PYPO)
;cache scheduled media files.
cache_ahead_hours = 1
[monit]
monit_user = guest
monit_password = airtime
[soundcloud]
connection_retries = 3
time_between_retries = 60

View file

@ -1,126 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
#############################
## Common
#############################
# Value needed to access the API
api_key = 'I6EUOJM0D1EIGSMZ9T70'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
#URL to register a components IP Address with the central web server
register_component = 'register-component/format/json/api_key/%%api_key%%/component/%%component%%'
# Hostname
host = 'localhost'
base_port = 80
base_dir = '/'
#############################
## Config for Media Monitor
#############################
# URL to setup the media monitor
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
# Tell Airtime the file id associated with a show instance.
upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%'
# URL to tell Airtime to update file's meta data
update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%'
# URL to tell Airtime we want a listing of all files it knows about
list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%/all/%%all%%'
# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir)
list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%'
# URL to tell Airtime we want to add watched directory
add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime about file system mount change
update_fs_mount = 'update-file-system-mount/format/json/api_key/%%api_key%%'
# URL to commit multiple updates from media monitor at the same time
reload_metadata_group = 'reload-metadata-group/format/json/api_key/%%api_key%%'
# URL to tell Airtime about file system mount change
handle_watched_dir_missing = 'handle-watched-dir-missing/format/json/api_key/%%api_key%%/dir/%%dir%%'
#############################
## Config for Recorder
#############################
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-file/format/json/api_key/%%api_key%%'
# URL to commit multiple updates from media monitor at the same time
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#############################
## Config for Pypo
#############################
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/'
# URL to tell Airtime we want to get stream setting
get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
#URL to update liquidsoap status
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to check live stream auth
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%'
#URL to update source status
update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%'
get_bootstrap_info = 'get-bootstrap-info/format/json/api_key/%%api_key%%'
get_files_without_replay_gain = 'get-files-without-replay-gain/api_key/%%api_key%%/dir_id/%%dir_id%%'
update_replay_gain_value = 'update-replay-gain-value/api_key/%%api_key%%'
notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%media_id%%/format/json'
notify_liquidsoap_started = 'rabbitmq-do-push/api_key/%%api_key%%/format/json'
get_stream_parameters = 'get-stream-parameters/api_key/%%api_key%%/format/json'
push_stream_stats = 'push-stream-stats/api_key/%%api_key%%/format/json'

View file

@ -1,31 +0,0 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/media-monitor'
# where the logging files live
log_dir = '/var/log/airtime/media-monitor'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# Media-Monitor preferences #
############################################
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
check_airtime_events = 30 #how long to queue metadata input from airtime.
# MM2 only:
touch_interval = 5
chunking_number = 450
request_max_wait = 3.0
rmq_event_wait = 0.1
logpath = '/var/log/airtime/media-monitor/media-monitor.log'
index_path = '/var/tmp/airtime/media-monitor/last_index'

View file

@ -1,6 +0,0 @@
set daemon 10 # Poll at 10 second intervals
set logfile /var/log/monit.log
set httpd port 2812
allow admin:$admin_pass
allow guest:airtime read-only

View file

@ -1,7 +0,0 @@
set daemon 10 # Poll at 5 second intervals
set logfile /var/log/monit.log
check process rabbitmq-server
with pidfile "/var/run/airtime/rabbitmq.pid"
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; /usr/lib/airtime/utils/rabbitmq-update-pid.sh'"
stop program = "/etc/init.d/rabbitmq-server stop"

View file

@ -1,140 +0,0 @@
import os
import grp
import stat
import shutil
import sys
import subprocess
import random
import string
import re
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
def get_current_script_dir():
current_script_dir = os.path.realpath(__file__)
index = current_script_dir.rindex('/')
return current_script_dir[0:index]
def copy_dir(src_dir, dest_dir):
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
shutil.rmtree(dest_dir)
if not (os.path.exists(dest_dir)):
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
shutil.copytree(src_dir, dest_dir)
def create_dir(path):
try:
os.makedirs(path)
except Exception, e:
pass
def get_rand_string(length=10):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
def get_rand_string(length=10):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
def get_monit_version():
version = 0
try:
p = subprocess.Popen(['monit', '-V'], stdout=subprocess.PIPE)
out = p.communicate()[0].strip()
search = re.search(r'This is Monit version (.*)\n', out, re.IGNORECASE)
if search:
matches = search.groups()
if len(matches) == 1:
version = matches[0]
except Exception:
print "Could not get monit version"
return version
#return 1 if version1 > version2
#return 0 if version1 == version2
#return -1 if version1 < version2
def version_compare(version1, version2):
def normalize(v):
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
return cmp(normalize(version1), normalize(version2))
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
try:
# Absolute path this script is in
current_script_dir = get_current_script_dir()
if not os.path.exists(PATH_INI_FILE):
shutil.copy('%s/../pypo.cfg'%current_script_dir, PATH_INI_FILE)
try:
os.remove("/etc/airtime/liquidsoap.cfg")
except Exception, e:
pass
gid = grp.getgrnam("pypo").gr_gid
os.chown("/etc/airtime", -1, gid)
os.chmod("/etc/airtime", stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
#copy monit files
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True, close_fds=True)
monit_version = get_monit_version()
if version_compare(monit_version, "5.3.0") >= 0:
shutil.copy('%s/../monit-airtime-liquidsoap.cfg' % current_script_dir, \
'/etc/monit/conf.d/monit-airtime-liquidsoap.cfg')
else:
shutil.copy('%s/../monit-pre530-airtime-liquidsoap.cfg' % current_script_dir, \
'/etc/monit/conf.d/monit-airtime-liquidsoap.cfg')
shutil.copy('%s/../monit-airtime-playout.cfg'%current_script_dir, '/etc/monit/conf.d/')
#create pypo log dir
create_dir(config['pypo_log_dir'])
os.system("chown -R pypo:pypo "+config["pypo_log_dir"])
#create liquidsoap log dir
create_dir(config['liquidsoap_log_dir'])
os.system("chown -R pypo:pypo "+config["liquidsoap_log_dir"])
#create cache, tmp, file dirs
create_dir(config['cache_dir'])
create_dir(config['file_dir'])
create_dir(config['tmp_dir'])
create_dir(config["base_recorded_files"])
#copy files to bin dir
copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/")
# delete /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap.cfg
# as we don't use it anymore.(CC-2552)
os.remove(config["bin_dir"]+"/bin/liquidsoap_scripts/liquidsoap.cfg")
#set permissions in bin dir and cache dir
os.system("chmod 755 "+os.path.join(config["bin_dir"], "bin/liquidsoap_scripts/notify.sh"))
os.system("chown -R pypo:pypo "+config["bin_dir"])
os.system("chown -R pypo:pypo "+config["cache_base_dir"])
os.system("chown -R pypo:pypo "+config["base_recorded_files"])
#copy init.d script
shutil.copy(config["bin_dir"]+"/bin/airtime-playout-init-d", "/etc/init.d/airtime-playout")
shutil.copy(config["bin_dir"]+"/bin/airtime-liquidsoap-init-d", "/etc/init.d/airtime-liquidsoap")
#copy log rotate script
shutil.copy(config["bin_dir"]+"/bin/liquidsoap_scripts/airtime-liquidsoap.logrotate", "/etc/logrotate.d/airtime-liquidsoap")
except Exception, e:
print e

View file

@ -1,95 +0,0 @@
import platform
import shutil
from subprocess import Popen, PIPE
import subprocess
import sys
import os
sys.path.append('/usr/lib/airtime/')
from api_clients import api_client
from configobj import ConfigObj
import logging
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
"""
This function returns the codename of the host OS by querying lsb_release.
If lsb_release does not exist, or an exception occurs the codename returned
is 'unknown'
"""
def get_os_codename():
try:
p = Popen("which lsb_release > /dev/null", shell=True)
sts = os.waitpid(p.pid, 0)[1]
if (sts == 0):
#lsb_release is available on this system. Let's get the os codename
p = Popen("lsb_release -sc", shell=True, stdout=PIPE)
codename = p.communicate()[0].strip('\r\n')
p = Popen("lsb_release -sd", shell=True, stdout=PIPE)
fullname = p.communicate()[0].strip('\r\n')
return (codename, fullname)
except Exception, e:
pass
return ("unknown", "unknown")
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
PATH_LIQUIDSOAP_BIN = '/usr/lib/airtime/pypo/bin/liquidsoap_bin'
#any debian/ubuntu codename in this et will automatically use the natty liquidsoap binary
arch_map = dict({"32bit":"i386", "64bit":"amd64"})
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
try:
#select appropriate liquidsoap file for given system os/architecture
architecture = platform.architecture()[0]
arch = arch_map[architecture]
print "* Detecting OS: ...",
(codename, fullname) = get_os_codename()
print " Found %s (%s) on %s architecture" % (fullname, codename, arch)
print " * Creating symlink to Liquidsoap binary"
p = Popen("which liquidsoap", shell=True, stdout=PIPE)
liq_path = p.communicate()[0].strip()
symlink_path = "/usr/bin/airtime-liquidsoap"
if p.returncode == 0:
try:
os.unlink(symlink_path)
except Exception:
#liq_path DNE, which is OK.
pass
os.symlink(liq_path, symlink_path)
else:
print " * Liquidsoap binary not found!"
sys.exit(1)
#initialize init.d scripts
subprocess.call("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True)
subprocess.call("update-rc.d airtime-liquidsoap defaults >/dev/null 2>&1", shell=True)
#clear out an previous pypo cache
print "* Clearing previous pypo cache"
subprocess.call("rm -rf /var/tmp/airtime/pypo/cache/scheduler/* >/dev/null 2>&1", shell=True)
if "airtime_service_start" in os.environ and os.environ["airtime_service_start"] == "t":
print "* Waiting for pypo processes to start..."
subprocess.call("invoke-rc.d airtime-liquidsoap start > /dev/null 2>&1", shell=True)
subprocess.call("invoke-rc.d airtime-playout start > /dev/null 2>&1", shell=True)
except Exception, e:
print e

View file

@ -1,54 +0,0 @@
import os
import shutil
import sys
from configobj import ConfigObj
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
def remove_file(path):
try:
os.remove(path)
except Exception, e:
pass
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
try:
#remove log rotate script
print " * Removing Pypo Log Rotate Script"
remove_file("/etc/logrotate.d/airtime-liquidsoap")
#remove init.d script
print " * Removing Pypo init.d Script"
remove_file("/etc/init.d/airtime-playout")
remove_file("/etc/init.d/airtime-liquidsoap")
#remove bin, cache, tmp and file dir
print " * Removing Pypo Program Directory"
shutil.rmtree(config['bin_dir'], ignore_errors=True)
shutil.rmtree(config['cache_dir'], ignore_errors=True)
shutil.rmtree(config['file_dir'], ignore_errors=True)
shutil.rmtree(config['tmp_dir'], ignore_errors=True)
#remove liquidsoap and pypo log dir
print " * Removing Pypo Log Directories"
shutil.rmtree(config['liquidsoap_log_dir'], ignore_errors=True)
shutil.rmtree(config['pypo_log_dir'], ignore_errors=True)
#remove monit files
print " * Removing Pypo Monit Files"
remove_file("/etc/monit/conf.d/monit-airtime-playout.cfg")
remove_file("/etc/monit/conf.d/monit-airtime-liquidsoap.cfg")
remove_file("/etc/monit/conf.d/monit-airtime-generic.cfg")
except Exception, e:
print e

View file

@ -1,33 +0,0 @@
import os
import sys
import subprocess
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
try:
#stop pypo and liquidsoap processes
print "Waiting for Pypo process to stop...",
try:
os.remove("/usr/bin/airtime-liquidsoap")
except Exception, e:
pass
if (os.path.exists('/etc/init.d/airtime-playout')):
subprocess.call("invoke-rc.d airtime-playout stop", shell=True)
print "OK"
else:
print "Wasn't running"
print "Waiting for Liquidsoap process to stop...",
if (os.path.exists('/etc/init.d/airtime-liquidsoap')):
subprocess.call("invoke-rc.d airtime-liquidsoap stop", shell=True)
print "OK"
else:
print "Wasn't running"
subprocess.call("update-rc.d -f airtime-playout remove".split(" "))
subprocess.call("update-rc.d -f airtime-liquidsoap remove".split(" "))
except Exception, e:
print e

@ -1 +0,0 @@
Subproject commit 492242f4bb7367afebbf2f096067cb5a5d3c0449

View file

@ -1,17 +0,0 @@
set daemon 15 # Poll at 5 second intervals
set logfile /var/log/monit.log
set httpd port 2812
check process airtime-liquidsoap matching "airtime-liquidsoap.*airtime.*ls_script"
if does not exist for 3 cycles then restart
start program = "/etc/init.d/airtime-liquidsoap start" with timeout 30 seconds
stop program = "/etc/init.d/airtime-liquidsoap stop"
if mem > 600 MB for 3 cycles then restart
if failed host localhost port 1234
send "version\r\nexit\r\n"
expect "Liquidsoap"
with timeout 2 seconds retry 3 for 2 cycles
then restart

View file

@ -1,9 +0,0 @@
set daemon 10 # Poll at 5 second intervals
set logfile /var/log/monit.log
set httpd port 2812
check process airtime-playout
with pidfile "/var/run/airtime/airtime-playout.pid"
start program = "/etc/init.d/airtime-playout start" with timeout 5 seconds
stop program = "/etc/init.d/airtime-playout stop"

View file

@ -1,8 +0,0 @@
set daemon 15 # Poll at 5 second intervals
set logfile /var/log/monit.log
set httpd port 2812
check process airtime-liquidsoap with pidfile "/var/run/airtime/airtime-liquidsoap.pid"
start program = "/etc/init.d/airtime-liquidsoap start" with timeout 5 seconds
stop program = "/etc/init.d/airtime-liquidsoap stop"

View file

@ -56,37 +56,18 @@ stop () {
sleep 2
}
start_with_monit () {
start
monit monitor airtime-liquidsoap >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
stop
}
case "${1:-''}" in
'stop')
echo "* Stopping Liquidsoap without notifying Monit process watchdog. If Monit is
* running it will automatically bring the Liquidsoap back up. You probably want
* 'stop-with-monit' instead of 'stop'."
echo -n "Stopping $NAME: "
stop
echo "Done."
;;
'start')
echo "* Starting $NAME without Monit process watchdog. To make sure Monit is watching
* Liquidsoap, use 'start-with-monit' instead of 'start'."
echo -n "Starting $NAME: "
start
echo "Done."
;;
'restart')
# restart commands here
echo -n "Restarting $NAME: "
stop
start
@ -104,18 +85,6 @@ case "${1:-''}" in
echo "$NAME is not running"
exit 1
;;
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
*) # no parameter specified
echo "Usage: $SELF start|stop|restart|status"

View file

@ -28,16 +28,6 @@ stop () {
rm -f $PIDFILE
}
start_with_monit() {
start
monit monitor airtime-playout >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-playout >/dev/null 2>&1
stop
}
case "${1:-''}" in
'start')
# start commands here
@ -58,18 +48,6 @@ case "${1:-''}" in
start
echo "Done."
;;
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
'status')
# status commands here

View file

@ -1,19 +0,0 @@
import os
import sys
import time
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(3)
os.system("deluser --remove-home " + username + " 1>/dev/null 2>&1")
if __name__ == "__main__":
if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
remove_user("pypo")