Format shell scripts

Fix flags order
This commit is contained in:
jo 2021-08-16 13:45:32 +02:00
parent 6c2e547808
commit 8b3e09d41c
24 changed files with 1487 additions and 1499 deletions

View File

@ -29,9 +29,8 @@ export RABBITMQ_VHOST
export AIRTIME_UNIT_TEST="1" export AIRTIME_UNIT_TEST="1"
#Change the working directory to this script's directory #Change the working directory to this script's directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" && pwd)"
cd $DIR cd $DIR
#Run the unit tests #Run the unit tests
phpunit --verbose --log-junit test_results.xml phpunit --verbose --log-junit test_results.xml

View File

@ -8,10 +8,10 @@ if [ -d .git ]; then
fi fi
if [ "${git_build}" = "y" ]; then if [ "${git_build}" = "y" ]; then
git_version=`git tag --points-at HEAD` git_version=$(git tag --points-at HEAD)
echo " * Version from tag: ${git_version}" echo " * Version from tag: ${git_version}"
if [ "${git_version}" = "" ]; then if [ "${git_version}" = "" ]; then
git_version=`git rev-parse --short HEAD` git_version=$(git rev-parse --short HEAD)
echo " * Overriding empty version with sha1 commit-ish: ${git_version}" echo " * Overriding empty version with sha1 commit-ish: ${git_version}"
fi fi
echo ${git_version} > VERSION echo ${git_version} > VERSION

View File

@ -1,8 +1,8 @@
#!/bin/bash -e #!/bin/bash -e
apt-get install -y --force-yes lsb-release sudo apt-get install -y --force-yes lsb-release sudo
dist=`lsb_release -is` dist=$(lsb_release -is)
code=`lsb_release -cs` code=$(lsb_release -cs)
cpu=`getconf LONG_BIT` cpu=$(getconf LONG_BIT)
cpuvalue= cpuvalue=
#enable apt.sourcefabric.org source #enable apt.sourcefabric.org source
@ -17,8 +17,6 @@ apt-get update
apt-get -y --force-yes install sourcefabric-keyring apt-get -y --force-yes install sourcefabric-keyring
apt-get update apt-get update
if [ "$dist" = "Ubuntu" ]; then if [ "$dist" = "Ubuntu" ]; then
set +e set +e
grep -E "deb http://ca.archive.ubuntu.com/ubuntu/ $code multiverse" /etc/apt/sources.list grep -E "deb http://ca.archive.ubuntu.com/ubuntu/ $code multiverse" /etc/apt/sources.list
@ -62,11 +60,11 @@ apt-get -y --force-yes install libopus0 libopus-dev libopus-dbg libopus-doc
#obsoleted code end #obsoleted code end
apt-get -y --force-yes install git-core ocaml-findlib libao-ocaml-dev \ apt-get -y --force-yes install git-core ocaml-findlib libao-ocaml-dev \
libportaudio-ocaml-dev libmad-ocaml-dev libtaglib-ocaml-dev libalsa-ocaml-dev \ libportaudio-ocaml-dev libmad-ocaml-dev libtaglib-ocaml-dev libalsa-ocaml-dev \
libvorbis-ocaml-dev libladspa-ocaml-dev libxmlplaylist-ocaml-dev libflac-dev \ libvorbis-ocaml-dev libladspa-ocaml-dev libxmlplaylist-ocaml-dev libflac-dev \
libxml-dom-perl libxml-dom-xpath-perl patch autoconf libmp3lame-dev \ libxml-dom-perl libxml-dom-xpath-perl patch autoconf libmp3lame-dev \
libcamomile-ocaml-dev libcamlimages-ocaml-dev libtool libpulse-dev camlidl \ libcamomile-ocaml-dev libcamlimages-ocaml-dev libtool libpulse-dev camlidl \
libfaad-dev libpcre-ocaml-dev libfftw3-3 dialog libfaad-dev libpcre-ocaml-dev libfftw3-3 dialog
if [ "$code" != "lucid" ]; then if [ "$code" != "lucid" ]; then
apt-get -y --force-yes install libvo-aacenc-dev apt-get -y --force-yes install libvo-aacenc-dev

View File

