diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index a09c1e42c..5dc03e557 100755 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -17,10 +17,8 @@ if [ $# == 0 ]; then exit 1 elif [ $# == 1 ]; then suffix=$1 - version=$1 else suffix=$1-$2 - version=$1 fi echo "Creating tarball for LibreTime ${suffix}." @@ -41,9 +39,9 @@ echo " Done" #echo "Done" cd .. -find libretime-${suffix} -type f -exec dos2unix {} \; +find "libretime-${suffix}" -type f -exec dos2unix {} \; echo -n "Creating tarball..." -tar -czf libretime-${suffix}.tar.gz \ +tar -czf "libretime-${suffix}.tar.gz" \ --owner=root --group=root \ --exclude-vcs \ --exclude .zfproject.xml \ diff --git a/airtime_mvc/tests/runtests.sh b/airtime_mvc/tests/runtests.sh index 7213ecadb..ed9ca7624 100755 --- a/airtime_mvc/tests/runtests.sh +++ b/airtime_mvc/tests/runtests.sh @@ -30,7 +30,7 @@ export AIRTIME_UNIT_TEST="1" #Change the working directory to this script's directory DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" && pwd)" -cd $DIR +cd "$DIR" || (echo "could not cd in $DIR!" && exit 1) #Run the unit tests phpunit --verbose --log-junit test_results.xml diff --git a/dev_tools/liquidsoap_compile/liquidsoap-compile.sh b/dev_tools/liquidsoap_compile/liquidsoap-compile.sh index 211dd7fd3..f59a52e69 100755 --- a/dev_tools/liquidsoap_compile/liquidsoap-compile.sh +++ b/dev_tools/liquidsoap_compile/liquidsoap-compile.sh @@ -5,8 +5,8 @@ set -e apt-get install -y --force-yes lsb-release sudo dist=$(lsb_release -is) code=$(lsb_release -cs) -cpu=$(getconf LONG_BIT) -cpuvalue= +# cpu=$(getconf LONG_BIT) +# cpuvalue= #enable apt.sourcefabric.org source set +e @@ -32,7 +32,7 @@ if [ "$dist" = "Ubuntu" ]; then fi #enable squeeze backports to get lame packages -if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then +if [[ "$dist" == "Debian" && "$code" == "squeeze" ]]; then set +e grep -E "deb http://backports.debian.org/debian-backports squeeze-backports main" /etc/apt/sources.list returncode=$? @@ -42,12 +42,12 @@ if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then fi fi -echo "System is $cpu bit..." -if [ "$cpu" = "64" ]; then - cpuvalue="amd64" -else - cpuvalue="i386" -fi +# echo "System is $cpu bit..." +# if [ "$cpu" = "64" ]; then +# cpuvalue="amd64" +# else +# cpuvalue="i386" +# fi apt-get update apt-get -o Dpkg::Options::="--force-confold" upgrade diff --git a/dev_tools/propel_regenerate.sh b/dev_tools/propel_regenerate.sh index bd2aac7eb..31dfd01c1 100755 --- a/dev_tools/propel_regenerate.sh +++ b/dev_tools/propel_regenerate.sh @@ -3,12 +3,12 @@ set -e # Absolute path to this script -SCRIPT=$(readlink -f $0) +SCRIPT=$(readlink -f "$0") # Absolute directory this script is in -SCRIPTPATH=$(dirname $SCRIPT) +SCRIPTPATH=$(dirname "$SCRIPT") -cd $SCRIPTPATH/../airtime_mvc/ +cd "$SCRIPTPATH/../airtime_mvc/" || (echo "could not cd in $SCRIPTPATH/../airtime_mvc/" && exit 1) path=$(pwd) 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 diff --git a/dev_tools/release/release.sh b/dev_tools/release/release.sh index c50f3fa3d..4fac2376a 100755 --- a/dev_tools/release/release.sh +++ b/dev_tools/release/release.sh @@ -19,13 +19,13 @@ if [ $# == 0 ]; then exit elif [ $# == 1 ]; then suffix=$1 - version=$1 + # version=$1 else suffix=$1-$2 - version=$1 + # version=$1 fi -dir=$(dirname $(readlink -f $0)) +# dir=$(dirname "$(readlink -f "$0")") gitrepo=$(readlink -f ./../../) echo "Creating tarball for LibreTime ${suffix}." diff --git a/dev_tools/scripts/git-merge-po b/dev_tools/scripts/git-merge-po index e717fc75d..ac91091bb 100755 --- a/dev_tools/scripts/git-merge-po +++ b/dev_tools/scripts/git-merge-po @@ -22,7 +22,8 @@ # # - When merging branches, conflicts in PO files will be marked with "#-#-#-#" # -O=$1 + +# O=$1 A=$2 B=$3 diff --git a/dev_tools/update_po_files.sh b/dev_tools/update_po_files.sh index ee9626aae..ecdb86177 100755 --- a/dev_tools/update_po_files.sh +++ b/dev_tools/update_po_files.sh @@ -4,8 +4,8 @@ cd .. #generate a new .po file #this will generate a file called messages.po -find airtime_mvc -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8 -find airtime_mvc -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8 -k --keyword=_pro:1 -d pro --force-po +find airtime_mvc -print0 -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8 +find airtime_mvc -print0 -iname "*.phtml" -o -name "*.php" | xargs xgettext -L php --from-code=UTF-8 -k --keyword=_pro:1 -d pro --force-po #merge the new messages from messages.po into each existing .po file #this will generate new .po files diff --git a/install b/install index ca90bc661..f7922f9da 100755 --- a/install +++ b/install @@ -678,14 +678,14 @@ case "${dist}-${code}" in is_debian_buster=true ;; #Fix for Raspbian 9 (stretch) - raspbian-9 | 9) + raspbian-9) 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 exit 1 ;; #End of fix #Fix for Raspbian 10 (buster) - raspbian-10 | 10) + raspbian-10) code="buster" dist="debian" # shellcheck disable=SC2034 @@ -811,8 +811,8 @@ will be moved to /etc/airtime/airtime.conf.tmp" rm -f /etc/apache2/sites-available/airtime.conf /etc/apache2/sites-enabled/airtime.conf fi - if [ -d /usr/share/airtime -a web_root = /usr/share/airtime ]; then - rm -rf /usr/share/airtime + if [[ -d "/usr/share/airtime" && $web_root == "/usr/share/airtime" ]]; then + rm -rf "/usr/share/airtime" fi mv /etc/airtime/airtime.conf /etc/airtime/airtime.conf.tmp @@ -821,17 +821,17 @@ will be moved to /etc/airtime/airtime.conf.tmp" fi API2_APACHE_CONF=$(grep -F "ProxyPass" /etc/apache2/sites-available/airtime.conf || true) -if [ -z "${API2_APACHE_CONF}" -a "$apache" = "t" ]; then +if [[ -z "${API2_APACHE_CONF}" && "$apache" == "t" ]]; then # Remove Apache configuration so that the ProxyPass configuration for API 2.0 # is installed rm -f /etc/apache2/sites-available/airtime.conf /etc/apache2/sites-enabled/airtime.conf fi -if [ "$apache" = "f" -a ${_i} -eq 1 ]; then +if [[ "$apache" = "f" && ${_i} -eq 1 ]]; then echo -e "Install default Airtime apache configuration? (Y/n): \c" read IN IN=${IN:-$default_value} - if [ "$IN" = "y" -o "$IN" = "Y" ]; then + if [[ "$IN" = "y" || "$IN" = "Y" ]]; then apache="t" fi fi @@ -861,7 +861,7 @@ if [ "$apache" = "t" ]; then loud " * Configuring Apache * " loud "-----------------------------------------------------" # 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}" verbose "Detected Apache root folder is: ${HTTPD_ROOT}" if [[ ! -e $apache_conf ]]; then @@ -896,7 +896,7 @@ if [ "$apache" = "t" ]; then # install apache, we should overwrite any existing configuration. If we don't do this, doing # an in-place installation over an old Airtime install (which installs to /usr/share by default) # will fail - if [ "$upgrade" = "t" -o ! -f ${apache_sitedir}${airtimeconfigfile} ]; then + if [[ "$upgrade" == "t" || ! -f "${apache_sitedir}${airtimeconfigfile}" ]]; then verbose "\n * Creating Apache config for Airtime..." listen_port="" if [ "$web_port" != "80" ]; then @@ -929,7 +929,7 @@ if [ "$apache" = "t" ]; then fi fi -if [ "$icecast" = "f" -a ${_i} -eq 1 ]; then +if [[ "$icecast" == "f" && ${_i} -eq 1 ]]; then echo -e "Install default Airtime Icecast configuration? (Y/n): \c" read -r IN IN=${IN:-$default_value} @@ -1123,7 +1123,7 @@ EOF echo -e "Create default airtime postgres user? (Y/n): \c" read IN IN=${IN:-$default_value} - if [ "$IN" = "y" -o "$IN" = "Y" ]; then + if [[ "$IN" = "y" || "$IN" = "Y" ]]; then setupAirtimePostgresUser fi fi @@ -1138,7 +1138,7 @@ if [ $skip_rabbitmq -eq 0 ]; then RABBITMQ_VHOST=/airtime RABBITMQ_USER=airtime RABBITMQ_PASSWORD=airtime - EXCHANGES="airtime-pypo|pypo-fetch|airtime-analyzer|media-monitor" + # EXCHANGES="airtime-pypo|pypo-fetch|airtime-analyzer|media-monitor" # Ignore errors in this check to avoid dying when vhost isn't found set +e @@ -1197,14 +1197,14 @@ if [ "$ignore_dependencies" = "f" ]; then else set +e verbose "\n * Generating locales" - for i in $(ls ${web_root}/../locale | grep ".._.."); do + for locale_file in "${web_root}"/../locale/*_*; do + locale=$(basename "$locale_file") if [ "$dist" = "debian" ]; then - grep -qi "^$i" /etc/locale.gen - if [ $? -ne 0 ]; then - verbose "$i.UTF-8 UTF-8" >> /etc/locale.gen + if ! grep -qi "^$locale" /etc/locale.gen; then + verbose "$locale.UTF-8 UTF-8" >> /etc/locale.gen fi else - loudCmd "locale-gen \"$i.utf8\"" + loudCmd "locale-gen \"$locale.utf8\"" fi done set -e diff --git a/python_apps/airtime-celery/install/initd/libretime-celery b/python_apps/airtime-celery/install/initd/libretime-celery index 5f2969cde..6028a1aeb 100755 --- a/python_apps/airtime-celery/install/initd/libretime-celery +++ b/python_apps/airtime-celery/install/initd/libretime-celery @@ -1,4 +1,7 @@ -#!/bin/sh -e +#!/usr/bin/env bash + +set -e + # ============================================ # celeryd - Starts the Celery worker daemon. # ============================================ @@ -29,7 +32,7 @@ # VERSION=10.1 echo "celery init v${VERSION}." -if [ $(id -u) -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Error: This program can only be used by the root user." echo " Unprivileged users must use the 'celery multi' utility, " echo " or 'celery worker --detach'." @@ -51,15 +54,19 @@ DEFAULT_PID_FILE="/var/run/celery/%n.pid" DEFAULT_LOG_FILE="/var/log/celery/%n.log" DEFAULT_LOG_LEVEL="INFO" DEFAULT_NODES="celery" -DEFAULT_CELERYD="-m celery worker --detach" +# DEFAULT_CELERYD="-m celery worker --detach" CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/${SCRIPT_NAME}"} # Make sure executable configuration script is owned by root _config_sanity() { - local path="$1" - local owner=$(ls -ld "$path" | awk '{print $3}') - local iwgrp=$(ls -ld "$path" | cut -b 6) - local iwoth=$(ls -ld "$path" | cut -b 9) + local path + local owner + local iwgrp + local iwoth + path="$1" + owner=$(ls -ld "$path" | awk '{print $3}') + iwgrp=$(ls -ld "$path" | cut -b 6) + iwoth=$(ls -ld "$path" | cut -b 9) if [ "$(id -u $owner)" != "0" ]; then echo "Error: Config script '$path' must be owned by root!" echo @@ -97,6 +104,7 @@ _config_sanity() { if [ -f "$CELERY_DEFAULTS" ]; then _config_sanity "$CELERY_DEFAULTS" echo "Using config script: $CELERY_DEFAULTS" + # shellcheck disable=SC1090 . "$CELERY_DEFAULTS" fi # Sets --app argument for CELERY_BIN @@ -184,8 +192,10 @@ _get_pids() { found_pids=0 my_exitcode=0 for pidfile in $(_get_pidfiles); do - local pid=$(cat "$pidfile") - local cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g') + local pid + local cleaned_pid + pid=$(cat "$pidfile") + cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g') if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then echo "bad pid file ($pidfile)" one_failed=true @@ -207,7 +217,7 @@ start_workers() { if [ ! -z "$CELERYD_ULIMIT" ]; then ulimit $CELERYD_ULIMIT fi - _chuid $* start $CELERYD_NODES $DAEMON_OPTS \ + _chuid "$@" start $CELERYD_NODES $DAEMON_OPTS \ --pidfile="$CELERYD_PID_FILE" \ --logfile="$CELERYD_LOG_FILE" \ --loglevel="$CELERYD_LOG_LEVEL" \ @@ -259,9 +269,12 @@ check_status() { one_failed=true break fi - local node=$(basename "$pidfile" .pid) - local pid=$(cat "$pidfile") - local cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g') + local node + local pid + local cleaned_pid + node=$(basename "$pidfile" .pid) + pid=$(cat "$pidfile") + cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g') if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then echo "bad pid file ($pidfile)" one_failed=true diff --git a/python_apps/airtime_analyzer/install/sysvinit/libretime-analyzer b/python_apps/airtime_analyzer/install/sysvinit/libretime-analyzer index 31da8d5f7..c88be1ea8 100755 --- a/python_apps/airtime_analyzer/install/sysvinit/libretime-analyzer +++ b/python_apps/airtime_analyzer/install/sysvinit/libretime-analyzer @@ -20,6 +20,7 @@ PIDFILE=/var/run/$NAME.pid [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present +# shellcheck disable=SC1090 [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables diff --git a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh index 90cb85a1e..82b02b118 100755 --- a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh +++ b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh @@ -17,7 +17,7 @@ post_file() { stripped_file_path=${file_path//','/''} mv "${file_path}" "${stripped_file_path}" file_path="${stripped_file_path}" - filename="${file_path##*/}" + # filename="${file_path##*/}" airtime_conf_path=/etc/airtime/airtime.conf diff --git a/python_apps/pypo/install/sysvinit/libretime-liquidsoap b/python_apps/pypo/install/sysvinit/libretime-liquidsoap index c90142c3a..35b2cd020 100755 --- a/python_apps/pypo/install/sysvinit/libretime-liquidsoap +++ b/python_apps/pypo/install/sysvinit/libretime-liquidsoap @@ -20,6 +20,7 @@ PIDFILE=/var/run/$NAME.pid [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present +# shellcheck disable=SC1090 [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables diff --git a/python_apps/pypo/install/sysvinit/libretime-playout b/python_apps/pypo/install/sysvinit/libretime-playout index 7a0b121ed..0183336ac 100755 --- a/python_apps/pypo/install/sysvinit/libretime-playout +++ b/python_apps/pypo/install/sysvinit/libretime-playout @@ -20,6 +20,7 @@ PIDFILE=/var/run/$NAME.pid [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present +# shellcheck disable=SC1090 [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables diff --git a/utils/airtime-test-soundcard b/utils/airtime-test-soundcard index 67722cdf2..f852267a7 100755 --- a/utils/airtime-test-soundcard +++ b/utils/airtime-test-soundcard @@ -28,6 +28,6 @@ SCRIPT=$(readlink -f $0) # Absolute directory this script is in SCRIPTPATH=$(dirname $SCRIPT) -cd $SCRIPTPATH +cd $SCRIPTPATH || exit 1 python airtime-test-soundcard.py "$@" || exit 1 diff --git a/utils/airtime-test-stream b/utils/airtime-test-stream index 8634b2dc2..1ebc328dc 100755 --- a/utils/airtime-test-stream +++ b/utils/airtime-test-stream @@ -28,6 +28,6 @@ SCRIPT=$(readlink -f $0) # Absolute directory this script is in SCRIPTPATH=$(dirname $SCRIPT) -cd $SCRIPTPATH +cd $SCRIPTPATH || exit 1 python airtime-test-stream.py "$@" || exit 1 diff --git a/utils/libretime-backup.sh b/utils/libretime-backup.sh index 03f7602c1..529cc64dd 100755 --- a/utils/libretime-backup.sh +++ b/utils/libretime-backup.sh @@ -11,34 +11,34 @@ fi airtime_conf_path=/etc/airtime/airtime.conf uploads_folder=/srv/airtime/stor/ -psdl_db=$(grep dbname ${airtime_conf_path} | awk '{print $3;}') +psql_db=$(grep dbname ${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;}') ## Remove old backup -rm -rf $backup_folder -mkdir $backup_folder +rm -rf "$backup_folder" +mkdir "$backup_folder" ## Backup of database -echo 'db: Getting database...' -pg_dump --dbname='postgresql://'$psql_user':'$psql_password'@localhost/'$psql_db > $backup_folder'database' -echo 'db: Complete' +echo "db: Getting database..." +pg_dump --dbname="postgresql://$psql_user:$psql_password@localhost/$psql_db" > "${backup_folder}database" +echo "db: Complete" ## Backup of sounds -mkdir $backup_folder'uploads/' +mkdir "${backup_folder}uploads/" -echo 'stor : Copying uploaded files...' -rsync -r -a --info=progress2 $uploads_folder $backup_folder'uploads/' -echo 'stor: Complete' +echo "stor : Copying uploaded files..." +rsync -r -a --info=progress2 $uploads_folder "${backup_folder}uploads/" +echo "stor: Complete" ## Backup of libretime config -mkdir $backup_folder'airtime_config/' +mkdir "${backup_folder}airtime_config/" -echo 'config: Copying config...' -rsync -r -a --info=progress2 /etc/airtime/ $backup_folder'airtime_config/' -echo 'config: Complete' +echo "config: Copying config..." +rsync -r -a --info=progress2 /etc/airtime/ "${backup_folder}airtime_config/" +echo "config: Complete" -date >> $backup_folder'datelog.txt' +date >> "${backup_folder}datelog.txt" diff --git a/utils/rivendell-converter.sh b/utils/rivendell-converter.sh index a16b26c2d..38f3d071d 100755 --- a/utils/rivendell-converter.sh +++ b/utils/rivendell-converter.sh @@ -21,17 +21,17 @@ db="Rivendell" #Edit this only if you changed Rivendell's database name :-) rivendell_dir=$1 end_dir=$2 -cd "$rivendell_dir" +cd "$rivendell_dir" || (echo "could not cd in $rivendell_dir" && exit 1) for file in *; do lame "$file" done mv "$rivendell_dir"/*.mp3 "$end_dir" -cd "$end_dir" +cd "$end_dir" || (echo "could not cd in $end_dir" && exit 1) for file in *; 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) 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)