From 674b8c69e4317d0ff4d0bca7897cbce074d56dfd Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 12 Jan 2015 16:13:39 -0500 Subject: [PATCH] Add very basic uninstall script, move install script to root directory --- README | 4 +- installer/install => install | 24 ++--- installer/lxc-bootstrap | 2 +- .../pypo/pypo/airtime-liquidsoap-init-d | 94 ------------------- python_apps/pypo/pypo/airtime-playout-init-d | 61 ------------ uninstall | 51 ++++++++++ 6 files changed, 59 insertions(+), 177 deletions(-) rename installer/install => install (95%) delete mode 100755 python_apps/pypo/pypo/airtime-liquidsoap-init-d delete mode 100755 python_apps/pypo/pypo/airtime-playout-init-d create mode 100755 uninstall diff --git a/README b/README index 483367e88..887cc5d37 100755 --- a/README +++ b/README @@ -32,9 +32,7 @@ http://wiki.sourcefabric.org/display/CC/Airtime+Dev+Site Basic installation has two steps: -1) Run the install script, located in the Airtime/installer directory. - - cd installer +1) Run the install script, located in the Airtime root directory. For an interactive installation, run: diff --git a/installer/install b/install similarity index 95% rename from installer/install rename to install index a17ed2efd..1cdd88b3b 100755 --- a/installer/install +++ b/install @@ -8,7 +8,7 @@ if [[ $EUID -ne 0 ]]; then fi SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" -AIRTIMEROOT="$( cd "$( dirname ${SCRIPT_DIR} )" && pwd )" +AIRTIMEROOT=${SCRIPT_DIR} showhelp () { echo "Usage: sudo bash install [options] @@ -281,7 +281,7 @@ if [ "$apache" = "t" ]; then if [ ! -f /etc/apache2/sites-available/${airtimeconfigfile} ]; then verbose "\n * Creating Apache config for Airtime..." - sed -e "s@WEB_ROOT@${web_root}@g" ${SCRIPT_DIR}/apache/airtime-vhost > /etc/apache2/sites-available/${airtimeconfigfile} + sed -e "s@WEB_ROOT@${web_root}@g" ${SCRIPT_DIR}/installer/apache/airtime-vhost > /etc/apache2/sites-available/${airtimeconfigfile} loudCmd "a2dissite 000-default" loudCmd "a2ensite airtime" else @@ -344,13 +344,7 @@ cp -R ${AIRTIMEROOT}/python_apps/media-monitor/media-monitor2 /usr/lib/airtime/m verbose "...Done" verbose "\n * Installing media-monitor..." -if [ -z web_root ]; then - python ${web_root}/python_apps/media-monitor/setup.py install -elif [ "$in_place" = "t" ]; then - python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py install -else - python /usr/share/airtime/python_apps/media-monitor/setup.py install -fi +python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py install verbose "...Done" verbose "\n * Copying pypo files..." @@ -359,13 +353,7 @@ cp -R ${AIRTIMEROOT}/python_apps/pypo/pypo /usr/lib/airtime/pypo/bin/ verbose "...Done" verbose "\n * Installing pypo..." -if [ -z web_root ]; then - python ${web_root}/python_apps/pypo/setup.py install -elif [ "$in_place" = "t" ]; then - python ${AIRTIMEROOT}/python_apps/pypo/setup.py install -else - python /usr/share/airtime/python_apps/pypo/setup.py install -fi +python ${AIRTIMEROOT}/python_apps/pypo/setup.py install verbose "...Done" verbose "\n * Creating liquidsoap symlink..." @@ -431,7 +419,7 @@ fi # PHP Config File for Apache if [ ! -f "/etc/php5/apache2/conf.d/airtime.ini" ]; then verbose "\n * Creating Airtime PHP config for Apache..." - cp ${SCRIPT_DIR}/php/airtime.ini /etc/php5/apache2/conf.d/airtime.ini + cp ${SCRIPT_DIR}/installer/php/airtime.ini /etc/php5/apache2/conf.d/airtime.ini else verbose "\nAirtime PHP config for Apache already exists, skipping" fi @@ -524,7 +512,7 @@ if [ "$install_dependencies" = "t" ]; then loud "-----------------------------------------------------" verbose "\n * Reading requirements-${dist,,}-${code,,}.apt..." - loudCmd "apt-get -y -m --force-yes install $(grep -vE '^\s*#' ${SCRIPT_DIR}/lib/requirements-${dist,,}-${code,,}.apt | tr '\n' ' ')" + loudCmd "apt-get -y -m --force-yes install $(grep -vE '^\s*#' ${SCRIPT_DIR}/installer/lib/requirements-${dist,,}-${code,,}.apt | tr '\n' ' ')" fi verbose "\n * Restarting apache..." diff --git a/installer/lxc-bootstrap b/installer/lxc-bootstrap index ffe092945..cdddffce6 100755 --- a/installer/lxc-bootstrap +++ b/installer/lxc-bootstrap @@ -51,7 +51,7 @@ lxc-attach -n ${name} -- git -C /usr/share/Airtime checkout 2.5.x-installer-moni echo "...Done" echo -e "\n * Running installer..." -lxc-attach -n ${name} -e -- /usr/share/Airtime/installer/install -ifapdIv +lxc-attach -n ${name} -e -- /usr/share/Airtime/install -ifapdIv echo "...Done" IP=$(lxc-info -i -n ${name} -H) diff --git a/python_apps/pypo/pypo/airtime-liquidsoap-init-d b/python_apps/pypo/pypo/airtime-liquidsoap-init-d deleted file mode 100755 index 8cfafb4eb..000000000 --- a/python_apps/pypo/pypo/airtime-liquidsoap-init-d +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: airtime-liquidsoap -# Required-Start: $local_fs $remote_fs $network $syslog $all -# Required-Stop: $local_fs $remote_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Liquidsoap daemon -### END INIT INFO - -USERID=WEB_USER -GROUPID=WEB_USER -NAME="Liquidsoap Playout Engine" - -DAEMON=/usr/lib/airtime/pypo/bin/airtime-liquidsoap -PIDFILE=/var/run/airtime/airtime-liquidsoap.pid -EXEC='/usr/bin/airtime-liquidsoap' - -start () { - mkdir -p /var/log/airtime/pypo-liquidsoap - chown $USERID:$GROUPID /var/log/airtime/pypo-liquidsoap - - chown $USERID:$GROUPID /etc/airtime - touch /etc/airtime/liquidsoap.cfg - chown $USERID:$GROUPID /etc/airtime/liquidsoap.cfg - - touch $PIDFILE - chown $USERID:$GROUPID $PIDFILE - - #start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \ - #--pidfile $PIDFILE --nicelevel -15 --startas $DAEMON - start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \ - --startas $DAEMON --exec $EXEC -} - -stop () { - timeout --version >/dev/null 2>&1 - RESULT="$?" - - #send term signal after 10 seconds - if [ "$RESULT" = "0" ]; then - timeout -s9 10s /usr/lib/airtime/airtime_virtualenv/bin/python \ - /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py - else - #some earlier versions of Ubuntu (Lucid) had a different timeout - #command that takes different input parameters. - timeout 10 /usr/lib/airtime/airtime_virtualenv/bin/python \ - /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py - fi - # Send TERM after 5 seconds, wait at most 30 seconds. - #start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --pidfile $PIDFILE - start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --exec $EXEC - - rm -f $PIDFILE - sleep 2 -} - -case "${1:-''}" in - 'stop') - echo -n "Stopping $NAME: " - stop - echo "Done." - ;; - 'start') - echo -n "Starting $NAME: " - start - echo "Done." - ;; - 'restart') - echo -n "Restarting $NAME: " - stop - start - echo "Done." - ;; - - 'status') - if [ -f "$PIDFILE" ]; then - pid=`cat $PIDFILE` - if [ -d "/proc/$pid" ]; then - echo "$NAME is running" - exit 0 - fi - fi - echo "$NAME is not running" - exit 1 - ;; - - *) # no parameter specified - echo "Usage: $SELF start|stop|restart|status" - exit 1 - ;; - -esac diff --git a/python_apps/pypo/pypo/airtime-playout-init-d b/python_apps/pypo/pypo/airtime-playout-init-d deleted file mode 100755 index adb223626..000000000 --- a/python_apps/pypo/pypo/airtime-playout-init-d +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: airtime-playout -# Required-Start: $local_fs $remote_fs $network $syslog $all -# Required-Stop: $local_fs $remote_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Manage airtime-playout daemon -### END INIT INFO - -USERID=WEB_USER -NAME="Airtime Scheduler" - -DAEMON=/usr/lib/airtime/pypo/bin/airtime-playout -PIDFILE=/var/run/airtime/airtime-playout.pid - -start () { - mkdir -p /var/log/airtime/pypo - - start-stop-daemon --start --background --quiet --chuid $USERID:$USERID \ - --make-pidfile --pidfile $PIDFILE --startas $DAEMON -} - -stop () { - # Send TERM after 5 seconds, wait at most 30 seconds. - start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE - rm -f $PIDFILE -} - -case "${1:-''}" in - 'start') - # start commands here - echo -n "Starting $NAME: " - start - echo "Done." - ;; - 'stop') - # stop commands here - echo -n "Stopping $NAME: " - stop - echo "Done." - ;; - 'restart') - # restart commands here - echo -n "Restarting $NAME: " - stop - start - echo "Done." - ;; - - 'status') - # status commands here - /usr/bin/airtime-check-system - ;; - *) # no parameter specified - echo "Usage: $SELF start|stop|restart|status" - exit 1 - ;; - -esac diff --git a/uninstall b/uninstall new file mode 100755 index 000000000..f72e0ff6f --- /dev/null +++ b/uninstall @@ -0,0 +1,51 @@ +#!/bin/bash -e +#-e Causes bash script to exit if any of the installers +#return with a non-zero return value. + +if [[ $EUID -ne 0 ]]; then + echo "Please run as root user." + exit 1 +fi + +SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +AIRTIMEROOT=${SCRIPT_DIR} + +FILES=( + "/etc/airtime" + "/var/log/airtime" + "/usr/lib/airtime" + "/usr/share/airtime" + "/etc/init/airtime*" + "/usr/bin/airtime*" + "/etc/apache2/sites-available/airtime*" + "pip airtime-playout" + "pip airtime-media-monitor" + ) + +echo -e "The following files, directories, and services will be removed:\n" +for i in ${FILES[*]}; do + echo $i +done + +echo -e "\nThis will permanently remove Airtime and all related files from your computer. \ +Any files in Airtime directories will be deleted. Are you sure you want to proceed? (Y/n): \c" +read IN +if [[ ! ( "$IN" = "y" || "$IN" = "Y" ) ]]; then + exit 0 +fi + +echo "Uninstalling Airtime..." +rm -rf /etc/airtime +rm -rf /var/log/airtime/ +rm -rf /usr/lib/airtime/ + +rm -rf /usr/share/airtime + +rm -f /etc/init/airtime* +rm -f /usr/bin/airtime* + +rm -f /etc/apache2/sites-enabled/airtime* +rm -f /etc/apache2/sites-available/airtime* + +pip uninstall -y airtime-playout airtime-media-monitor +echo "...Done" \ No newline at end of file