@ -5,7 +5,7 @@ exec 2>&1
ROOT_UID="0" ROOT_UID="0"
#Check if run as root #Check if run as root
if [ "$UID" -ne "$ROOT_UID" ] ; then if [ "$UID" -ne "$ROOT_UID" ]; then
echo "You must have 'sudo' right to do that!" echo "You must have 'sudo' right to do that!"
exit 1 exit 1
fi fi
@ -13,7 +13,7 @@ fi
rm -rf ./liquidsoap-compile_logs rm -rf ./liquidsoap-compile_logs
mkdir -p ./liquidsoap-compile_logs mkdir -p ./liquidsoap-compile_logs
showhelp () { showhelp() {
echo "Usage: run.sh [options] [parameters] echo "Usage: run.sh [options] [parameters]
-c all|ubuntu_lucid_32 Compile liquidsoap on all platforms or specified platform. -c all|ubuntu_lucid_32 Compile liquidsoap on all platforms or specified platform.
-b all|ubuntu_lucid_32 Build shroot environments for all platforms or specified platform. -b all|ubuntu_lucid_32 Build shroot environments for all platforms or specified platform.
@ -21,20 +21,20 @@ showhelp () {
exit 0 exit 0
} }
build_env () { build_env() {
if [ $sudo_user = "-1" ];then if [ $sudo_user = "-1" ]; then
echo "Please use -u to assign sudo username before build environments." echo "Please use -u to assign sudo username before build environments."
exit 1 exit 1
fi fi
echo "build_env $1" echo "build_env $1"
#exec > >(tee ./liquidsoap_compile_logs/build_env_$1.log) #exec > >(tee ./liquidsoap_compile_logs/build_env_$1.log)
os=`echo $1 | awk '/(debian)/'` os=$(echo $1 | awk '/(debian)/')
cpu=`echo $1 | awk '/(64)/'` cpu=$(echo $1 | awk '/(64)/')
dist=`echo $1 | awk -F "_" '{print $2}'` dist=$(echo $1 | awk -F "_" '{print $2}')
rm -f /etc/schroot/chroot.d/$1.conf rm -f /etc/schroot/chroot.d/$1.conf
if cat /etc/passwd | awk -F:'{print $1}' | grep "tmp" >/dev/null 2>&1;then if cat /etc/passwd | awk -F:'{print $1}' | grep "tmp" > /dev/null 2>&1; then
echo "User tmp exists." echo "User tmp exists."
else else
useradd tmp useradd tmp
@ -53,8 +53,8 @@ build_env () {
mkdir -p /srv/chroot/$1 mkdir -p /srv/chroot/$1
#cp liquidsoap_compile.sh /srv/chroot/$1/ #cp liquidsoap_compile.sh /srv/chroot/$1/
if [ "$os" = "" ];then if [ "$os" = "" ]; then
if [ "$cpu" = "" ];then if [ "$cpu" = "" ]; then
echo "debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/" echo "debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/"
debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/ debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/
else else
@ -62,7 +62,7 @@ build_env () {
debootstrap --variant=buildd --arch=amd64 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/ debootstrap --variant=buildd --arch=amd64 $dist /srv/chroot/$1 http://archive.ubuntu.com/ubuntu/
fi fi
else else
if [ "$cpu" = "" ];then if [ "$cpu" = "" ]; then
echo "debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://ftp.debian.com/debian/" echo "debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://ftp.debian.com/debian/"
debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://ftp.debian.com/debian/ debootstrap --variant=buildd --arch=i386 $dist /srv/chroot/$1 http://ftp.debian.com/debian/
else else
@ -73,16 +73,16 @@ build_env () {
} }
compile_liq () { compile_liq() {
echo "complie_liq $1" echo "complie_liq $1"
#exec > >(tee ./liquidsoap_compile_logs/compile_liq_$1.log) #exec > >(tee ./liquidsoap_compile_logs/compile_liq_$1.log)
binfilename=`echo $1 | sed -e 's/ubuntu/liquidsoap/g' -e 's/debian/liquidsoap/g' -e 's/32/i386/g' -e 's/64/amd64/g'` binfilename=$(echo $1 | sed -e 's/ubuntu/liquidsoap/g' -e 's/debian/liquidsoap/g' -e 's/32/i386/g' -e 's/64/amd64/g')
rm -f /srv/chroot/$1/liquidsoap-compile.sh rm -f /srv/chroot/$1/liquidsoap-compile.sh
rm -f /srv/chroot/$1/liquidsoap rm -f /srv/chroot/$1/liquidsoap
cp liquidsoap-compile.sh /srv/chroot/$1/ cp liquidsoap-compile.sh /srv/chroot/$1/
schroot -c $1 -u root -d / -- /liquidsoap-compile.sh schroot -c $1 -u root -d / -- /liquidsoap-compile.sh
cp /srv/chroot/$1/liquidsoap ./$binfilename cp /srv/chroot/$1/liquidsoap ./$binfilename
if [ $? = 0 ];then if [ $? = 0 ]; then
echo "$binfilename is generated successfully" echo "$binfilename is generated successfully"
else else
mv ./liquidsoap-compile_logs/compile_liq_$1.log ./liquidsoap-compile_logs/fail_to_compile_liq_$1.log mv ./liquidsoap-compile_logs/compile_liq_$1.log ./liquidsoap-compile_logs/fail_to_compile_liq_$1.log
@ -96,34 +96,30 @@ flag=
os= os=
sudo_user="-1" sudo_user="-1"
if [ x$1 = x ];then if [ x$1 = x ]; then
showhelp showhelp
fi fi
while getopts b:c:u: arg while getopts b:c:u: arg; do
do
case $arg in case $arg in
b) b)
if [ "$OPTARG" = "all" ];then if [ "$OPTARG" = "all" ]; then
echo "Building all platforms on server..." echo "Building all platforms on server..."
for i in $(seq 0 $(($num -1))); for i in $(seq 0 $(($num - 1))); do
do
build_env ${os_versions[$i]} | tee ./liquidsoap-compile_logs/build_env_${os_versions[$i]}.log build_env ${os_versions[$i]} | tee ./liquidsoap-compile_logs/build_env_${os_versions[$i]}.log
done done
else else
flag=1 flag=1
for i in $(seq 0 $(($num -1))); for i in $(seq 0 $(($num - 1))); do
do if [ "$OPTARG" = ${os_versions[$i]} ]; then
if [ "$OPTARG" = ${os_versions[$i]} ];then
echo "Building platform: $OPTARG ..." echo "Building platform: $OPTARG ..."
build_env ${os_versions[$i]} | tee ./liquidsoap-compile_logs/build_env_${os_versions[$i]}.log build_env ${os_versions[$i]} | tee ./liquidsoap-compile_logs/build_env_${os_versions[$i]}.log
flag=0 flag=0
fi fi
done done
if [ $flag = 1 ];then if [ $flag = 1 ]; then
echo "Unsupported Platform from:" echo "Unsupported Platform from:"
for j in "${os_versions[@]}" for j in "${os_versions[@]}"; do
do
echo $j echo $j
done done
exit 1 exit 1
@ -131,27 +127,24 @@ do
fi fi
;; ;;
c) c)
if [ "$OPTARG" = "all" ];then if [ "$OPTARG" = "all" ]; then
echo "Compiling liquidsoap for all platforms on server..." echo "Compiling liquidsoap for all platforms on server..."
for i in $(seq 0 $(($num -1))) for i in $(seq 0 $(($num - 1))); do
do
compile_liq ${os_versions[$i]} | tee ./liquidsoap-compile_logs/compile_liq_${os_versions[$i]}.log compile_liq ${os_versions[$i]} | tee ./liquidsoap-compile_logs/compile_liq_${os_versions[$i]}.log
done done
else else
flag=1 flag=1
for i in $(seq 0 $(($num -1))); for i in $(seq 0 $(($num - 1))); do
do if [ "$OPTARG" = ${os_versions[$i]} ]; then
if [ "$OPTARG" = ${os_versions[$i]} ];then
echo "Compiling liquidsoap for platform: $OPTARG ..." echo "Compiling liquidsoap for platform: $OPTARG ..."
compile_liq ${os_versions[$i]} | tee ./liquidsoap-compile_logs/compile_liq_${os_versions[$i]}.log compile_liq ${os_versions[$i]} | tee ./liquidsoap-compile_logs/compile_liq_${os_versions[$i]}.log
flag=0 flag=0
fi fi
done done
if [ $flag = 1 ];then if [ $flag = 1 ]; then
echo "Unsupported Platform from:" echo "Unsupported Platform from:"
for k in "${os_versions[@]}" for k in "${os_versions[@]}"; do
do
echo $k echo $k
done done
exit 1 exit 1

View File

@ -10,7 +10,7 @@ baseurl="$1/updateAndBuild.action?buildKey="
# Moves to the 2nd param (first is URL) # Moves to the 2nd param (first is URL)
shift shift
# Loop for each build key # Loop for each build key
while (( "$#" )); do while (("$#")); do
# #
# Invoke the trigger # Invoke the trigger
@ -21,5 +21,4 @@ while (( "$#" )); do
shift shift
done done
exit 0 exit 0

View File

@ -1,11 +1,11 @@
#!/bin/bash -e #!/bin/bash -e
# Absolute path to this script # Absolute path to this script
SCRIPT=`readlink -f $0` SCRIPT=$(readlink -f $0)
# Absolute directory this script is in # Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=$(dirname $SCRIPT)
cd $SCRIPTPATH/../airtime_mvc/ cd $SCRIPTPATH/../airtime_mvc/
path=`pwd` path=$(pwd)
cd build cd build
sed -i s#"project\.home =.*$"#"project.home = $path"#g build.properties sed -i s:"project\.home =.*$":"project.home = $path":g build.properties
../../vendor/propel/propel1/generator/bin/propel-gen ../../vendor/propel/propel1/generator/bin/propel-gen

View File

@ -78,5 +78,4 @@ tar -czf $target_file \
echo " Done" echo " Done"
popd popd
echo "Output file available at $target_file" echo "Output file available at $target_file"

View File

@ -4,7 +4,7 @@ if [[ $EUID -ne 0 ]]; then
exit 1 exit 1
fi fi
usage () { usage() {
echo "Use --enable <user> or --disable flag. Enable is to set up environment" echo "Use --enable <user> or --disable flag. Enable is to set up environment"
echo "for specified user. --disable is to reset it back to pypo user" echo "for specified user. --disable is to reset it back to pypo user"
} }
@ -30,7 +30,6 @@ elif [ "$1" = "--disable" ]; then
chown -Rv $user:$user /var/tmp/airtime/pypo/ chown -Rv $user:$user /var/tmp/airtime/pypo/
chmod -v a+r /etc/airtime/api_client.cfg chmod -v a+r /etc/airtime/api_client.cfg
/etc/init.d/airtime-playout stop-liquidsoap /etc/init.d/airtime-playout stop-liquidsoap
/etc/init.d/airtime-playout start /etc/init.d/airtime-playout start
else else

128
install
View File

@ -8,10 +8,10 @@ if [[ $EUID -ne 0 ]]; then
exit 1 exit 1
fi fi
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "$0")" && pwd)"
AIRTIMEROOT=${SCRIPT_DIR} AIRTIMEROOT=${SCRIPT_DIR}
showhelp () { showhelp() {
echo "Usage: sudo bash install [options] echo "Usage: sudo bash install [options]
-h, --help, -? -h, --help, -?
Display usage information Display usage information
@ -57,12 +57,11 @@ showhelp () {
Skips all postgres related install tasks (Useful if you configure Skips all postgres related install tasks (Useful if you configure
postgresql as part of another script / docker builds) postgresql as part of another script / docker builds)
--no-rabbitmq --no-rabbitmq
Skips all rabbitmq related install tasks. Skips all rabbitmq related install tasks."
"
exit 0 exit 0
} }
showversion () { showversion() {
if [ ! -f "$SCRIPT_DIR/VERSION" ]; then if [ ! -f "$SCRIPT_DIR/VERSION" ]; then
echo "Please initialize LibreTime by running ./build.sh" echo "Please initialize LibreTime by running ./build.sh"
exit 1 exit 1
@ -121,7 +120,7 @@ function loudCmd() {
function checkCommandExists() { function checkCommandExists() {
set +e set +e
command=$@ command=$@
eval hash ${command} 2>/dev/null eval hash ${command} 2> /dev/null
commandFound=$? commandFound=$?
if [[ ! ${commandFound} -eq 0 ]]; then if [[ ! ${commandFound} -eq 0 ]]; then
echo -e "Error: ${command} not found. Please ensure you have the corresponding dependency installed." echo -e "Error: ${command} not found. Please ensure you have the corresponding dependency installed."
@ -151,15 +150,25 @@ function systemInitDetect() {
# Get package of PID=1 path as it identifies the init system. # Get package of PID=1 path as it identifies the init system.
# Allow this to fail, at least then the init system can be guessed from the # Allow this to fail, at least then the init system can be guessed from the
# PID 1 executable alone # PID 1 executable alone
pid_1_package=$(dpkg -S $pid_1_path 2>/dev/null || pid_1_package=$(dpkg -S $pid_1_path 2> /dev/null ||
rpm --qf '%{name}\n' -qf $pid_1_path 2>/dev/null || rpm --qf '%{name}\n' -qf $pid_1_path 2> /dev/null ||
echo "unknown") echo "unknown")
verbose "Detected package name for PID=1 process: $pid_1_package" verbose "Detected package name for PID=1 process: $pid_1_package"
case "${pid_1_package}:${pid_1_path}" in case "${pid_1_package}:${pid_1_path}" in
*systemd*) has_systemd_init=true; verbose "Detected init system type: systemd" ;; *systemd*)
*upstart*) has_upstart_init=true; verbose "Detected init system type: Upstart" ;; has_systemd_init=true
*sysvinit*) has_systemv_init=true; verbose "Detected init system type: System V" ;; verbose "Detected init system type: systemd"
*) echo "ERROR: Unable to detect init system using package or path of PID=1 process!" >&2 ;;
*upstart*)
has_upstart_init=true
verbose "Detected init system type: Upstart"
;;
*sysvinit*)
has_systemv_init=true
verbose "Detected init system type: System V"
;;
*)
echo "ERROR: Unable to detect init system using package or path of PID=1 process!" >&2
exit 1 exit 1
;; ;;
esac esac
@ -196,7 +205,7 @@ function systemInitInstall() {
target_path="/etc/systemd/system/${service_name}.service" target_path="/etc/systemd/system/${service_name}.service"
alt_path=$(echo $target_path | sed 's/libretime-/airtime-/') alt_path=$(echo $target_path | sed 's/libretime-/airtime-/')
;; ;;
libretime-liquidsoap|libretime-playout) libretime-liquidsoap | libretime-playout)
source_path="${python_source_path}/pypo/install/systemd/${service_name}.service" source_path="${python_source_path}/pypo/install/systemd/${service_name}.service"
target_path="/etc/systemd/system/${service_name}.service" target_path="/etc/systemd/system/${service_name}.service"
alt_path=$(echo $target_path | sed 's/libretime-/airtime-/') alt_path=$(echo $target_path | sed 's/libretime-/airtime-/')
@ -257,7 +266,7 @@ function systemInitInstall() {
target_path="/etc/init/${service_name}.conf" target_path="/etc/init/${service_name}.conf"
user="" user=""
;; ;;
libretime-liquidsoap|libretime-playout) libretime-liquidsoap | libretime-playout)
source_path="${python_source_path}/pypo/install/upstart/${service_name}.conf.template" source_path="${python_source_path}/pypo/install/upstart/${service_name}.conf.template"
target_path="/etc/init/${service_name}.conf" target_path="/etc/init/${service_name}.conf"
user=${user:-$web_user} user=${user:-$web_user}
@ -297,7 +306,7 @@ function systemInitInstall() {
target_config_path="/etc/default/${service_name}" target_config_path="/etc/default/${service_name}"
user="" user=""
;; ;;
libretime-liquidsoap|libretime-playout) libretime-liquidsoap | libretime-playout)
source_path="${python_source_path}/pypo/install/sysvinit/${service_name}" source_path="${python_source_path}/pypo/install/sysvinit/${service_name}"
target_path="/etc/init.d/${service_name}" target_path="/etc/init.d/${service_name}"
user=${user:-$web_user} user=${user:-$web_user}
@ -342,9 +351,10 @@ function systemInitInstall() {
# Where _command_ is one of: start, stop, status, reload, restart # Where _command_ is one of: start, stop, status, reload, restart
# enable, disable and either daemon-reload or reload-configuration. # enable, disable and either daemon-reload or reload-configuration.
function systemInitCommand() { function systemInitCommand() {
local command=$1; shift local command=$1
shift
case "$command" in case "$command" in
start|stop|status|reload|restart) start | stop | status | reload | restart)
if $has_systemd_init; then if $has_systemd_init; then
loudCmd "systemctl $command $@" loudCmd "systemctl $command $@"
elif $has_upstart_init; then elif $has_upstart_init; then
@ -357,23 +367,25 @@ function systemInitCommand() {
done done
fi fi
;; ;;
enable|disable) # TODO: REMOVE enable | disable) # TODO: REMOVE
$has_systemd_init && $has_systemd_init &&
loudCmd "systemctl $command $1.service" loudCmd "systemctl $command $1.service"
if $has_systemv_init; then if $has_systemv_init; then
if [[ "$command" = "enable" ]] if [[ "$command" = "enable" ]]; then
then loudCmd "update-rc.d $1 defaults" loudCmd "update-rc.d $1 defaults"
else loudCmd "update-rc.d $1 enable" else
loudCmd "update-rc.d $1 enable"
fi fi
fi fi
;; ;;
daemon-reload|reload-configuration) daemon-reload | reload-configuration)
$has_systemd_init && $has_systemd_init &&
loudCmd "systemctl daemon-reload" loudCmd "systemctl daemon-reload"
$has_upstart_init && $has_upstart_init &&
loudCmd "initctl reload-configuration" loudCmd "initctl reload-configuration"
;; ;;
*) echo -e "$0:${FUNCNAME}(): ERROR: command \"$command\" is not supported!" >&2 *)
echo -e "$0:${FUNCNAME}(): ERROR: command \"$command\" is not supported!" >&2
exit 1 exit 1
;; ;;
esac esac
@ -391,7 +403,7 @@ while :; do
--verbose) --verbose)
_v=1 _v=1
;; ;;
--quiet|--silent) --quiet | --silent)
_q=1 _q=1
;; ;;
--force) --force)
@ -507,7 +519,7 @@ while :; do
-?*) -?*)
for ((i = 1; i < ${#1}; i++)); do for ((i = 1; i < ${#1}; i++)); do
case "${1:$i:1}" in case "${1:$i:1}" in
h|\?) h | \?)
showhelp showhelp
;; ;;
V) V)
@ -556,14 +568,16 @@ while :; do
fi fi
;; ;;
*) *)
echo "$0: error - unrecognized option '${1:$i:1}'" >&2; echo "$0: error - unrecognized option '${1:$i:1}'" >&2
echo "Try 'install --help' for more information." echo "Try 'install --help' for more information."
exit 1 exit 1
;;
esac esac
done done
;; ;;
*) *)
break break
;;
esac esac
shift shift
done done
@ -606,9 +620,16 @@ if [ -n "$dist" ]; then
if [ "$dist" != "$ID" ]; then if [ "$dist" != "$ID" ]; then
verbose "Detected distribution \"$ID\" does not match specified one of \"$dist\". Checking ..." verbose "Detected distribution \"$ID\" does not match specified one of \"$dist\". Checking ..."
case "$dist" in case "$dist" in
centos|rhel) pkg_installer=/usr/bin/yum; verbose "Detected yum package installer" ;; centos | rhel)
debian|ubuntu) pkg_installer=/usr/bin/apt-get; verbose "Detected apt-get package installer" ;; pkg_installer=/usr/bin/yum
*) echo "ERROR: the value \"$dist\" specified for --distribution is unsupported." >&2 verbose "Detected yum package installer"
;;
debian | ubuntu)
pkg_installer=/usr/bin/apt-get
verbose "Detected apt-get package installer"
;;
*)
echo "ERROR: the value \"$dist\" specified for --distribution is unsupported." >&2
exit 1 exit 1
;; ;;
esac esac
@ -638,30 +659,30 @@ case "${dist}-${code}" in
is_ubuntu_dist=true is_ubuntu_dist=true
is_ubuntu_bionic=true is_ubuntu_bionic=true
;; ;;
ubuntu-16.04|ubuntu-xenial|ubuntu-xenial_docker_minimal) ubuntu-16.04 | ubuntu-xenial | ubuntu-xenial_docker_minimal)
echo -e "ERROR: Ubuntu Xenial is archived and does not receive any security or other updates since 2021-04-01." >&2 echo -e "ERROR: Ubuntu Xenial is archived and does not receive any security or other updates since 2021-04-01." >&2
echo -e "The LibreTime installer dropped support for installing LibreTime on Xenial in 3.0.0-alpha.10." >&2 echo -e "The LibreTime installer dropped support for installing LibreTime on Xenial in 3.0.0-alpha.10." >&2
exit 1 exit 1
;; ;;
debian-9|debian-stretch) debian-9 | debian-stretch)
echo -e "ERROR: Debian Stretch is archived and does not receive any security or other updates since 2020-06-06." >&2 echo -e "ERROR: Debian Stretch is archived and does not receive any security or other updates since 2020-06-06." >&2
echo -e "The LibreTime installer dropped support for installing LibreTime on Stretch in 3.0.0-alpha.10." >&2 echo -e "The LibreTime installer dropped support for installing LibreTime on Stretch in 3.0.0-alpha.10." >&2
exit 1 exit 1
;; ;;
debian-10|debian-buster) debian-10 | debian-buster)
code="buster" code="buster"
is_debian_dist=true is_debian_dist=true
is_debian_buster=true is_debian_buster=true
;; ;;
#Fix for Raspbian 9 (stretch) #Fix for Raspbian 9 (stretch)
raspbian-9|9) raspbian-9 | 9)
echo -e "ERROR: Raspbian Stretch is archived and does not receive any security or other updates since 2020-06-06." >&2 echo -e "ERROR: Raspbian Stretch is archived and does not receive any security or other updates since 2020-06-06." >&2
echo -e "The LibreTime installer dropped support for installing LibreTime on Stretch in 3.0.0-alpha.10." >&2 echo -e "The LibreTime installer dropped support for installing LibreTime on Stretch in 3.0.0-alpha.10." >&2
exit 1 exit 1
;; ;;
#End of fix #End of fix
#Fix for Raspbian 10 (buster) #Fix for Raspbian 10 (buster)
raspbian-10|10) raspbian-10 | 10)
code="buster" code="buster"
dist="debian" dist="debian"
is_debian_dist=true is_debian_dist=true
@ -669,7 +690,7 @@ case "${dist}-${code}" in
;; ;;
#End of fix #End of fix
debian-8|debian-jessie) debian-8 | debian-jessie)
echo -e "ERROR: Debian Jessie is archived and does not receive any security or other updates since 2018-05-17." >&2 echo -e "ERROR: Debian Jessie is archived and does not receive any security or other updates since 2018-05-17." >&2
echo -e "The LibreTime installer dropped support for installing LibreTime on Jessie in 3.0.0-alpha.8." >&2 echo -e "The LibreTime installer dropped support for installing LibreTime on Jessie in 3.0.0-alpha.8." >&2
exit 1 exit 1
@ -738,7 +759,7 @@ fi
# Check if composer exists and install if it doesn't # Check if composer exists and install if it doesn't
set +e set +e
eval hash "composer" 2>/dev/null eval hash "composer" 2> /dev/null
commandFound=$? commandFound=$?
set -e set -e
if [[ ! ${commandFound} -eq 0 ]]; then if [[ ! ${commandFound} -eq 0 ]]; then
@ -835,7 +856,7 @@ if [ "$apache" = "t" ]; then
loud " * Configuring Apache * " loud " * Configuring Apache * "
loud "-----------------------------------------------------" loud "-----------------------------------------------------"
# Detect Apache root folder, e.g. /etc/apache2 or /etc/httpd # Detect Apache root folder, e.g. /etc/apache2 or /etc/httpd
eval $($apache_bin -V |awk '/HTTPD_ROOT|SERVER_CONFIG_FILE/ { print $2 }') eval $($apache_bin -V | awk '/HTTPD_ROOT|SERVER_CONFIG_FILE/ { print $2 }')
apache_conf="${HTTPD_ROOT}/${SERVER_CONFIG_FILE}" apache_conf="${HTTPD_ROOT}/${SERVER_CONFIG_FILE}"
verbose "Detected Apache root folder is: ${HTTPD_ROOT}" verbose "Detected Apache root folder is: ${HTTPD_ROOT}"
if [[ ! -e $apache_conf ]]; then if [[ ! -e $apache_conf ]]; then
@ -855,7 +876,7 @@ if [ "$apache" = "t" ]; then
set +e set +e
# Parse: Server version: Apache/2.2.22 (Ubuntu) -> 2 # Parse: Server version: Apache/2.2.22 (Ubuntu) -> 2
apache_major_version=$($apache_bin -v |awk -F'[ /.]+' 'NR == 1 { print $4 }') apache_major_version=$($apache_bin -v | awk -F'[ /.]+' 'NR == 1 { print $4 }')
set -e set -e
if [[ "$apache_major_version" -ge 2 ]]; then if [[ "$apache_major_version" -ge 2 ]]; then
@ -929,7 +950,7 @@ if [ "$icecast" = "t" ]; then
systemInitCommand enable ${icecast_unit_name} systemInitCommand enable ${icecast_unit_name}
# only update icecast password if # only update icecast password if
if [ ! -e "/etc/airtime/airtime.conf" ] && [ ! -e "/etc/airtime/airtime.conf.tmp" ]; then if [ ! -e "/etc/airtime/airtime.conf" ] && [ ! -e "/etc/airtime/airtime.conf.tmp" ]; then
icecast_pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};) icecast_pass=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c${1:-12})
echo $icecast_pass > /tmp/icecast_pass echo $icecast_pass > /tmp/icecast_pass
loud "\n New install detected setting icecast password to random value." loud "\n New install detected setting icecast password to random value."
xmlstarlet ed --inplace -u /icecast/authentication/source-password -v $icecast_pass $icecast_config xmlstarlet ed --inplace -u /icecast/authentication/source-password -v $icecast_pass $icecast_config
@ -1075,18 +1096,18 @@ if [ $skip_postgres -eq 0 ]; then
setupAirtimePostgresUser() { setupAirtimePostgresUser() {
# here-doc to execute this block as postgres user # here-doc to execute this block as postgres user
su postgres <<'EOF' su postgres << 'EOF'
set +e set +e
count=$(psql -d postgres -tAc "SELECT count(*) FROM pg_roles WHERE rolname='airtime';") count=$(psql -d postgres -tAc "SELECT count(*) FROM pg_roles WHERE rolname='airtime';")
if [[ $count -eq 0 ]]; then if [[ $count -eq 0 ]]; then
psql -d postgres -tAc "CREATE USER airtime WITH ENCRYPTED PASSWORD 'airtime'; ALTER USER airtime CREATEDB;" psql -d postgres -tAc "CREATE USER airtime WITH ENCRYPTED PASSWORD 'airtime'; ALTER USER airtime CREATEDB;"
[[ $? -eq 0 ]] && [[ $? -eq 0 ]] &&
echo "Created airtime user in PostgreSQL" || echo "Created airtime user in PostgreSQL" ||
echo "$0:${FUNCNAME}(): ERROR: Can't create airtime user in PostgreSQL!" echo "$0:${FUNCNAME}(): ERROR: Can't create airtime user in PostgreSQL!"
else else
echo "airtime user already exists in PostgreSQL" echo "airtime user already exists in PostgreSQL"
fi fi
set -e set -e
# don't indent this! # don't indent this!
EOF EOF
} }
@ -1158,7 +1179,6 @@ if [ ! -d "/srv/airtime" ]; then
fi fi
chown -R ${web_user}:${web_user} /srv/airtime chown -R ${web_user}:${web_user} /srv/airtime
# We only generate the locales for Airtime if you're allowing us # We only generate the locales for Airtime if you're allowing us
# to install our dependencies, so that we won't automatically do this # to install our dependencies, so that we won't automatically do this
# when this install script runs from our DEB package. # when this install script runs from our DEB package.
@ -1172,7 +1192,7 @@ if [ "$ignore_dependencies" = "f" ]; then
else else
set +e set +e
verbose "\n * Generating locales" verbose "\n * Generating locales"
for i in `ls ${web_root}/../locale | grep ".._.."`; do for i in $(ls ${web_root}/../locale | grep ".._.."); do
if [ "$dist" = "debian" ]; then if [ "$dist" = "debian" ]; then
grep -qi "^$i" /etc/locale.gen grep -qi "^$i" /etc/locale.gen
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -1210,7 +1230,7 @@ if $is_centos_dist; then
else else
# not on centos # not on centos
ip_device="eth0" ip_device="eth0"
IP=$(ifconfig ${ip_device} 2>/dev/null |awk -F'[ :]+' '/inet addr:/ {print $4}') IP=$(ifconfig ${ip_device} 2> /dev/null | awk -F'[ :]+' '/inet addr:/ {print $4}')
fi fi
verbose "...Done" verbose "...Done"

