mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-28 20:42:41 +02:00
add shellcheck action to catch script errors (#4533)
* add shellcheck action to catch script errors * fix(_commands.sh): cache command * fix(_provision.sh): unicode space * fix(blitz.conf.sh): use $* * fix(internet.dyndomain.sh): use -gt * fix(blitz.fatpack.sh): use $* * fix(_cache.sh): quote $@ and use $* with echo * shellcheck disable SC2068 and SC2145 * update checkout action in .github/workflows/test-shellcheck.yml Co-authored-by: Christoph Stenglein <9399034+cstenglein@users.noreply.github.com> * fix(_bootsrtap.sh): =~ needs double brackets * fix(bonus.publicpool.sh): use $* when displaying with echo --------- Co-authored-by: Christoph Stenglein <9399034+cstenglein@users.noreply.github.com>
This commit is contained in:
19
.github/workflows/test-shellcheck.yml
vendored
Normal file
19
.github/workflows/test-shellcheck.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: "Test Shellcheck"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: ["dev"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["dev"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
name: Run Shellcheck
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Run ShellCheck
|
||||||
|
uses: ludeeus/action-shellcheck@master
|
||||||
|
with:
|
||||||
|
severity: error
|
@@ -306,7 +306,7 @@ until [ ${#scenario} -gt 0 ] && [[ ! "${scenario}" =~ ^error ]]; do
|
|||||||
if [ "${scenario}" = "error:no-storage" ]; then
|
if [ "${scenario}" = "error:no-storage" ]; then
|
||||||
/home/admin/_cache.sh set state "noHDD"
|
/home/admin/_cache.sh set state "noHDD"
|
||||||
/home/admin/_cache.sh set message ">=1TB"
|
/home/admin/_cache.sh set message ">=1TB"
|
||||||
elif [ "${scenario}" =~ ^error ]; then
|
elif [[ "${scenario}" =~ ^error ]]; then
|
||||||
echo "FAIL - error on HDD analysis: ${scenario}" >> $logFile
|
echo "FAIL - error on HDD analysis: ${scenario}" >> $logFile
|
||||||
/home/admin/_cache.sh set state "errorHDD"
|
/home/admin/_cache.sh set state "errorHDD"
|
||||||
/home/admin/_cache.sh set message "${scenario}"
|
/home/admin/_cache.sh set message "${scenario}"
|
||||||
|
@@ -212,12 +212,14 @@ elif [ "$1" = "set" ] || [ "$1" = "init" ]; then
|
|||||||
elif [ "$1" = "get" ]; then
|
elif [ "$1" = "get" ]; then
|
||||||
|
|
||||||
position=0
|
position=0
|
||||||
|
# shellcheck disable=SC2068
|
||||||
for keystr in $@
|
for keystr in $@
|
||||||
do
|
do
|
||||||
|
|
||||||
# skip first parameter
|
# skip first parameter
|
||||||
((position++))
|
((position++))
|
||||||
if [ $position -eq 1 ]; then
|
if [ $position -eq 1 ]; then
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "# _cache.sh $@"
|
echo "# _cache.sh $@"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -432,12 +434,14 @@ elif [ "$1" = "valid" ]; then
|
|||||||
|
|
||||||
position=0
|
position=0
|
||||||
lasttouch_overall=""
|
lasttouch_overall=""
|
||||||
|
# shellcheck disable=SC2068
|
||||||
for keystr in $@
|
for keystr in $@
|
||||||
do
|
do
|
||||||
|
|
||||||
# skip first parameter from script - thats the action string
|
# skip first parameter from script - thats the action string
|
||||||
((position++))
|
((position++))
|
||||||
if [ $position -eq 1 ]; then
|
if [ $position -eq 1 ]; then
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "# _cache.sh $@"
|
echo "# _cache.sh $@"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@@ -288,6 +288,7 @@ function headless() {
|
|||||||
|
|
||||||
# command: cache
|
# command: cache
|
||||||
function cache() {
|
function cache() {
|
||||||
|
# shellcheck disable=SC2068
|
||||||
sudo /home/admin/_cache.sh $@
|
sudo /home/admin/_cache.sh $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -276,7 +276,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# LND binary install
|
# LND binary install
|
||||||
if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ] || [ "${tlnd}" == "on" ] || [ "${slnd}" == "on" ]; then
|
if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ] || [ "${tlnd}" == "on" ] || [ "${slnd}" == "on" ]; then
|
||||||
# if already installed by fatpack will skip
|
# if already installed by fatpack will skip
|
||||||
echo "Provisioning LND Binary - run config script" >> ${logFile}
|
echo "Provisioning LND Binary - run config script" >> ${logFile}
|
||||||
/home/admin/config.scripts/lnd.install.sh install >> ${logFile} 2>&1
|
/home/admin/config.scripts/lnd.install.sh install >> ${logFile} 2>&1
|
||||||
|
@@ -23,6 +23,7 @@ if [ "$1" = "set" ]; then
|
|||||||
|
|
||||||
# check that key & value are given
|
# check that key & value are given
|
||||||
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
|
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "# blitz.conf.sh $@"
|
echo "# blitz.conf.sh $@"
|
||||||
echo "# FAIL: missing parameter"
|
echo "# FAIL: missing parameter"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -39,6 +40,7 @@ if [ "$1" = "set" ]; then
|
|||||||
# check that config file exists
|
# check that config file exists
|
||||||
raspiblitzConfExists=$(ls ${configFile} 2>/dev/null | grep -c "${configFile}")
|
raspiblitzConfExists=$(ls ${configFile} 2>/dev/null | grep -c "${configFile}")
|
||||||
if [ ${raspiblitzConfExists} -eq 0 ]; then
|
if [ ${raspiblitzConfExists} -eq 0 ]; then
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "# blitz.conf.sh $@"
|
echo "# blitz.conf.sh $@"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
@@ -87,6 +89,7 @@ elif [ "$1" = "list-add" ]; then
|
|||||||
|
|
||||||
# check that key & value are given
|
# check that key & value are given
|
||||||
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
|
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "# blitz.conf.sh $@"
|
echo "# blitz.conf.sh $@"
|
||||||
echo "# FAIL: missing parameter"
|
echo "# FAIL: missing parameter"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -141,6 +144,7 @@ elif [ "$1" = "list-remove" ]; then
|
|||||||
|
|
||||||
# check that key & value are given
|
# check that key & value are given
|
||||||
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
|
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
|
||||||
|
# shellcheck disable=SC2145
|
||||||
echo "# blitz.conf.sh $@"
|
echo "# blitz.conf.sh $@"
|
||||||
echo "# FAIL: missing parameter"
|
echo "# FAIL: missing parameter"
|
||||||
exit 1
|
exit 1
|
||||||
|
@@ -61,9 +61,11 @@ if [ "${needsExpansion}" == "1" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
apt_install() {
|
apt_install() {
|
||||||
|
# shellcheck disable=SC2068
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y ${@}
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y ${@}
|
||||||
if [ $? -eq 100 ]; then
|
if [ $? -eq 100 ]; then
|
||||||
echo "FAIL! apt failed to install needed packages!"
|
echo "FAIL! apt failed to install needed packages!"
|
||||||
|
# shellcheck disable=SC2068
|
||||||
echo ${@}
|
echo ${@}
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@@ -15,7 +15,7 @@ APP_DATA_DIR="/mnt/hdd/app-data/${APPID}"
|
|||||||
|
|
||||||
# Debug information
|
# Debug information
|
||||||
echo "# Script name: $0"
|
echo "# Script name: $0"
|
||||||
echo "# All parameters: $@"
|
echo "# All parameters: $*"
|
||||||
echo "# First parameter: $1"
|
echo "# First parameter: $1"
|
||||||
echo "# Parameter count: $#"
|
echo "# Parameter count: $#"
|
||||||
|
|
||||||
|
@@ -78,13 +78,13 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
|||||||
dynUpdateUrl=''
|
dynUpdateUrl=''
|
||||||
|
|
||||||
# when additional parameters are given
|
# when additional parameters are given
|
||||||
if [ $# > 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
|
|
||||||
# 2. parameter is dyndomain (required)
|
# 2. parameter is dyndomain (required)
|
||||||
dynDomain=$2
|
dynDomain=$2
|
||||||
|
|
||||||
# 3. parameter is the update url (optional - could be that router is doing the update)
|
# 3. parameter is the update url (optional - could be that router is doing the update)
|
||||||
if [ $# > 2 ]; then
|
if [ $# -gt 2 ]; then
|
||||||
dynUpdateUrl=$3
|
dynUpdateUrl=$3
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user