community-content
community-content copied to clipboard
🚨 Issue 450: fix failover-script
This PR fixes issue #450 by a fixed fail.sh
failover-script. This script has been:
- reformatted with shfmt
- shellcheck'ed
- 1 error
- 2 warning
- 22 style
- 32 info
I have read and understood the Contributor's Certificate of Origin available at the end of https://raw.githubusercontent.com/hetzneronline/community-content/master/tutorial-template.md and I hereby certify that I meet the contribution criteria described in it. Signed-off-by: Thomas Merz [email protected]
Full shellcheck
output before this fix:
In 01.sh line 9: pard=$4 ^--^ SC2034 (warning): pard appears unused. Verify use (or export if used externally).In 01.sh line 12: curl=
whereis curl|awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: curl=$(whereis curl|awk '{ print $2 }')
In 01.sh line 13: if [ $? -ne 0 ] ; then echo "Curl is not properly configured" ; exit 1 ; fi ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 20: echo $para | grep -E "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" > /dev/null 2>&1 ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$para" | grep -E "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" > /dev/null 2>&1
In 01.sh line 23: if [ $? -eq 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
In 01.sh line 36: if [ -z "$parc" -a "$parb" == "set" ] ; then echo "You have to specify the IP address of the failover server" ; exit 1 ; fi ^-- SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
In 01.sh line 40: read user ^--^ SC2162 (info): read without -r will mangle backslashes.
In 01.sh line 42: read pass ^--^ SC2162 (info): read without -r will mangle backslashes.
In 01.sh line 48: resources=
cat $resourcedir/* | grep "resource" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: resources=$(cat $resourcedir/* | grep "resource" | awk '{ print $2 }')
In 01.sh line 50: if [ $? -ne 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 57: if [ -z $para ] ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: if [ -z "$para" ]
In 01.sh line 61: echo $resources ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources"
In 01.sh line 65: echo $resources | grep $para > /dev/null ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources" | grep "$para" > /dev/null
In 01.sh line 67: if [ $? -ne 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 71: echo $resources ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources"
In 01.sh line 75: ip=
cat $resourcedir/$para | grep "^ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: ip=$(cat $resourcedir/"$para" | grep "^ip" | awk '{ print $2 }')
In 01.sh line 77: user=
cat $resourcedir/$para | grep "user" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: user=$(cat $resourcedir/"$para" | grep "user" | awk '{ print $2 }')
In 01.sh line 78: pass=
cat $resourcedir/$para | grep "password" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: pass=$(cat $resourcedir/"$para" | grep "password" | awk '{ print $2 }')
In 01.sh line 87: lines 1-126...skipping...
In 01.sh line 9: pard=$4 ^--^ SC2034 (warning): pard appears unused. Verify use (or export if used externally).
In 01.sh line 12: curl=
whereis curl|awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: curl=$(whereis curl|awk '{ print $2 }')
In 01.sh line 13: if [ $? -ne 0 ] ; then echo "Curl is not properly configured" ; exit 1 ; fi ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 20: echo $para | grep -E "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" > /dev/null 2>&1 ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$para" | grep -E "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" > /dev/null 2>&1
In 01.sh line 23: if [ $? -eq 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
In 01.sh line 36: if [ -z "$parc" -a "$parb" == "set" ] ; then echo "You have to specify the IP address of the failover server" ; exit 1 ; fi ^-- SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
In 01.sh line 40: read user ^--^ SC2162 (info): read without -r will mangle backslashes.
In 01.sh line 42: read pass ^--^ SC2162 (info): read without -r will mangle backslashes.
In 01.sh line 48: resources=
cat $resourcedir/* | grep "resource" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: resources=$(cat $resourcedir/* | grep "resource" | awk '{ print $2 }')
In 01.sh line 50: if [ $? -ne 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 57: if [ -z $para ] ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: if [ -z "$para" ]
In 01.sh line 61: echo $resources ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources"
In 01.sh line 65: echo $resources | grep $para > /dev/null ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources" | grep "$para" > /dev/null
In 01.sh line 67: if [ $? -ne 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 71: echo $resources ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources"
In 01.sh line 75: ip=
cat $resourcedir/$para | grep "^ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: ip=$(cat $resourcedir/"$para" | grep "^ip" | awk '{ print $2 }')
In 01.sh line 77: user=
cat $resourcedir/$para | grep "user" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: user=$(cat $resourcedir/"$para" | grep "user" | awk '{ print $2 }')
In 01.sh line 78: pass=
cat $resourcedir/$para | grep "password" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: pass=$(cat $resourcedir/"$para" | grep "password" | awk '{ print $2 }')
In 01.sh line 87: get=
$curl -s -u $user:$pass $uri/$ip
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: get=$($curl -s -u "$user":"$pass" $uri/"$ip")
In 01.sh line 91: echo $get ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$get"
In 01.sh line 101: echo $get ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$get"
In 01.sh line 105: yamlip=
echo "$get" | grep "^ ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlip=$(echo "$get" | grep "^ ip" | awk '{ print $2 }')
In 01.sh line 106: yamlserverip=
echo "$get" | grep "^ server_ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlserverip=$(echo "$get" | grep "^ server_ip" | awk '{ print $2 }')
In 01.sh line 107: yamlactiveip=
echo "$get" | grep "^ active_server_ip" | awk '{print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlactiveip=$(echo "$get" | grep "^ active_server_ip" | awk '{print $2 }')
lines 1-176...skipping...
In 01.sh line 9: pard=$4 ^--^ SC2034 (warning): pard appears unused. Verify use (or export if used externally).
In 01.sh line 9: pard=$4 ^--^ SC2034 (warning): pard appears unused. Verify use (or export if used externally).
In 01.sh line 12: curl=
whereis curl|awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: curl=$(whereis curl|awk '{ print $2 }')
In 01.sh line 13: if [ $? -ne 0 ] ; then echo "Curl is not properly configured" ; exit 1 ; fi ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 20: echo $para | grep -E "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" > /dev/null 2>&1 ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$para" | grep -E "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" > /dev/null 2>&1
In 01.sh line 23: if [ $? -eq 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
In 01.sh line 36: if [ -z "$parc" -a "$parb" == "set" ] ; then echo "You have to specify the IP address of the failover server" ; exit 1 ; fi ^-- SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
In 01.sh line 40: read user ^--^ SC2162 (info): read without -r will mangle backslashes.
In 01.sh line 42: read pass ^--^ SC2162 (info): read without -r will mangle backslashes.
In 01.sh line 48: resources=
cat $resourcedir/* | grep "resource" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: resources=$(cat $resourcedir/* | grep "resource" | awk '{ print $2 }')
In 01.sh line 50: if [ $? -ne 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 57: if [ -z $para ] ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: if [ -z "$para" ]
In 01.sh line 61: echo $resources ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources"
In 01.sh line 65: echo $resources | grep $para > /dev/null ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources" | grep "$para" > /dev/null
In 01.sh line 67: if [ $? -ne 0 ] ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
In 01.sh line 71: echo $resources ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$resources"
In 01.sh line 75: ip=
cat $resourcedir/$para | grep "^ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: ip=$(cat $resourcedir/"$para" | grep "^ip" | awk '{ print $2 }')
In 01.sh line 77: user=
cat $resourcedir/$para | grep "user" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: user=$(cat $resourcedir/"$para" | grep "user" | awk '{ print $2 }')
In 01.sh line 78: pass=
cat $resourcedir/$para | grep "password" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: pass=$(cat $resourcedir/"$para" | grep "password" | awk '{ print $2 }')
In 01.sh line 87: get=
$curl -s -u $user:$pass $uri/$ip
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: get=$($curl -s -u "$user":"$pass" $uri/"$ip")
In 01.sh line 91: echo $get ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$get"
In 01.sh line 101: echo $get ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: echo "$get"
In 01.sh line 105: yamlip=
echo "$get" | grep "^ ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlip=$(echo "$get" | grep "^ ip" | awk '{ print $2 }')
In 01.sh line 106: yamlserverip=
echo "$get" | grep "^ server_ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlserverip=$(echo "$get" | grep "^ server_ip" | awk '{ print $2 }')
In 01.sh line 107: yamlactiveip=
echo "$get" | grep "^ active_server_ip" | awk '{print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlactiveip=$(echo "$get" | grep "^ active_server_ip" | awk '{print $2 }')
In 01.sh line 114: then echo "the configured failover server(s) is/are:
cat $resourcedir/$para | grep "^failover_ip" | sed -e 's/failover_ip //g'
" ; fi ^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: then echo "the configured failover server(s) is/are: $(cat $resourcedir/"$para" | grep "^failover_ip" | sed -e 's/failover_ip //g')" ; fi
In 01.sh line 119: if [ -z $parc ] ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: if [ -z "$parc" ]
In 01.sh line 122: echo "the configured failover server(s) is/are:
cat $resourcedir/$para | grep "^failover_ip" | sed -e 's/failover_ip //g'
" ^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: echo "the configured failover server(s) is/are: $(cat $resourcedir/"$para" | grep "^failover_ip" | sed -e 's/failover_ip //g')"
In 01.sh line 127: set=
$curl -s -u $user:$pass $uri/$ip -d active_server_ip=$parc
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: set=$($curl -s -u "$user":"$pass" $uri/"$ip" -d active_server_ip="$parc")
In 01.sh line 151: yamlip=
echo "$set" | grep "^ ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlip=$(echo "$set" | grep "^ ip" | awk '{ print $2 }')
In 01.sh line 152: yamlserverip=
echo "$set" | grep "^ server_ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlserverip=$(echo "$set" | grep "^ server_ip" | awk '{ print $2 }')
In 01.sh line 153: yamlactiveip=
echo "$set" | grep "^ active_server_ip" | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
.Did you mean: yamlactiveip=$(echo "$set" | grep "^ active_server_ip" | awk '{ print $2 }')
In 01.sh line 160: then echo "the configured failover server(s) is/are:
cat $resourcedir/$para | grep "^failover_ip" | sed -e 's/failover_ip //g'
" ; fi ^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: then echo "the configured failover server(s) is/are: $(cat $resourcedir/"$para" | grep "^failover_ip" | sed -e 's/failover_ip //g')" ; fi
In 01.sh line 167: script=
grep "script" $resourcedir/$para | awk '{ print $2 }'
^-- SC2006 (style): Use $(...) notation instead of legacy backticks...
. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: script=$(grep "script" $resourcedir/"$para" | awk '{ print $2 }')
In 01.sh line 174: elif [ -x $script ] ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: elif [ -x "$script" ]
In 01.sh line 176: ./$0 $para set $parc ^-- SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: ./"$0" "$para" set "$parc"
In 01.sh line 177: if [ $? = 0 ] ; then $script ; else exit 1 ; fi ^-- SC2181 (style): Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
In 01.sh line 178: elif [ -f $script ] ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: elif [ -f "$script" ]
In 01.sh line 185: if [ -n $parb ] ^---^ SC2070 (error): -n doesn't work with unquoted arguments. Quote or use [[ ]]. ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: if [ -n "$parb" ]
For more information: https://www.shellcheck.net/wiki/SC2070 -- -n doesn't work with unquoted arg... https://www.shellcheck.net/wiki/SC2034 -- pard appears unused. Verify use (... https://www.shellcheck.net/wiki/SC2166 -- Prefer [ p ] && [ q ] as [ p -a q...
@thomasmerz Which script would you like to get reviewed? The one called fail.sh
?
@svenja11 , that's right. I moved it from MD-files into a single one: fail.sh
.
The other files in tutorials/failover-script are only for showing failing and fixed shellcheck
before from 01.sh(.start) and 02.sh(.start) which are now "all-in-one" (fail.sh) and should be removed before merging.
Should I remove now "the other files in tutorials/failover-script that are only for showing failing and fixed shellcheck before from 01.sh(.start) and 02.sh(.start) which are now "all-in-one" (fail.sh)" before merging?
Yes you can remove the other files now. Please also move the script from fail.sh
back to the files 01.en.md
and 01.de.md
. Otherwise, the contents might not get displayed correctly at community.hetzner.com.
@svenja11 , my thoughts about files 01.en.md
and 01.de.md
: I have provided a link to the real script to deduplicate it from two markdown-files and for easier download. Would you agree to keep this change?
I understand where you're coming from. It's just that the tutorials are all published at community.hetzner.com which does not support these kind of links. That's why the entire text needs to be in those md
files.
@svenja11 , I understood and moved fail.sh
back again into both markdown files 👍🏼
Here's my `shellcheck' GitHub Action in my forked repo proving that everything is fine now:

With this GitHub Action definition:
name: Shellcheck Lint
on:
push:
paths:
# Run workflow on every push
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: Shellcheck Lint
# This job runs on Linux
runs-on: ubuntu-latest
steps:
# Required to access files of this repository
- uses: actions/checkout@v2
# Download Shellcheck and add it to the workflow path
- name: Download Shellcheck
run: |
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv
chmod +x shellcheck-stable/shellcheck
# Verify that Shellcheck can be executed
- name: Check Shellcheck Version
run: |
shellcheck-stable/shellcheck --version
# Run Shellcheck on repository
# ---
# https://github.com/koalaman/shellcheck
# ---
# Excluded checks:
# https://www.shellcheck.net/wiki/SC1091 -- Not following: /etc/rc.status was...
# https://www.shellcheck.net/wiki/SC1090 -- Can't follow non-constant source. ..
# ---
- name: Run Shellcheck
run: |
rm -f ./some_scripts_have_failed_shellcheck
set +e
find ./ -type f -name "*.sh"| sort | while read -r sh; do
if [ "$(file --brief --mime-type "$sh")" == 'text/x-shellscript' ]; then
echo "shellcheck'ing $sh"
if ! shellcheck-stable/shellcheck --color=always --severity=warning "$sh"; then
touch some_scripts_have_failed_shellcheck
fi
fi
done
if [ -f ./some_scripts_have_failed_shellcheck ]; then
echo "Shellcheck failed for one or more shellscript(s)"
exit 1
fi