several scripts: use the release helpers instead of hand-rolled version checks and downloads (#17625)

* Use the release helpers instead of hand-rolled version checks and downloads

Legacy /opt/*_version.txt files move to ~/.<app> on the next update.

* homeassistant: use get_latest_github_release
This commit is contained in:
CanbiZ (MickLesk)
2026-10-02 08:01:49 +02:00
committed by GitHub
parent 94cdc531ca
commit b4bf7aacf3
29 changed files with 125 additions and 261 deletions
+4 -8
View File
@@ -19,12 +19,9 @@ $STD apk add --no-cache \
python3
msg_ok "Installed Dependencies"
msg_info "Installing IT-Tools"
RELEASE=$(curl -fsSL https://api.github.com/repos/sharevb/it-tools/releases/latest | grep '"tag_name":' | cut -d '"' -f4)
curl -fsSL "https://github.com/sharevb/it-tools/releases/download/${RELEASE}/it-tools-${RELEASE#v}.zip" -o it-tools.zip
mkdir -p /usr/share/nginx/html
$STD unzip it-tools.zip -d /tmp/
mv /tmp/dist/* /usr/share/nginx/html
fetch_and_deploy_gh_release "it-tools" "sharevb/it-tools" "prebuild" "latest" "/usr/share/nginx/html" "it-tools-*.zip"
msg_info "Configuring IT-Tools"
cat <<'EOF' >/etc/nginx/http.d/default.conf
server {
listen 80;
@@ -39,8 +36,7 @@ server {
EOF
$STD rc-update add nginx default
$STD rc-service nginx start
echo "${RELEASE}" >/opt/"${APPLICATION}"_version.txt
msg_ok "Installed IT-Tools"
msg_ok "Configured IT-Tools"
motd_ssh
customize
+4 -12
View File
@@ -90,20 +90,14 @@ setup_alpine() {
$STD rc-service postgresql start
msg_ok "Installed PostreSQL"
RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
fetch_and_deploy_gh_release "bitmagnet" "bitmagnet-io/bitmagnet" "tarball"
msg_info "Installing bitmagnet v${RELEASE}"
mkdir -p /opt/bitmagnet
temp_file=$(mktemp)
curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
msg_info "Building bitmagnet"
cd /opt/bitmagnet
VREL=v$RELEASE
$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=v$(cat ~/.bitmagnet)"
chmod +x bitmagnet
$STD su - postgres -c "psql -c 'CREATE DATABASE bitmagnet;'"
echo "${RELEASE}" >/opt/bitmagnet_version.txt
msg_ok "Installed bitmagnet v${RELEASE}"
msg_ok "Built bitmagnet"
read -rp "${TAB3}Enter your TMDB API key if you have one: " tmdbapikey
@@ -133,8 +127,6 @@ EOF
msg_info "Starting bitmagnet"
$STD service bitmagnet start
msg_ok "Started bitmagnet"
rm -f "$temp_file"
}
run_os_setup
+2 -4
View File
@@ -78,12 +78,10 @@ EOF
read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
fetch_and_deploy_gh_release "xcaddy" "caddyserver/xcaddy" "prebuild" "latest" "/opt/xcaddy" "xcaddy_*_linux_$(arch_resolve).tar.gz"
ln -sf /opt/xcaddy/xcaddy /usr/local/bin/xcaddy
msg_info "Setup xCaddy"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz"
$STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy
rm -rf /opt/xcaddy*
$STD xcaddy build
msg_ok "Setup xCaddy"
fi
+1 -4
View File
@@ -65,10 +65,7 @@ setup_alpine() {
$STD rc-update add docker default
msg_ok "Installed Docker"
get_latest_release() {
curl -fsSL https://api.github.com/repos/"$1"/releases/latest | grep '"tag_name":' | cut -d'"' -f4
}
DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose")
DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_github_release "docker/compose" false)
read -r -p "${TAB3}Would you like to add Docker Compose? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
msg_info "Installing Docker Compose $DOCKER_COMPOSE_LATEST_VERSION"
+1 -6
View File
@@ -51,12 +51,7 @@ EOF
$STD systemctl restart mariadb
msg_ok "Configured MariaDB for ERPNext"
msg_info "Installing wkhtmltopdf"
WKHTMLTOPDF_URL="https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_$(arch_resolve).deb"
$STD curl -fsSL -o /tmp/wkhtmltox.deb "$WKHTMLTOPDF_URL"
$STD apt install -y /tmp/wkhtmltox.deb
rm -f /tmp/wkhtmltox.deb
msg_ok "Installed wkhtmltopdf"
fetch_and_deploy_gh_release "wkhtmltopdf" "wkhtmltopdf/packaging" "binary" "latest" "" "wkhtmltox_*.bookworm_$(arch_resolve).deb"
msg_info "Installing Frappe Bench"
useradd -m -s /bin/bash frappe
+1 -9
View File
@@ -27,14 +27,7 @@ setup_mariadb
mariadb-tzinfo-to-sql /usr/share/zoneinfo | mariadb mysql
MARIADB_DB_NAME="glpi_db" MARIADB_DB_USER="glpi" MARIADB_DB_EXTRA_GRANTS="GRANT SELECT ON \`mysql\`.\`time_zone_name\`" MARIADB_DB_CREDS_FILE="$HOME/glpi_db.creds" setup_mariadb_db
msg_info "Installing GLPi"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/glpi-project/glpi/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
curl -fsSL "https://github.com/glpi-project/glpi/releases/download/${RELEASE}/glpi-${RELEASE}.tgz" -o $(basename "https://github.com/glpi-project/glpi/releases/download/${RELEASE}/glpi-${RELEASE}.tgz")
$STD tar -xzvf glpi-${RELEASE}.tgz
cd /opt/glpi
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed GLPi"
fetch_and_deploy_gh_release "glpi" "glpi-project/glpi" "prebuild" "latest" "/opt/glpi" "glpi-*.tgz"
msg_info "Setting Downstream file"
cat <<EOF >/opt/glpi/inc/downstream.php
@@ -119,7 +112,6 @@ $STD a2dissite 000-default.conf
$STD a2enmod rewrite
$STD a2ensite glpi.conf
rm -rf /opt/glpi/install/install.php
rm -rf /opt/glpi-${RELEASE}.tgz
msg_ok "Setup Service"
msg_info "Setup Cronjob"
+1 -5
View File
@@ -26,11 +26,7 @@ msg_info "Installing runlike"
$STD pip install runlike
msg_ok "Installed runlike"
get_latest_release() {
curl -fsSL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4
}
CORE_LATEST_VERSION=$(get_latest_release "home-assistant/core")
CORE_LATEST_VERSION=$(get_latest_github_release "home-assistant/core")
setup_docker
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/portainer.sh)" <<<"y"
+1 -1
View File
@@ -80,7 +80,7 @@ setup_alpine() {
sed -i 's|# *include "mod_fastcgi.conf"|include "mod_fastcgi.conf"|' /etc/lighttpd/lighttpd.conf
sed -i 's|/usr/bin/php-cgi|/usr/bin/php-cgi83|g' /etc/lighttpd/mod_fastcgi.conf
mkdir -p /var/www/localhost/htdocs
ADMINER_VERSION=$(curl -fsSL https://api.github.com/repos/vrana/adminer/releases/latest | jq -r '.tag_name' | sed 's/^v//')
ADMINER_VERSION=$(get_latest_github_release "vrana/adminer")
curl -fsSL "https://github.com/vrana/adminer/releases/download/v${ADMINER_VERSION}/adminer-${ADMINER_VERSION}.php" -o /var/www/localhost/htdocs/adminer.php
chown lighttpd:lighttpd /var/www/localhost/htdocs/adminer.php
chmod 755 /var/www/localhost/htdocs/adminer.php
+1 -4
View File
@@ -25,10 +25,7 @@ $STD apk add docker
$STD rc-service docker start
$STD rc-update add docker default
get_latest_release() {
curl -fsSL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4
}
DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose")
DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_github_release "docker/compose" false)
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -fsSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-$(arch_resolve "x86_64" "aarch64") -o ~/.docker/cli-plugins/docker-compose
+1 -1
View File
@@ -22,7 +22,7 @@ msg_ok "Installed Dependencies"
JAVA_VERSION="21" setup_java
msg_info "Installing OneDev"
RELEASE=$(curl -fsSL https://api.github.com/repos/theonedev/onedev/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
RELEASE=$(get_latest_github_release "theonedev/onedev" false)
cd /opt
curl -fsSL "https://code.onedev.io/onedev/server/~site/onedev-latest.tar.gz" -o onedev-latest.tar.gz
tar -xzf onedev-latest.tar.gz
+1 -1
View File
@@ -180,7 +180,7 @@ setup_alpine() {
sed -i 's|# *include "mod_fastcgi.conf"|include "mod_fastcgi.conf"|' /etc/lighttpd/lighttpd.conf
sed -i 's|/usr/bin/php-cgi|/usr/bin/php-cgi83|g' /etc/lighttpd/mod_fastcgi.conf
mkdir -p /var/www/localhost/htdocs
ADMINER_VERSION=$(curl -fsSL https://api.github.com/repos/vrana/adminer/releases/latest | jq -r '.tag_name' | sed 's/^v//')
ADMINER_VERSION=$(get_latest_github_release "vrana/adminer")
curl -fsSL "https://github.com/vrana/adminer/releases/download/v${ADMINER_VERSION}/adminer-${ADMINER_VERSION}.php" -o /var/www/localhost/htdocs/adminer.php
chown lighttpd:lighttpd /var/www/localhost/htdocs/adminer.php
chmod 755 /var/www/localhost/htdocs/adminer.php
+2 -6
View File
@@ -51,12 +51,10 @@ read -p "${TAB3}Provide an email address for admin login, this should be a valid
read -p "${TAB3}Enter your First Name: " NAME_FIRST
read -p "${TAB3}Enter your Last Name: " NAME_LAST
fetch_and_deploy_gh_release "pterodactyl-panel" "pterodactyl/panel" "prebuild" "latest" "/opt/pterodactyl-panel" "panel.tar.gz"
msg_info "Installing pterodactyl Panel"
RELEASE=$(curl -fsSL https://api.github.com/repos/pterodactyl/panel/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
mkdir /opt/pterodactyl-panel
cd /opt/pterodactyl-panel
curl -fsSL "https://github.com/pterodactyl/panel/releases/download/v${RELEASE}/panel.tar.gz" -o "panel.tar.gz"
tar -xzf "panel.tar.gz"
cp .env.example .env
ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD composer install --no-dev --optimize-autoloader --no-interaction
@@ -75,9 +73,7 @@ pterodactyl Admin Username: admin
pterodactyl Admin Email: $ADMIN_EMAIL
pterodactyl Admin Password: $ADMIN_PASS
EOF
rm -rf "/opt/pterodactyl-panel/panel.tar.gz"
rm -rf "/tmp/debsuryorg-archive-keyring.deb"
echo "${RELEASE}" >/opt/"${APPLICATION}"_version.txt
msg_ok "Installed pterodactyl Panel"
msg_info "Creating Service"
+4 -11
View File
@@ -57,12 +57,9 @@ setup_alpine() {
apache2-utils fuse3
msg_ok "Installed dependencies"
msg_info "Installing rclone"
temp_file=$(mktemp)
mkdir -p /opt/rclone
RELEASE=$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
curl -fsSL "https://github.com/rclone/rclone/releases/download/v${RELEASE}/rclone-v${RELEASE}-linux-$(arch_resolve).zip" -o "$temp_file"
$STD unzip -j "$temp_file" '*/**' -d /opt/rclone
fetch_and_deploy_gh_release "rclone" "rclone/rclone" "prebuild" "latest" "/opt/rclone" "rclone*linux-$(arch_resolve).zip"
msg_info "Configuring rclone"
cd /opt/rclone
RCLONE_PASSWORD=$(head -c 16 /dev/urandom | xxd -p -c 16)
$STD htpasswd -cb -B /opt/login.pwd admin "$RCLONE_PASSWORD"
@@ -71,9 +68,7 @@ rclone-Credentials
rclone User Name: admin
rclone Password: $RCLONE_PASSWORD
EOF
echo "${RELEASE}" >/opt/rclone_version.txt
rm -f "$temp_file"
msg_ok "Installed rclone"
msg_ok "Configured rclone"
msg_info "Enabling rclone Service"
cat <<EOF >/etc/init.d/rclone
@@ -96,8 +91,6 @@ EOF
msg_info "Starting rclone"
$STD service rclone start
msg_ok "Started rclone"
rm -rf "$temp_file"
}
run_os_setup
+8 -19
View File
@@ -24,13 +24,9 @@ setup_deb_based() {
}
setup_alpine() {
RELEASE=$(curl -s https://api.github.com/repos/lejianwen/rustdesk-server/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
msg_info "Installing RustDesk Server v${RELEASE}"
temp_file1=$(mktemp)
ARCH=$(arch_resolve "amd64" "arm64v8")
curl -fsSL "https://github.com/lejianwen/rustdesk-server/releases/download/${RELEASE}/rustdesk-server-linux-${ARCH}.zip" -o "$temp_file1"
$STD unzip "$temp_file1"
mv "$ARCH" /opt/rustdesk-server
fetch_and_deploy_gh_release "rustdesk-server" "lejianwen/rustdesk-server" "prebuild" "latest" "/opt/rustdesk-server" "rustdesk-server-linux-$(arch_resolve "amd64" "arm64v8").zip"
msg_info "Configuring RustDesk Server"
mkdir -p /root/.config/rustdesk
cd /opt/rustdesk-server
./rustdesk-utils genkeypair >/tmp/rustdesk_keys.txt
@@ -39,15 +35,11 @@ setup_alpine() {
chmod 600 /root/.config/rustdesk/id_ed25519
chmod 644 /root/.config/rustdesk/id_ed25519.pub
rm /tmp/rustdesk_keys.txt
echo "${RELEASE}" >~/.rustdesk-server
msg_ok "Installed RustDesk Server v${RELEASE}"
msg_ok "Configured RustDesk Server"
APIRELEASE=$(curl -s https://api.github.com/repos/lejianwen/rustdesk-api/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
msg_info "Installing RustDesk API v${APIRELEASE}"
temp_file2=$(mktemp)
curl -fsSL "https://github.com/lejianwen/rustdesk-api/releases/download/v${APIRELEASE}/linux-$(arch_resolve).tar.gz" -o "$temp_file2"
$STD tar zxvf "$temp_file2"
mv release /opt/rustdesk-api
fetch_and_deploy_gh_release "rustdesk-api" "lejianwen/rustdesk-api" "prebuild" "latest" "/opt/rustdesk-api" "linux-$(arch_resolve).tar.gz"
msg_info "Configuring RustDesk API"
cd /opt/rustdesk-api
ADMINPASS=$(head -c 16 /dev/urandom | xxd -p -c 16)
$STD ./apimain reset-admin-pwd "$ADMINPASS"
@@ -57,8 +49,7 @@ RustDesk WebUI
Username: admin
Password: $ADMINPASS
EOF
echo "${APIRELEASE}" >~/.rustdesk-api
msg_ok "Installed RustDesk API v${APIRELEASE}"
msg_ok "Configured RustDesk API"
msg_info "Enabling RustDesk Server Services"
cat <<EOF >/etc/init.d/rustdesk-server-hbbs
@@ -124,8 +115,6 @@ EOF
$STD service rustdesk-server-hbbr start
$STD service rustdesk-api start
msg_ok "Started RustDesk Server"
rm -f "$temp_file1" "$temp_file2"
}
run_os_setup
+2 -7
View File
@@ -26,13 +26,10 @@ curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/pla
$STD python3 get-platformio.py
msg_ok "Setup Platformio"
fetch_and_deploy_gh_release "tasmocompiler" "benzino77/tasmocompiler" "tarball"
msg_info "Setup TasmoCompiler"
mkdir /tmp/Tasmota
RELEASE=$(curl -fsSL https://api.github.com/repos/benzino77/tasmocompiler/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
curl_download "/tmp/v${RELEASE}.tar.gz" "https://github.com/benzino77/tasmocompiler/archive/refs/tags/v${RELEASE}.tar.gz"
cd /tmp
tar xzf /tmp/v${RELEASE}.tar.gz
mv tasmocompiler-${RELEASE}/ /opt/tasmocompiler/
cd /opt/tasmocompiler
$STD yarn install
export NODE_OPTIONS=--openssl-legacy-provider
@@ -42,8 +39,6 @@ mkdir -p /usr/local/bin
ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio
ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb
rm -f /tmp/v${RELEASE}.tar.gz
echo "${RELEASE}" >"/opt/tasmocompiler_version.txt"
msg_ok "Setup TasmoCompiler"
msg_info "Creating Service"
+4 -7
View File
@@ -64,11 +64,9 @@ setup_alpine() {
$STD apk add --no-cache openssl apache2-utils
msg_ok "Installed Dependencies"
msg_info "Installing Tinyauth"
mkdir -p /opt/tinyauth
RELEASE=$(curl -s https://api.github.com/repos/tinyauthapp/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
curl -fsSL "https://github.com/tinyauthapp/tinyauth/releases/download/v${RELEASE}/tinyauth-$(arch_resolve)" -o /opt/tinyauth/tinyauth
chmod +x /opt/tinyauth/tinyauth
fetch_and_deploy_gh_release "tinyauth" "tinyauthapp/tinyauth" "singlefile" "latest" "/opt/tinyauth" "tinyauth-$(arch_resolve)"
msg_info "Configuring Tinyauth"
PASS=$(openssl rand -base64 8 | tr -dc 'a-zA-Z0-9' | head -c 8)
USER=$(htpasswd -Bbn "tinyauth" "${PASS}")
@@ -77,8 +75,7 @@ Tinyauth Credentials
Username: tinyauth
Password: ${PASS}
EOF
echo "${RELEASE}" >~/.tinyauth
msg_ok "Installed Tinyauth"
msg_ok "Configured Tinyauth"
read -r -p "${TAB3}Enter your Tinyauth subdomain (e.g. https://tinyauth.example.com): " app_url
+5 -13
View File
@@ -17,15 +17,10 @@ msg_info "Installing dependencies"
$STD apt install -y zstd
msg_ok "Installed dependencies"
msg_info "Installing Wastebin"
temp_file=$(mktemp)
RELEASE=$(curl -fsSL https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/matze/wastebin/releases/download/${RELEASE}/wastebin_${RELEASE}_$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl.tar.zst" -o "$temp_file"
tar -xf "$temp_file"
mkdir -p /opt/wastebin
mv wastebin* /opt/wastebin/
chmod +x /opt/wastebin/wastebin
chmod +x /opt/wastebin/wastebin-ctl
fetch_and_deploy_gh_release "wastebin" "matze/wastebin" "prebuild" "latest" "/opt/wastebin" "wastebin_*_$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl.tar.zst"
chmod +x /opt/wastebin/wastebin /opt/wastebin/wastebin-ctl
msg_info "Configuring Wastebin"
mkdir -p /opt/wastebin-data
cat <<EOF >/opt/wastebin-data/.env
@@ -35,10 +30,7 @@ WASTEBIN_HTTP_TIMEOUT=30
WASTEBIN_SIGNING_KEY=$(openssl rand -hex 32)
WASTEBIN_PASTE_EXPIRATIONS=0,600,3600=d,86400,604800,2419200,29030400
EOF
rm -f "$temp_file"
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed Wastebin"
msg_ok "Configured Wastebin"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/wastebin.service
+1 -1
View File
@@ -13,7 +13,7 @@ setting_up_container
network_check
update_os
RELEASE=$(curl -fsSL https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '"tag_name"' | awk -F '"' '{print substr($4, 2, length($2)-4)}')
RELEASE=$(get_latest_github_release "wazuh/wazuh" | cut -d. -f1,2)
msg_warn "WARNING: This script will run an external installer from a third-party source (https://wazuh.com/)."
msg_warn "The following code is NOT maintained or audited by our repository."