Refactor install.sh for improved quoting and variable handling
All checks were successful
Deploy ACT Runner Installer / deploy (push) Successful in 10s
All checks were successful
Deploy ACT Runner Installer / deploy (push) Successful in 10s
This commit is contained in:
30
install.sh
30
install.sh
@@ -1,12 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
check_command() {
|
check_command() {
|
||||||
command -v $1 >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
check_version() {
|
check_version() {
|
||||||
act_runner_version=$(act_runner -v | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+')
|
act_runner_version=$(act_runner -v | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+')
|
||||||
echo $act_runner_version
|
echo "$act_runner_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ensure jq is installed (attempt auto-install on common distros)
|
# Ensure jq is installed (attempt auto-install on common distros)
|
||||||
@@ -59,7 +59,7 @@ fi
|
|||||||
|
|
||||||
required_commands=("curl" "jq" "wget" "unxz" "sha256sum")
|
required_commands=("curl" "jq" "wget" "unxz" "sha256sum")
|
||||||
for cmd in "${required_commands[@]}"; do
|
for cmd in "${required_commands[@]}"; do
|
||||||
if ! check_command $cmd; then
|
if ! check_command "$cmd"; then
|
||||||
echo "Error: '$cmd' command not found. Please make sure all required commands are installed."
|
echo "Error: '$cmd' command not found. Please make sure all required commands are installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -71,21 +71,21 @@ if [ "$arch" = "x86_64" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
json=$(curl -s https://gitea.com/api/v1/repos/gitea/act_runner/releases/latest)
|
json=$(curl -s https://gitea.com/api/v1/repos/gitea/act_runner/releases/latest)
|
||||||
latest_version=$(echo $json | jq -r '.tag_name')
|
latest_version=$(echo "$json" | jq -r '.tag_name')
|
||||||
url_checksum=$(echo $json | jq -r '.assets[] | select(.name | contains("linux-'$arch'") and contains(".xz.sha256")) | .browser_download_url')
|
url_checksum=$(echo "$json" | jq -r '.assets[] | select(.name | contains("linux-'"$arch"'") and contains(".xz.sha256")) | .browser_download_url')
|
||||||
url_binary=$(echo $json | jq -r '.assets[] | select(.name | contains("linux-'$arch'") and contains(".xz")) | .browser_download_url')
|
url_binary=$(echo "$json" | jq -r '.assets[] | select(.name | contains("linux-'"$arch"'") and contains(".xz")) | .browser_download_url')
|
||||||
checksum_filename=$(basename $url_checksum)
|
checksum_filename=$(basename "$url_checksum")
|
||||||
filename=$(basename $url_binary)
|
filename=$(basename "$url_binary")
|
||||||
|
|
||||||
if [ -z "$current_version" ] || [ "$current_version" != "$latest_version" ]; then
|
if [ -z "$current_version" ] || [ "$current_version" != "$latest_version" ]; then
|
||||||
echo "Updating act_runner to version: $latest_version"
|
echo "Updating act_runner to version: $latest_version"
|
||||||
wget $url_binary
|
wget "$url_binary"
|
||||||
wget $url_checksum
|
wget "$url_checksum"
|
||||||
sha256sum -c $checksum_filename
|
sha256sum -c "$checksum_filename"
|
||||||
rm $checksum_filename
|
rm "$checksum_filename"
|
||||||
unxz $filename
|
unxz "$filename"
|
||||||
filename=$(echo $filename | sed 's/\.xz$//')
|
filename=${filename%.xz}
|
||||||
mv $filename '/usr/local/bin/act_runner'
|
mv "$filename" '/usr/local/bin/act_runner'
|
||||||
chmod +x /usr/local/bin/act_runner
|
chmod +x /usr/local/bin/act_runner
|
||||||
echo "Update completed."
|
echo "Update completed."
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user