View File

@ -52,9 +52,9 @@ echo "...Done"
IP=$(lxc-info -i -n ${name} -H) IP=$(lxc-info -i -n ${name} -H)
echo -e "\n * Opening ${name} in your browser..." echo -e "\n * Opening ${name} in your browser..."
if hash xdg-open 2>/dev/null; then if hash xdg-open 2> /dev/null; then
xdg-open "http://${IP}/" xdg-open "http://${IP}/"
elif hash gnome-open 2>/dev/null; then elif hash gnome-open 2> /dev/null; then
gnome-open "http://${IP}/" gnome-open "http://${IP}/"
fi fi
echo "...Done" echo "...Done"

View File

@ -58,7 +58,6 @@ su -l postgres bash -c 'createdb -O airtime airtime'
echo "ALTER USER airtime WITH PASSWORD 'airtime';" | su -l postgres bash -c psql echo "ALTER USER airtime WITH PASSWORD 'airtime';" | su -l postgres bash -c psql
echo "GRANT ALL PRIVILEGES ON DATABASE airtime TO airtime;" | su -l postgres bash -c psql echo "GRANT ALL PRIVILEGES ON DATABASE airtime TO airtime;" | su -l postgres bash -c psql
# RabbitMQ # RabbitMQ
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
yum install -y rabbitmq-server yum install -y rabbitmq-server
@ -142,7 +141,6 @@ sed -i \
-e 's/LoadModule mpm_event_module/#LoadModule mpm_event_module/' \ -e 's/LoadModule mpm_event_module/#LoadModule mpm_event_module/' \
/etc/httpd/conf.modules.d/00-mpm.conf /etc/httpd/conf.modules.d/00-mpm.conf
# celery will not run unless we install a specific version (https://github.com/pypa/setuptools/issues/942) # celery will not run unless we install a specific version (https://github.com/pypa/setuptools/issues/942)
# this will need to be figured out later on and will get overridden by the docs installer anyhow :( # this will need to be figured out later on and will get overridden by the docs installer anyhow :(
pip3 install setuptools==33.1.1 pip3 install setuptools==33.1.1

