Skip to content

Commit

Permalink
Add shellcheck and a integration test
Browse files Browse the repository at this point in the history
Couldn't get fedora/redhat type containers to work. TODO.

Shellcheck 2070 says:
Exceptions

If the strings happen to be version numbers and you're using <, or > to compare them as strings, and you consider this an acceptable thing to do, then you can ignore this warning.

So I left it. The alternatives are complicated bash, or external tools
that aren't always installed.
  • Loading branch information
laduke committed Aug 29, 2024
1 parent 9be4644 commit 3c7b1bf
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Curl | Bash Test
on:
push:
paths:
- install.sh.in
- .github/workflows/ci.yml
# branches: [ main ]
schedule:
- cron: "0 0 * * 0" # weekly
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- run: sudo apt install -y shellcheck
- run: shellcheck -S error install.sh.in

curl-bash:
needs: shellcheck
runs-on: ubuntu-latest
strategy:
matrix:
container:
- "ubuntu:latest"
- "ubuntu:24.10"
- "ubuntu:24.04"
- "ubuntu:22.04"
- "ubuntu:20.04"
- "debian:latest"
- "debian:12"
- "debian:11"
- "debian:10"
- "kalilinux/kali-rolling:latest"

container:
image: ${{ matrix.container }}

steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: apt
run: apt-get -y update && apt-get -y install curl gnupg2 gnupg gpg bc || true
- name: install ${{ matrix.container }}
run: bash install.sh.in
10 changes: 6 additions & 4 deletions install.sh.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck disable=SC2148
ENDOFSIGSTART=

export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
Expand Down Expand Up @@ -216,6 +217,7 @@ _new_apt_signing() {
echo "deb [signed-by=/usr/share/keyrings/zerotier-debian-package-key.gpg] ${URL}debian/$CODENAME $CODENAME main" >/tmp/zt-sources-list
}

# shellcheck disable=SC2072
write_apt_repo() {
DISTRIBUTION=$1
VERSION=$2
Expand All @@ -230,7 +232,7 @@ write_apt_repo() {
$SUDO apt-get install -y gpg
$SUDO chmod a+r /tmp/zt-gpg-key

if [[ "$DISTRIBUTION" == "ubuntu" && "$VERSION" < "22.04" ]]; then
if [[ "$DISTRIBUTION" == "ubuntu" && "$VERSION" < "22.04" ]]; then
_old_apt_signing $URL $CODENAME
elif [[ ("$DISTRIBUTION" == "debian" || "$DISTRIBUTION" == "raspbian") && "$VERSION" -lt "10" ]]; then
_old_apt_signing $URL $CODENAME
Expand All @@ -242,9 +244,9 @@ write_apt_repo() {
_new_apt_signing $URL $CODENAME
elif [[ "$DISTRIBUTION" == "linuxmint" && "$VERSION" == "6" ]]; then
_new_apt_signing $URL $CODENAME
elif [[ "$DISTRIBUTION" == "linuxmint" && ( "$VERSION" == "21" || "$VERSION" > "21" ) ]]; then
elif [[ "$DISTRIBUTION" == "linuxmint" && ( "$VERSION" == "21" || "$VERSION" -gt "21" ) ]]; then
_new_apt_signing $URL $CODENAME
elif [[ "$DISTRIBUTION" == "linuxmint" && ( "$VERSION" == "20" || ("$VERSION" > "20" && "$VERSION" < "21" ) ) ]]; then
elif [[ "$DISTRIBUTION" == "linuxmint" && ( "$VERSION" == "20" || ("$VERSION" -gt "20" && "$VERSION" -lt "21" ) ) ]]; then
_old_apt_signing $URL $CODENAME
else
echo "Unsupported distribution $DISTRIBUTION $VERSION"
Expand Down Expand Up @@ -296,7 +298,7 @@ elif [ $ID == "ubuntu" ] || [ $ID == "pop" ]; then
elif [ $ID == "linuxmint" ]; then
echo '*** Detected Linux Mint, creating /etc/apt/sources.list.d/zerotier.list'

if [[ "$VERSION_ID" > "$MAX_SUPPORTED_MINT_VERSION" ]]; then
if [[ "$VERSION_ID" -gt "$MAX_SUPPORTED_MINT_VERSION" ]]; then
write_apt_repo $ID $MAX_SUPPORTED_MINT_VERSION $ZT_BASE_URL_HTTP $MAX_SUPPORTED_MINT_VERSION_NAME
else
write_apt_repo $ID $VERSION_ID $ZT_BASE_URL_HTTP ${MINT_CODENAME_MAP[${VERSION_CODENAME}]}
Expand Down

0 comments on commit 3c7b1bf

Please sign in to comment.