More work on simple installer

This commit is contained in:
Duncan Sommerville 2014-11-26 16:35:13 -05:00
parent f9d52c6c00
commit 51627e6270
3 changed files with 181 additions and 1 deletions

View File

@ -0,0 +1,111 @@
#!/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
#copy files to
## /etc/airtime
#+ /etc/apache2/sites-available/airtime
#+ /etc/apache2/sites-enabled/airtime
## /etc/cron.d/
## /etc/init.d/
## /etc/monit/conf.d/
# /usr/lib/airtime/airtime_virtualenv
## /usr/lib/airtime/api_clients
## /usr/lib/airtime/media-monitor
# /srv/airtime/stor
## /usr/lib/airtime/pypo
## /usr/lib/airtime/show-recorder
## /usr/lib/airtime/utils
## /usr/bin/airtime-*
## /usr/share/airtime
## /var/log/airtime
## /var/tmp/airtime
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../../
echo "* Creating /etc/airtime"
mkdir -p /etc/airtime
if [ ! -e /etc/airtime/airtime.conf ]; then
#config file airtime.conf exists, but Airtime is not installed
cp $AIRTIMEROOT/airtime_mvc/build/airtime.conf /etc/airtime
fi
#if [ -e /etc/airtime/airtime.conf -a "$DO_UPGRADE" -eq "0" ]; then
#config file airtime.conf exists, but Airtime is not installed
# mv /etc/airtime/airtime.conf airtime.conf.bak
# cp $AIRTIMEROOT/airtime_mvc/build/airtime.conf /etc/airtime
#fi
echo "* Creating /etc/monit/conf.d/monit-airtime-generic.cfg"
mkdir -p /etc/monit/conf.d/
if [ ! -e /etc/monit/conf.d/monit-airtime-generic.cfg ]; then
rm -f /etc/monit/conf.d/*airtime*
cp $AIRTIMEROOT/python_apps/monit/monit-airtime-generic.cfg /etc/monit/conf.d/
fi
echo "* Creating /etc/cron.d/airtime-crons"
HOUR=$(($RANDOM%24))
MIN=$(($RANDOM%60))
echo "$MIN $HOUR * * * root /usr/lib/airtime/utils/phone_home_stat" > /etc/cron.d/airtime-crons
echo "* Creating /usr/lib/airtime"
if [ "$python_service" -eq "0" ]; then
python $AIRTIMEROOT/python_apps/api_clients/install/api_client_install.py
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py
fi
if [ "$pypo" = "t" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py
fi
fi
cp -R $AIRTIMEROOT/utils /usr/lib/airtime
cp -R $AIRTIMEROOT/python_apps/std_err_override /usr/lib/airtime
echo "* Creating symbolic links in /usr/bin"
#create symbolic links
ln -sf /usr/lib/airtime/utils/airtime-import/airtime-import /usr/bin/airtime-import
ln -sf /usr/lib/airtime/utils/airtime-update-db-settings /usr/bin/airtime-update-db-settings
ln -sf /usr/lib/airtime/utils/airtime-check-system /usr/bin/airtime-check-system
ln -sf /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log
ln -sf /usr/lib/airtime/utils/airtime-test-soundcard /usr/bin/airtime-test-soundcard
ln -sf /usr/lib/airtime/utils/airtime-test-stream /usr/bin/airtime-test-stream
ln -sf /usr/lib/airtime/utils/airtime-silan /usr/bin/airtime-silan
echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime
chmod a+x /var/log/airtime
chown www-data:www-data /var/log/airtime/
chown pypo:pypo /var/log/airtime/pypo
chown pypo:pypo /var/log/airtime/pypo-liquidsoap
if [ "$web" = "t" ]; then
echo "* Creating /usr/share/airtime"
rm -rf "/usr/share/airtime"
mkdir -p /usr/share/airtime
cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/
rm -f /etc/logrotate.d/airtime-php
cp $AIRTIMEROOT/airtime_mvc/build/airtime-php.logrotate /etc/logrotate.d/airtime-php
fi
echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime
echo "* Creating /var/tmp/airtime"
mkdir -p /var/tmp/airtime
#Finished copying files

View File

@ -0,0 +1,67 @@
#!/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
set +e
dist=`lsb_release -is`
echo "Generating locales"
for i in `ls /usr/share/airtime/locale | grep ".._.."`; do
if [ "$dist" = "Debian" ]; then
grep -qi "^$i" /etc/locale.gen
if [ $? -ne 0 ]; then
echo "$i.UTF-8 UTF-8" >> /etc/locale.gen
fi
else
locale-gen "$i.utf8"
fi
done
set -e
if [ "$dist" = "Debian" ]; then
/usr/sbin/locale-gen
fi
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../../
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-initialize.py
fi
if [ "$pypo" = "t" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-initialize.py
fi
chmod 600 /etc/monit/conf.d/monit-airtime-generic.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-liquidsoap.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-media-monitor.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-playout.cfg
chmod 600 /etc/monit/conf.d/monit-airtime-liquidsoap.cfg
# Start monit if it is not running, or restart if it is.
# Need to ensure monit is running before Airtime daemons are run. This is
# so we can ensure they can register with monit to monitor them when they start.
# If monit is already running, this step is still useful as we need monit to
# reload its config files.
invoke-rc.d monit restart
#give monit some time to boot-up before issuing commands
sleep 1
set +e
if [ "$mediamonitor" = "t" ]; then
monit monitor airtime-media-monitor
fi
if [ "$pypo" = "t" ]; then
monit monitor airtime-playout
monit monitor airtime-liquidsoap
fi
set -e

View File

@ -131,7 +131,9 @@ chown -R www-data:www-data /var/log/airtime
apt-get -y --force-yes install postgresql php5-pgsql php5-mysql
# TODO copy files over to /usr/share/airtime
# Copy files to /usr/share/airtime
export airtime_service_start='t'
airtime/airtime-copy-files.sh $@
echo -e "\n-----------------------------------------------------"
echo " * Basic Setup DONE! * "