View File

@ -8,7 +8,6 @@
# #
# See http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts # See http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: celeryd # Provides: celeryd
# Required-Start: $network $local_fs $remote_fs # Required-Start: $network $local_fs $remote_fs
@ -126,8 +125,8 @@ export CELERY_LOADER
if [ -n "$2" ]; then if [ -n "$2" ]; then
CELERYD_OPTS="$CELERYD_OPTS $2" CELERYD_OPTS="$CELERYD_OPTS $2"
fi fi
CELERYD_LOG_DIR=`dirname $CELERYD_LOG_FILE` CELERYD_LOG_DIR=$(dirname $CELERYD_LOG_FILE)
CELERYD_PID_DIR=`dirname $CELERYD_PID_FILE` CELERYD_PID_DIR=$(dirname $CELERYD_PID_FILE)
# Extra start-stop-daemon options, like user/group. # Extra start-stop-daemon options, like user/group.
if [ -n "$CELERYD_CHDIR" ]; then if [ -n "$CELERYD_CHDIR" ]; then
DAEMON_OPTS="$DAEMON_OPTS --workdir=$CELERYD_CHDIR" DAEMON_OPTS="$DAEMON_OPTS --workdir=$CELERYD_CHDIR"
@ -177,7 +176,7 @@ create_paths() {
create_default_dir "$CELERYD_PID_DIR" create_default_dir "$CELERYD_PID_DIR"
} }
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
_get_pidfiles () { _get_pidfiles() {
# note: multi < 3.1.14 output to stderr, not stdout, hence the redirect. # note: multi < 3.1.14 output to stderr, not stdout, hence the redirect.
${CELERYD_MULTI} expand "${CELERYD_PID_FILE}" ${CELERYD_NODES} 2>&1 ${CELERYD_MULTI} expand "${CELERYD_PID_FILE}" ${CELERYD_NODES} 2>&1
} }
@ -185,8 +184,8 @@ _get_pids() {
found_pids=0 found_pids=0
my_exitcode=0 my_exitcode=0
for pidfile in $(_get_pidfiles); do for pidfile in $(_get_pidfiles); do
local pid=`cat "$pidfile"` local pid=$(cat "$pidfile")
local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` local cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g')
if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then
echo "bad pid file ($pidfile)" echo "bad pid file ($pidfile)"
one_failed=true one_failed=true
@ -201,10 +200,10 @@ _get_pids() {
fi fi
done done
} }
_chuid () { _chuid() {
su "$CELERYD_USER" -c "$CELERYD_MULTI $*" su "$CELERYD_USER" -c "$CELERYD_MULTI $*"
} }
start_workers () { start_workers() {
if [ ! -z "$CELERYD_ULIMIT" ]; then if [ ! -z "$CELERYD_ULIMIT" ]; then
ulimit $CELERYD_ULIMIT ulimit $CELERYD_ULIMIT
fi fi
@ -215,13 +214,13 @@ start_workers () {
$CELERY_APP_ARG \ $CELERY_APP_ARG \
$CELERYD_OPTS $CELERYD_OPTS
} }
dryrun () { dryrun() {
(C_FAKEFORK=1 start_workers --verbose) (C_FAKEFORK=1 start_workers --verbose)
} }
stop_workers () { stop_workers() {
_chuid stopwait $CELERYD_NODES --pidfile="$CELERYD_PID_FILE" _chuid stopwait $CELERYD_NODES --pidfile="$CELERYD_PID_FILE"
} }
restart_workers () { restart_workers() {
_chuid restart $CELERYD_NODES $DAEMON_OPTS \ _chuid restart $CELERYD_NODES $DAEMON_OPTS \
--pidfile="$CELERYD_PID_FILE" \ --pidfile="$CELERYD_PID_FILE" \
--logfile="$CELERYD_LOG_FILE" \ --logfile="$CELERYD_LOG_FILE" \
@ -232,11 +231,11 @@ restart_workers () {
kill_workers() { kill_workers() {
_chuid kill $CELERYD_NODES --pidfile="$CELERYD_PID_FILE" _chuid kill $CELERYD_NODES --pidfile="$CELERYD_PID_FILE"
} }
restart_workers_graceful () { restart_workers_graceful() {
echo "WARNING: Use with caution in production" echo "WARNING: Use with caution in production"
echo "The workers will attempt to restart, but they may not be able to." echo "The workers will attempt to restart, but they may not be able to."
local worker_pids= local worker_pids=
worker_pids=`_get_pids` worker_pids=$(_get_pids)
[ "$one_failed" ] && exit 1 [ "$one_failed" ] && exit 1
for worker_pid in $worker_pids; do for worker_pid in $worker_pids; do
local failed= local failed=
@ -250,7 +249,7 @@ restart_workers_graceful () {
done done
[ "$one_failed" ] && exit 1 || exit 0 [ "$one_failed" ] && exit 1 || exit 0
} }
check_status () { check_status() {
my_exitcode=0 my_exitcode=0
found_pids=0 found_pids=0
local one_failed= local one_failed=
@ -260,9 +259,9 @@ check_status () {
one_failed=true one_failed=true
break break
fi fi
local node=`basename "$pidfile" .pid` local node=$(basename "$pidfile" .pid)
local pid=`cat "$pidfile"` local pid=$(cat "$pidfile")
local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` local cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g')
if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then
echo "bad pid file ($pidfile)" echo "bad pid file ($pidfile)"
one_failed=true one_failed=true
@ -290,7 +289,7 @@ case "$1" in
check_paths check_paths
stop_workers stop_workers
;; ;;
reload|force-reload) reload | force-reload)
echo "Use restart" echo "Use restart"
;; ;;
status) status)

