Fix shellcheck errors

This commit is contained in:
jo 2021-08-16 17:44:19 +02:00
parent b5f302ac61
commit dc999f9006
15 changed files with 108 additions and 98 deletions

View File

@ -25,5 +25,5 @@ apt-get install -y gstreamer1.0-plugins-base \
libcairo2-dev libcairo2-dev
# Making log directory for PHP tests # Making log directory for PHP tests
mkdir -p $LIBRETIME_LOG_DIR mkdir -p "$LIBRETIME_LOG_DIR"
chown runner:runner $LIBRETIME_LOG_DIR chown runner:runner "$LIBRETIME_LOG_DIR"

View File

@ -25,5 +25,5 @@ apt-get install -y gstreamer1.0-plugins-base \
libcairo2-dev libcairo2-dev
# Making log directory for PHP tests # Making log directory for PHP tests
mkdir -p $LIBRETIME_LOG_DIR mkdir -p "$LIBRETIME_LOG_DIR"
chown runner:runner $LIBRETIME_LOG_DIR chown runner:runner "$LIBRETIME_LOG_DIR"

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "::group::Install Python apps" echo "::group::Install Python apps"
for app in $(ls python_apps); do for app in python_apps/*; do
if [[ -f "python_apps/$app/requirements-dev.txt" ]]; then if [[ -f "python_apps/$app/requirements-dev.txt" ]]; then
pip3 install -r "python_apps/$app/requirements-dev.txt" pip3 install -r "python_apps/$app/requirements-dev.txt"
fi fi

View File

@ -14,7 +14,7 @@ if ! make -C python_apps/api_clients test; then
fi fi
echo "::endgroup::" echo "::endgroup::"
if [[ "$failed" = "true" ]]; then if [[ $failed == "true" ]]; then
echo "Python tests failed" echo "Python tests failed"
exit 1 exit 1
fi fi

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
set -e # Exit if any of the steps fails.
composer install --no-dev --no-interaction composer install --no-dev --no-interaction
git_build="" git_build=""
@ -14,7 +17,7 @@ if [ "${git_build}" = "y" ]; 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
else else
# if no file was in tarball we create one letting the user know # if no file was in tarball we create one letting the user know
# if you run in to this you should grab an enriched tarball built # if you run in to this you should grab an enriched tarball built

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
set -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)

View File

@ -105,12 +105,12 @@ while getopts b:c:u: arg; do
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))); do for i in $(seq 0 $((num - 1))); 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))); do for i in $(seq 0 $((num - 1))); 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
@ -129,13 +129,13 @@ while getopts b:c:u: arg; do
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))); do for i in $(seq 0 $((num - 1))); 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))); do for i in $(seq 0 $((num - 1))); 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

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
set -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

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
set -e
#release.sh 1.8.2 #release.sh 1.8.2
#creates a libretime folder with a "1.8.2" suffix #creates a libretime folder with a "1.8.2" suffix

109
install
View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
#-e Causes bash script to exit if any of the installers set -e # Exit if any of the steps fails.
#return with a non-zero return value.
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "Please run as root user." echo "Please run as root user."
@ -111,16 +110,16 @@ function loud() {
function loudCmd() { function loudCmd() {
if [[ ${_q} -eq 0 ]]; then if [[ ${_q} -eq 0 ]]; then
verbose "$@" verbose "$@"
eval $@ eval "$@"
else else
eval $@ > /dev/null eval "$@" > /dev/null
fi fi
} }
function checkCommandExists() { function checkCommandExists() {
set +e set +e
command=$@ command="$1"
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."
@ -150,8 +149,8 @@ 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
@ -185,6 +184,7 @@ function systemInitDetect() {
function systemInitInstall() { function systemInitInstall() {
local service_name="$1" local service_name="$1"
local user="$2" local user="$2"
# shellcheck disable=SC2034
local source_base_path="" local source_base_path=""
local source_path="" local source_path=""
local target_path="" local target_path=""
@ -198,26 +198,26 @@ function systemInitInstall() {
libretime-analyzer) libretime-analyzer)
source_path="${python_source_path}/airtime_analyzer/install/systemd/${service_name}.service" source_path="${python_source_path}/airtime_analyzer/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="${target_path//libretime-/airtime_}"
;; ;;
libretime-celery) libretime-celery)
source_path="${python_source_path}/airtime-celery/install/systemd/${service_name}.service" source_path="${python_source_path}/airtime-celery/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="${target_path//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="${target_path//libretime-/airtime-}"
;; ;;
libretime-api) libretime-api)
source_path="${SCRIPT_DIR-$PWD}/api/install/systemd/${service_name}.service" source_path="${SCRIPT_DIR-$PWD}/api/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="${target_path//libretime-/airtime-}"
;; ;;
esac esac
if [[ ! -e $source_path ]]; then if [[ ! -e $source_path ]]; then
echo "$0:${FUNCNAME}(): ERROR: service \"$service_name\" with source path \"$source_path\" does not exist!" >&2 echo "$0:${FUNCNAME[0]}(): ERROR: service \"$service_name\" with source path \"$source_path\" does not exist!" >&2
exit 1 exit 1
fi fi
# Stop and disable the service if it already exists # Stop and disable the service if it already exists
@ -229,7 +229,8 @@ function systemInitInstall() {
local old_style_unit_exists="f" local old_style_unit_exists="f"
# Migrate old style airtime unit exist if it exists # Migrate old style airtime unit exist if it exists
if [[ -e $alt_path && ! -L $alt_path ]]; then if [[ -e $alt_path && ! -L $alt_path ]]; then
local old_service=$(echo $service_name | sed 's/libretime/airtime/' | sed 's/-analyzer/_analyzer/') local old_service
old_service=$(echo "$service_name" | sed 's/libretime/airtime/' | sed 's/-analyzer/_analyzer/')
verbose "Old service $old_service already exists - migrating." verbose "Old service $old_service already exists - migrating."
loudCmd "systemctl disable ${old_service}.service" loudCmd "systemctl disable ${old_service}.service"
loudCmd "systemctl stop ${old_service}.service" loudCmd "systemctl stop ${old_service}.service"
@ -241,15 +242,15 @@ function systemInitInstall() {
loudCmd "cp $source_path $target_path" loudCmd "cp $source_path $target_path"
else else
sed -e "s/User=.*/User=${user}/" \ sed -e "s/User=.*/User=${user}/" \
-e "s/Group=.*/Group=${user}/" $source_path > $target_path -e "s/Group=.*/Group=${user}/" "$source_path" > "$target_path"
fi fi
if [[ $old_style_unit_exists == "t" ]]; then if [[ $old_style_unit_exists == "t" ]]; then
verbose "Maintaining compatibility with old systemd unit names" verbose "Maintaining compatibility with old systemd unit names"
# Alias to old Airtime names # Alias to old Airtime names
loudCmd "ln -s $source_path $alt_path" loudCmd "ln -s $source_path $alt_path"
fi fi
chmod 0644 $target_path chmod 0644 "$target_path"
chown root:root $target_path chown root:root "$target_path"
verbose "Service ${service_name} installed into ${target_path}" verbose "Service ${service_name} installed into ${target_path}"
# Enable and start the service # Enable and start the service
loudCmd "systemctl enable ${service_name}.service" loudCmd "systemctl enable ${service_name}.service"
@ -273,7 +274,7 @@ function systemInitInstall() {
;; ;;
esac esac
if [[ ! -e $source_path ]]; then if [[ ! -e $source_path ]]; then
echo "$0:${FUNCNAME}(): ERROR: service \"$service_name\" with source path \"$source_path\" does not exist!" >&2 echo "$0:${FUNCNAME[0]}(): ERROR: service \"$service_name\" with source path \"$source_path\" does not exist!" >&2
exit 1 exit 1
fi fi
# Stop the service if it already exists # Stop the service if it already exists
@ -286,10 +287,10 @@ function systemInitInstall() {
loudCmd "cp $source_path $target_path" loudCmd "cp $source_path $target_path"
else else
sed -e "s/WEB_USER/${user}/g" \ sed -e "s/WEB_USER/${user}/g" \
-e "/^set[gu]id/{s/www-data/${user}/}" $source_path > $target_path -e "/^set[gu]id/{s/www-data/${user}/}" "$source_path" > "$target_path"
fi fi
chmod 0644 $target_path chmod 0644 "$target_path"
chown root:root $target_path chown root:root "$target_path"
verbose "Service ${service_name} installed into ${target_path}" verbose "Service ${service_name} installed into ${target_path}"
loudCmd "initctl check-config $service_name" loudCmd "initctl check-config $service_name"
elif $has_systemv_init; then elif $has_systemv_init; then
@ -313,7 +314,7 @@ function systemInitInstall() {
;; ;;
esac esac
if [[ ! -e $source_path ]]; then if [[ ! -e $source_path ]]; then
echo "$0:${FUNCNAME}(): ERROR: service \"$service_name\" with source path \"$source_path\" does not exist!" >&2 echo "$0:${FUNCNAME[0]}(): ERROR: service \"$service_name\" with source path \"$source_path\" does not exist!" >&2
exit 1 exit 1
fi fi
# Stop the service if it already exists # Stop the service if it already exists
@ -328,13 +329,13 @@ function systemInitInstall() {
loudCmd "cp $source_config_path $target_config_path" loudCmd "cp $source_config_path $target_config_path"
else else
sed -e "/^USERID/{s/www-data/${user}/}" \ sed -e "/^USERID/{s/www-data/${user}/}" \
-e "/^GROUPID/{s/www-data/${user}/}" $source_path > $target_path -e "/^GROUPID/{s/www-data/${user}/}" "$source_path" > "$target_path"
fi fi
chmod 0644 $target_path chmod 0644 "$target_path"
chown root:root $target_path chown root:root "$target_path"
if [[ -n $target_config_path ]]; then if [[ -n $target_config_path ]]; then
chmod 0644 $target_config_path chmod 0644 "$target_config_path"
chown root:root $target_config_path chown root:root "$target_config_path"
fi fi
verbose "Service ${service_name} installed into ${target_path}" verbose "Service ${service_name} installed into ${target_path}"
# Create symlinks for the appropriate runlevels # Create symlinks for the appropriate runlevels
@ -356,13 +357,13 @@ function systemInitCommand() {
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
for svc_name in $@; do for svc_name in "$@"; do
loudCmd "service $svc_name $command" loudCmd "service $svc_name $command"
done done
elif $has_systemv_init; then elif $has_systemv_init; then
for svc_name in $@; do for svc_name in "$@"; do
loudCmd "invoke-rc.d $svc_name $command" loudCmd "invoke-rc.d $svc_name $command"
done done
fi fi
@ -371,7 +372,7 @@ function systemInitCommand() {
$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" ]]; then if [[ "$command" == "enable" ]]; then
loudCmd "update-rc.d $1 defaults" loudCmd "update-rc.d $1 defaults"
else else
loudCmd "update-rc.d $1 enable" loudCmd "update-rc.d $1 enable"
@ -385,7 +386,7 @@ function systemInitCommand() {
loudCmd "initctl reload-configuration" loudCmd "initctl reload-configuration"
;; ;;
*) *)
echo -e "$0:${FUNCNAME}(): ERROR: command \"$command\" is not supported!" >&2 echo -e "$0:${FUNCNAME[0]}(): ERROR: command \"$command\" is not supported!" >&2
exit 1 exit 1
;; ;;
esac esac
@ -477,7 +478,7 @@ while :; do
;; ;;
--web-root) --web-root)
if [ "$2" ]; then if [ "$2" ]; then
web_root=$(readlink -f $2) web_root=$(readlink -f "$2")
shift 2 shift 2
continue continue
else else
@ -568,7 +569,7 @@ 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
;; ;;
@ -582,7 +583,7 @@ while :; do
shift shift
done done
if [ -z web_root -a ! -d web_root ]; then if [[ -z $web_root || ! -d $web_root ]]; then
echo "$web_root doesn't exist!" echo "$web_root doesn't exist!"
exit 1 exit 1
fi fi
@ -596,6 +597,7 @@ echo -e " \/ \/ \/ \/ \/\n"
echo -e "Detecting distribution and release ..." echo -e "Detecting distribution and release ..."
if [ -e /etc/os-release ]; then if [ -e /etc/os-release ]; then
# Access $ID, $VERSION_ID and $PRETTY_NAME # Access $ID, $VERSION_ID and $PRETTY_NAME
# shellcheck disable=SC1091
source /etc/os-release source /etc/os-release
echo "Detected distribution id: $ID" echo "Detected distribution id: $ID"
echo "Detected distribution release id: $VERSION_ID" echo "Detected distribution release id: $VERSION_ID"
@ -605,7 +607,7 @@ else
VERSION_ID=unknown VERSION_ID=unknown
PRETTY_NAME="Unknown distribution and release" PRETTY_NAME="Unknown distribution and release"
echo "WARNING: /etc/os-release configuration not found. Unable to detect distribution." >&2 echo "WARNING: /etc/os-release configuration not found. Unable to detect distribution." >&2
if [ -z "$dist" -o -z "$code" ]; then if [[ -z $dist || -z $code ]]; then
echo "ERROR: One or both of --distribution and --release options were not specified." >&2 echo "ERROR: One or both of --distribution and --release options were not specified." >&2
echo "This is an unsupported distribution and/or version!" >&2 echo "This is an unsupported distribution and/or version!" >&2
exit 1 exit 1
@ -646,6 +648,7 @@ is_debian_buster=false
is_ubuntu_dist=false is_ubuntu_dist=false
is_ubuntu_bionic=false is_ubuntu_bionic=false
is_centos_dist=false is_centos_dist=false
# shellcheck disable=SC2034
is_centos_7=false is_centos_7=false
is_centos_8=false is_centos_8=false
# Use specified distribution and release or detected otherwise. # Use specified distribution and release or detected otherwise.
@ -685,6 +688,7 @@ case "${dist}-${code}" in
raspbian-10 | 10) raspbian-10 | 10)
code="buster" code="buster"
dist="debian" dist="debian"
# shellcheck disable=SC2034
is_debian_dist=true is_debian_dist=true
is_debian_buster=true is_debian_buster=true
;; ;;
@ -697,6 +701,7 @@ case "${dist}-${code}" in
;; ;;
centos-8) centos-8)
is_centos_dist=true is_centos_dist=true
# shellcheck disable=SC2034
is_centos_8=true is_centos_8=true
;; ;;
*) *)
@ -926,9 +931,9 @@ fi
if [ "$icecast" = "f" -a ${_i} -eq 1 ]; then if [ "$icecast" = "f" -a ${_i} -eq 1 ]; then
echo -e "Install default Airtime Icecast configuration? (Y/n): \c" echo -e "Install default Airtime Icecast configuration? (Y/n): \c"
read IN read -r IN
IN=${IN:-$default_value} IN=${IN:-$default_value}
if [ "$IN" = "y" -o "$IN" = "Y" ]; then if [[ $IN == "y" || $IN == "Y" ]]; then
icecast="t" icecast="t"
fi fi
fi fi
@ -947,15 +952,15 @@ if [ "$icecast" = "t" ]; then
icecast_unit_name="icecast" icecast_unit_name="icecast"
icecast_config="/etc/icecast.xml" icecast_config="/etc/icecast.xml"
fi fi
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=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | 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"
xmlstarlet ed --inplace -u /icecast/authentication/relay-password -v $icecast_pass $icecast_config xmlstarlet ed --inplace -u /icecast/authentication/relay-password -v "$icecast_pass" "$icecast_config"
xmlstarlet ed --inplace -u /icecast/authentication/admin-password -v $icecast_pass $icecast_config xmlstarlet ed --inplace -u /icecast/authentication/admin-password -v "$icecast_pass" "$icecast_config"
fi fi
# restart in case icecast was already started (like is the case on debian) # restart in case icecast was already started (like is the case on debian)
systemInitCommand restart ${icecast_unit_name} systemInitCommand restart ${icecast_unit_name}
@ -979,7 +984,7 @@ verbose "...Done"
verbose "\n * Creating /run/airtime..." verbose "\n * Creating /run/airtime..."
mkdir -p /run/airtime mkdir -p /run/airtime
chmod 755 /run/airtime chmod 755 /run/airtime
chown -R ${web_user}:${web_user} /run/airtime chown -R "${web_user}:${web_user}" /run/airtime
verbose "...Done" verbose "...Done"
if [ ! -d /var/log/airtime ]; then if [ ! -d /var/log/airtime ]; then
@ -1003,8 +1008,8 @@ verbose "\n * Installing pypo and liquidsoap..."
loudCmd "$python_bin ${AIRTIMEROOT}/python_apps/pypo/setup.py install --install-scripts=/usr/bin --no-init-script" loudCmd "$python_bin ${AIRTIMEROOT}/python_apps/pypo/setup.py install --install-scripts=/usr/bin --no-init-script"
loudCmd "mkdir -p /var/log/airtime/{pypo,pypo-liquidsoap} /var/tmp/airtime/pypo/{cache,files,tmp} /var/tmp/airtime/show-recorder/" loudCmd "mkdir -p /var/log/airtime/{pypo,pypo-liquidsoap} /var/tmp/airtime/pypo/{cache,files,tmp} /var/tmp/airtime/show-recorder/"
loudCmd "chown -R ${web_user}:${web_user} /var/log/airtime/{pypo,pypo-liquidsoap} /var/tmp/airtime/pypo/{cache,files,tmp} /var/tmp/airtime/show-recorder/" loudCmd "chown -R ${web_user}:${web_user} /var/log/airtime/{pypo,pypo-liquidsoap} /var/tmp/airtime/pypo/{cache,files,tmp} /var/tmp/airtime/show-recorder/"
systemInitInstall libretime-liquidsoap $web_user systemInitInstall libretime-liquidsoap "$web_user"
systemInitInstall libretime-playout $web_user systemInitInstall libretime-playout "$web_user"
verbose "...Done" verbose "...Done"
verbose "\n * Installing airtime-celery..." verbose "\n * Installing airtime-celery..."
@ -1025,16 +1030,16 @@ verbose "...Done"
verbose "\n * Installing libretime-analyzer..." verbose "\n * Installing libretime-analyzer..."
loudCmd "$python_bin ${AIRTIMEROOT}/python_apps/airtime_analyzer/setup.py install --install-scripts=/usr/bin" loudCmd "$python_bin ${AIRTIMEROOT}/python_apps/airtime_analyzer/setup.py install --install-scripts=/usr/bin"
systemInitInstall libretime-analyzer $web_user systemInitInstall libretime-analyzer "$web_user"
verbose "...Done" verbose "...Done"
verbose "\n * Installing API..." verbose "\n * Installing API..."
loudCmd "python3 ${AIRTIMEROOT}/api/setup.py install --install-scripts=/usr/bin" loudCmd "python3 ${AIRTIMEROOT}/api/setup.py install --install-scripts=/usr/bin"
systemInitInstall libretime-api $web_user systemInitInstall libretime-api "$web_user"
mkdir -p /etc/airtime mkdir -p /etc/airtime
sed -e "s@WEB_USER@${web_user}@g" \ sed -e "s@WEB_USER@${web_user}@g" \
-e "s@WEB_ROOT@${web_root}@g" \ -e "s@WEB_ROOT@${web_root}@g" \
${AIRTIMEROOT}/installer/uwsgi/libretime-api.ini > /etc/airtime/libretime-api.ini "${AIRTIMEROOT}/installer/uwsgi/libretime-api.ini" > /etc/airtime/libretime-api.ini
loudCmd "libretime-api collectstatic --clear --noinput" loudCmd "libretime-api collectstatic --clear --noinput"
verbose "...Done" verbose "...Done"
@ -1058,7 +1063,7 @@ php_conf_dirs=(
"/etc/php5/apache2/conf.d" # Debian Stretch, Debian Jessie, Ubuntu Trusty "/etc/php5/apache2/conf.d" # Debian Stretch, Debian Jessie, Ubuntu Trusty
"/etc/php.d" # CentOS 7 "/etc/php.d" # CentOS 7
) )
for php_conf in ${php_conf_dirs[@]}; do for php_conf in "${php_conf_dirs[@]}"; do
[[ -d $php_conf ]] && break [[ -d $php_conf ]] && break
done done
if [[ -d $php_conf ]]; then if [[ -d $php_conf ]]; then

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
set -e
#-e Causes bash script to exit if any of the installers #-e Causes bash script to exit if any of the installers
#return with a non-zero return value. #return with a non-zero return value.