View File

@ -30,12 +30,12 @@ PIDFILE=/var/run/$NAME.pid
# and status_of_proc is working. # and status_of_proc is working.
. /lib/lsb/init-functions . /lib/lsb/init-functions
start () { start() {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \ start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON --make-pidfile --pidfile $PIDFILE --startas $DAEMON
} }
stop () { stop() {
# Send TERM after 5 seconds, wait at most 30 seconds. # Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE rm -f $PIDFILE

View File

@ -19,10 +19,9 @@ post_file() {
airtime_conf_path=/etc/airtime/airtime.conf airtime_conf_path=/etc/airtime/airtime.conf
#instance_path will look like 1/1384, for example #instance_path will look like 1/1384, for example
http_path=$(grep base_url ${airtime_conf_path} | awk '{print $3;}' ) http_path=$(grep base_url ${airtime_conf_path} | awk '{print $3;}')
http_port=$(grep base_port ${airtime_conf_path} | awk '{print $3;}' ) http_port=$(grep base_port ${airtime_conf_path} | awk '{print $3;}')
#post request url - http://bananas.airtime.pro/rest/media, for example #post request url - http://bananas.airtime.pro/rest/media, for example
url=http:// url=http://
@ -31,14 +30,12 @@ post_file() {
url+=$http_port url+=$http_port
url+=/rest/media url+=/rest/media
api_key=$(grep api_key ${airtime_conf_path} | awk '{print $3;}')
api_key=$(grep api_key ${airtime_conf_path} | awk '{print $3;}' )
# -f is needed to make curl fail if there's an HTTP error code # -f is needed to make curl fail if there's an HTTP error code
# -L is needed to follow redirects! (just in case) # -L is needed to follow redirects! (just in case)
until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}"; do
do retry_count=$(($retry_count + 1))
retry_count=$[$retry_count+1]
if [ $retry_count -ge $max_retry ]; then if [ $retry_count -ge $max_retry ]; then
break break
fi fi

View File

@ -8,9 +8,8 @@ post_file() {
max_retry=10 max_retry=10
retry_count=0 retry_count=0
until curl --max-time 30 http://localhost/rest/media -u 3188BDIMPJROQP89Z0OX: -X POST -F "file=@${file_path}" -F "name=${filename}" until curl --max-time 30 http://localhost/rest/media -u 3188BDIMPJROQP89Z0OX: -X POST -F "file=@${file_path}" -F "name=${filename}"; do
do retry_count=$(($retry_count + 1))
retry_count=$[$retry_count+1]
if [ $retry_count -ge $max_retry ]; then if [ $retry_count -ge $max_retry ]; then
break break
fi fi

View File

@ -30,12 +30,12 @@ PIDFILE=/var/run/$NAME.pid
# and status_of_proc is working. # and status_of_proc is working.
. /lib/lsb/init-functions . /lib/lsb/init-functions
start () { start() {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \ start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON --make-pidfile --pidfile $PIDFILE --startas $DAEMON
} }
stop () { stop() {
# Send TERM after 5 seconds, wait at most 30 seconds. # Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE rm -f $PIDFILE

View File

@ -30,12 +30,12 @@ PIDFILE=/var/run/$NAME.pid
# and status_of_proc is working. # and status_of_proc is working.
. /lib/lsb/init-functions . /lib/lsb/init-functions
start () { start() {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \ start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON --make-pidfile --pidfile $PIDFILE --startas $DAEMON
} }
stop () { stop() {
# Send TERM after 5 seconds, wait at most 30 seconds. # Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE rm -f $PIDFILE

View File

@ -8,25 +8,18 @@ if [[ $EUID -ne 0 ]]; then
fi fi
getStorDirFromDatabase() { getStorDirFromDatabase() {
# here-doc to execute this block as postgres user echo $(sudo -u postgres psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'")
result=`su postgres <<'EOF'
set +e
echo $(psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'")
set -e
# don't indent this!
EOF`
echo $result
} }
dropLibreTimeDatabase() { dropLibreTimeDatabase() {
# here-doc to execute this block as postgres user # here-doc to execute this block as postgres user
su postgres <<'EOF' su postgres << 'EOF'
set +e set +e
# DROP DATABASE cannot be executed from a function or multi-command string # DROP DATABASE cannot be executed from a function or multi-command string
psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime_test" psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime_test"
psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime" psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime"
psql -d postgres -tAc "DROP USER IF EXISTS airtime" psql -d postgres -tAc "DROP USER IF EXISTS airtime"
set -e set -e
# don't indent this! # don't indent this!
EOF EOF
} }
@ -44,7 +37,7 @@ removeRabbitmqLibreTimeSettings() {
rabbitmqctl delete_user ${RMQ_USER} rabbitmqctl delete_user ${RMQ_USER}
} }
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "$0")" && pwd)"
AIRTIMEROOT=${SCRIPT_DIR} AIRTIMEROOT=${SCRIPT_DIR}
STOR_DIR=$(getStorDirFromDatabase) STOR_DIR=$(getStorDirFromDatabase)
@ -60,7 +53,7 @@ FILES=(
"/usr/bin/airtime*" "/usr/bin/airtime*"
"/etc/apache2/sites-available/airtime*" "/etc/apache2/sites-available/airtime*"
"/etc/apache2/sites-enabled/airtime*" "/etc/apache2/sites-enabled/airtime*"
) )
echo -e "The following files, directories, and services will be removed:\n" echo -e "The following files, directories, and services will be removed:\n"
for i in ${FILES[*]}; do for i in ${FILES[*]}; do
@ -73,14 +66,14 @@ echo -e "\nIf your web root is not listed, you will need to manually remove it."
echo -e "\nThis will *permanently* remove LibreTime and all related files from your computer. \ echo -e "\nThis will *permanently* remove LibreTime and all related files from your computer. \
Any files in LibreTime directories and subdirectories will be deleted. Are you sure you want to proceed? [y/N]: \c" Any files in LibreTime directories and subdirectories will be deleted. Are you sure you want to proceed? [y/N]: \c"
read IN read IN
if [[ ! ( "$IN" = "y" || "$IN" = "Y" ) ]]; then if [[ ! ("$IN" = "y" || "$IN" = "Y") ]]; then
exit 0 exit 0
fi fi
if [ -n "${STOR_DIR}" ]; then if [ -n "${STOR_DIR}" ]; then
echo -e "\nDo you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? [y/N]: \c" echo -e "\nDo you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? [y/N]: \c"
read IN read IN
if [[ ( "$IN" = "y" || "$IN" = "Y" ) ]]; then if [[ ("$IN" = "y" || "$IN" = "Y") ]]; then
rm -rf "${STOR_DIR}" rm -rf "${STOR_DIR}"
fi fi
else else

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Absolute path to this script # Absolute path to this script
SCRIPT=`readlink -f $0` SCRIPT=$(readlink -f $0)
# Absolute directory this script is in # Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=$(dirname $SCRIPT)
php -q $SCRIPTPATH/airtime-log.php "$@" || exit 1 php -q $SCRIPTPATH/airtime-log.php "$@" || exit 1

View File

@ -24,9 +24,9 @@
# This script send data to data collection server # This script send data to data collection server
# #
# Absolute path to this script # Absolute path to this script
SCRIPT=`readlink -f $0` SCRIPT=$(readlink -f $0)
# Absolute directory this script is in # Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=$(dirname $SCRIPT)
cd $SCRIPTPATH cd $SCRIPTPATH

View File

@ -24,9 +24,9 @@
# This script send data to data collection server # This script send data to data collection server
# #
# Absolute path to this script # Absolute path to this script
SCRIPT=`readlink -f $0` SCRIPT=$(readlink -f $0)
# Absolute directory this script is in # Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=$(dirname $SCRIPT)
cd $SCRIPTPATH cd $SCRIPTPATH

View File

@ -1,21 +1,19 @@
#!/bin/bash #!/bin/bash
if [ -z "$1" ] if [ -z "$1" ]; then
then
## Use config ## Use config
backup_folder=~/libretime_backup/ backup_folder=~/libretime_backup/
else else
## User arg as config ## User arg as config
backup_folder=$1 backup_folder=$1
fi fi
airtime_conf_path=/etc/airtime/airtime.conf airtime_conf_path=/etc/airtime/airtime.conf
uploads_folder=/srv/airtime/stor/ uploads_folder=/srv/airtime/stor/
psdl_db=$(grep dbname ${airtime_conf_path} | awk '{print $3;}' ) psdl_db=$(grep dbname ${airtime_conf_path} | awk '{print $3;}')
psql_user=$(grep dbuser ${airtime_conf_path} | awk '{print $3;}' ) psql_user=$(grep dbuser ${airtime_conf_path} | awk '{print $3;}')
psql_password=$(grep dbpass ${airtime_conf_path} | awk '{print $3;}' ) psql_password=$(grep dbpass ${airtime_conf_path} | awk '{print $3;}')
## Remove old backup ## Remove old backup
rm -rf $backup_folder rm -rf $backup_folder

View File

@ -5,10 +5,10 @@ pid_found="$?"
if [ "$pid_found" == "0" ]; then if [ "$pid_found" == "0" ]; then
#PID is available in the status message #PID is available in the status message
rabbitmqpid=`/etc/init.d/rabbitmq-server status | grep "\[{pid" | sed "s/.*,\(.*\)\}.*/\1/"` rabbitmqpid=$(/etc/init.d/rabbitmq-server status | grep "\[{pid" | sed "s/.*,\(.*\)\}.*/\1/")
else else
#PID should be available from file #PID should be available from file
rabbitmqpid=`sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids` rabbitmqpid=$(sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids)
fi fi
echo "RabbitMQ PID: $rabbitmqpid" echo "RabbitMQ PID: $rabbitmqpid"

View File

@ -7,7 +7,6 @@
# 1 - Rivendell store files in .wav format, airtime uses .mp3 format # 1 - Rivendell store files in .wav format, airtime uses .mp3 format
# 2 - WAV does not have Meta-tag support so all meta-tags need to be fetched from Rivendell database. # 2 - WAV does not have Meta-tag support so all meta-tags need to be fetched from Rivendell database.
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo "usage: $0 <rivendell_dir> <final_dir>" echo "usage: $0 <rivendell_dir> <final_dir>"
exit exit
@ -24,21 +23,19 @@ end_dir=$2
cd "$rivendell_dir" cd "$rivendell_dir"
for file in * for file in *; do
do
lame "$file" lame "$file"
done done
mv "$rivendell_dir"/*.mp3 "$end_dir" mv "$rivendell_dir"/*.mp3 "$end_dir"
cd "$end_dir" cd "$end_dir"
for file in * for file in *; do
do id=$(echo $file | head -c 10)
id=`echo $file | head -c 10` title=$(mysql -u $user -p$pass -sN -e "SELECT CU.DESCRIPTION FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db)
title=`mysql -u $user -p$pass -sN -e "SELECT CU.DESCRIPTION FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db` artist=$(mysql -u $user -p$pass -sN -e "SELECT CA.ARTIST FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db)
artist=`mysql -u $user -p$pass -sN -e "SELECT CA.ARTIST FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db` album=$(mysql -u $user -p$pass -sN -e "SELECT CA.ALBUM FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db)
album=`mysql -u $user -p$pass -sN -e "SELECT CA.ALBUM FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db` year=$(mysql -u $user -p$pass -sN -e "SELECT CA.YEAR FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db)
year=`mysql -u $user -p$pass -sN -e "SELECT CA.YEAR FROM CUTS CU, CART CA WHERE CA.NUMBER=CU.CART_NUMBER AND CU.CUT_NAME=\"${id}\"" $db`
id3 -t "$title" -a "$artist" -A "$album" -y "$year" $file id3 -t "$title" -a "$artist" -A "$album" -y "$year" $file
mv "$file" "$artist-$title.mp3" mv "$file" "$artist-$title.mp3"
done done