4
jekyll.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
#/bin/bash #!/usr/bin/env bash
echo "Installing Ruby" echo "Installing Ruby"
apt-get update -y && apt-get install -y ruby-full build-essential zlib1g-dev apt-get update -y && apt-get install -y ruby-full build-essential zlib1g-dev
@ -8,7 +8,7 @@ export PATH=".gems/bin:$PATH"
echo "Installing Jekyll" echo "Installing Jekyll"
cd docs cd docs || (echo "Could not cd in docs" && exit 1)
gem install jekyll bundler gem install jekyll bundler
# Running Jekyll # Running Jekyll

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash -xv #!/usr/bin/env bash
set -xv
post_file() { post_file() {
#kill process after 30 minutes (360*5=30 minutes) #kill process after 30 minutes (360*5=30 minutes)
@ -35,7 +37,7 @@ post_file() {
# -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}"; do until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}"; 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

@ -9,7 +9,7 @@ post_file() {
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}"; do until curl --max-time 30 http://localhost/rest/media -u 3188BDIMPJROQP89Z0OX: -X POST -F "file=@${file_path}" -F "name=${filename}"; 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

@ -1,6 +1,6 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash
# -e Causes bash script to exit if any of the steps
# return with a non-zero return value. set -e # Exit if any of the steps fails.
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "Please run as root user." echo "Please run as root user."
@ -8,20 +8,13 @@ if [[ $EUID -ne 0 ]]; then
fi fi
getStorDirFromDatabase() { getStorDirFromDatabase() {
echo $(sudo -u postgres psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'") sudo -u postgres psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'"
} }
dropLibreTimeDatabase() { dropLibreTimeDatabase() {
# here-doc to execute this block as postgres user sudo -u postgres psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime_test"
su postgres << 'EOF' sudo -u postgres psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime"
set +e sudo -u postgres psql -d postgres -tAc "DROP USER IF EXISTS airtime"
# 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"
psql -d postgres -tAc "DROP USER IF EXISTS airtime"
set -e
# don't indent this!
EOF
} }
removeRabbitmqLibreTimeSettings() { removeRabbitmqLibreTimeSettings() {
@ -37,9 +30,6 @@ removeRabbitmqLibreTimeSettings() {
rabbitmqctl delete_user ${RMQ_USER} rabbitmqctl delete_user ${RMQ_USER}
} }
SCRIPT_DIR="$( cd "$( dirname "$0")" && pwd)"
AIRTIMEROOT=${SCRIPT_DIR}
STOR_DIR=$(getStorDirFromDatabase) STOR_DIR=$(getStorDirFromDatabase)
FILES=( FILES=(
@ -57,7 +47,7 @@ FILES=(
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
echo $i echo "$i"
done done
echo "pip3 airtime-playout" echo "pip3 airtime-playout"
@ -65,15 +55,15 @@ 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 -r 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 -r 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
@ -87,12 +77,12 @@ removeRabbitmqLibreTimeSettings
set -e set -e
for i in ${FILES[*]}; do for i in ${FILES[*]}; do
rm -rf $i rm -rf "$i"
done done
echo -e "\nDo you want to drop your current LibreTime database? [y/N]: \c" echo -e "\nDo you want to drop your current LibreTime database? [y/N]: \c"
read IN read -r IN
if [[ "$IN" = "y" || "$IN" = "Y" ]]; then if [[ $IN == "y" || $IN == "Y" ]]; then
echo -e "\nDropping LibreTime database..." echo -e "\nDropping LibreTime database..."
dropLibreTimeDatabase dropLibreTimeDatabase
fi fi