mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-26 20:02:58 +01:00
Compare commits
19 Commits
fix/pin-np
...
github-act
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd52a62e80 | ||
|
|
88e1813f96 | ||
|
|
6c44215000 | ||
|
|
d4e20816c7 | ||
|
|
d12a0f1701 | ||
|
|
fbe5b57c76 | ||
|
|
b14dfccc99 | ||
|
|
38a283e549 | ||
|
|
d06a70819d | ||
|
|
53e73e2f1a | ||
|
|
ee66508879 | ||
|
|
83cfa0b5b4 | ||
|
|
0a458c0a11 | ||
|
|
6703fca0e4 | ||
|
|
42fbf1afc5 | ||
|
|
d1c5b03fa7 | ||
|
|
b9a39db667 | ||
|
|
0872f086ef | ||
|
|
4eecca8aea |
32
CHANGELOG.md
32
CHANGELOG.md
@@ -426,6 +426,38 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
|
||||
|
||||
</details>
|
||||
|
||||
## 2026-03-26
|
||||
|
||||
### 🆕 New Scripts
|
||||
|
||||
- BirdNET ([#13313](https://github.com/community-scripts/ProxmoxVE/pull/13313))
|
||||
|
||||
### 🚀 Updated Scripts
|
||||
|
||||
- #### 🐞 Bug Fixes
|
||||
|
||||
- Immich: Bump to 2.6.2 | use start.sh in service, ensure DB_HOSTNAME in .env | Fix Rights Issue with ZFS Shares [@MickLesk](https://github.com/MickLesk) ([#13199](https://github.com/community-scripts/ProxmoxVE/pull/13199))
|
||||
|
||||
- #### ✨ New Features
|
||||
|
||||
- Frigate: bump to v0.17.1 & change build order [@MickLesk](https://github.com/MickLesk) ([#13304](https://github.com/community-scripts/ProxmoxVE/pull/13304))
|
||||
- SparkyFitness: add garmin microservice as addon [@tomfrenzel](https://github.com/tomfrenzel) ([#12642](https://github.com/community-scripts/ProxmoxVE/pull/12642))
|
||||
|
||||
### 💾 Core
|
||||
|
||||
- #### 🐞 Bug Fixes
|
||||
|
||||
- tools.func: pin npm to 11.11.0 to work around Node.js 22.22.2 regression [@MickLesk](https://github.com/MickLesk) ([#13296](https://github.com/community-scripts/ProxmoxVE/pull/13296))
|
||||
|
||||
- #### ✨ New Features
|
||||
|
||||
- core: APT/APK Mirror Fallback for CDN Failures [@MickLesk](https://github.com/MickLesk) ([#13316](https://github.com/community-scripts/ProxmoxVE/pull/13316))
|
||||
- core/tools: replace generic return 1 exit_codes with more specific exit_codes [@MickLesk](https://github.com/MickLesk) ([#13311](https://github.com/community-scripts/ProxmoxVE/pull/13311))
|
||||
|
||||
- #### 🔧 Refactor
|
||||
|
||||
- core: use /usr/bin/install to prevent function shadowing [@MickLesk](https://github.com/MickLesk) ([#13299](https://github.com/community-scripts/ProxmoxVE/pull/13299))
|
||||
|
||||
## 2026-03-25
|
||||
|
||||
### 🚀 Updated Scripts
|
||||
|
||||
63
ct/birdnet.sh
Normal file
63
ct/birdnet.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
||||
|
||||
# Copyright (c) 2021-2026 community-scripts ORG
|
||||
# Author: MickLesk (CanbiZ)
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://github.com/tphakala/birdnet-go
|
||||
|
||||
APP="BirdNET"
|
||||
var_tags="${var_tags:-monitoring;ai;nature}"
|
||||
var_cpu="${var_cpu:-4}"
|
||||
var_ram="${var_ram:-2048}"
|
||||
var_disk="${var_disk:-12}"
|
||||
var_os="${var_os:-debian}"
|
||||
var_version="${var_version:-13}"
|
||||
var_unprivileged="${var_unprivileged:-1}"
|
||||
var_gpu="${var_gpu:-no}"
|
||||
|
||||
header_info "$APP"
|
||||
variables
|
||||
color
|
||||
catch_errors
|
||||
|
||||
function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
|
||||
if [[ ! -f /usr/local/bin/birdnet-go ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if check_for_gh_release "birdnet" "tphakala/birdnet-go"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop birdnet
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
fetch_and_deploy_gh_release "birdnet" "tphakala/birdnet-go" "prebuild" "latest" "/opt/birdnet" "birdnet-go-linux-amd64.tar.gz"
|
||||
|
||||
msg_info "Deploying Binary"
|
||||
cp /opt/birdnet/birdnet-go /usr/local/bin/birdnet-go
|
||||
chmod +x /usr/local/bin/birdnet-go
|
||||
cp -r /opt/birdnet/libtensorflowlite_c.so /usr/local/lib/ || true
|
||||
ldconfig
|
||||
msg_ok "Deployed Binary"
|
||||
|
||||
msg_info "Starting Service"
|
||||
systemctl start birdnet
|
||||
msg_ok "Started Service"
|
||||
msg_ok "Updated successfully!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
start
|
||||
build_container
|
||||
description
|
||||
|
||||
msg_ok "Completed Successfully!\n"
|
||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"
|
||||
22
ct/immich.sh
22
ct/immich.sh
@@ -109,7 +109,7 @@ EOF
|
||||
msg_ok "Image-processing libraries up to date"
|
||||
fi
|
||||
|
||||
RELEASE="v2.6.1"
|
||||
RELEASE="v2.6.2"
|
||||
if check_for_gh_release "Immich" "immich-app/immich" "${RELEASE}" "each release is tested individually before the version is updated. Please do not open issues for this"; then
|
||||
if [[ $(cat ~/.immich) > "2.5.1" ]]; then
|
||||
msg_info "Enabling Maintenance Mode"
|
||||
@@ -214,7 +214,10 @@ EOF
|
||||
|
||||
cd "$SRC_DIR"/machine-learning
|
||||
mkdir -p "$ML_DIR"
|
||||
chown -R immich:immich "$INSTALL_DIR"
|
||||
# chown excluding upload dir contents (may be a mount with restricted permissions)
|
||||
chown immich:immich "$INSTALL_DIR"
|
||||
find "$INSTALL_DIR" -maxdepth 1 -mindepth 1 ! -name upload -exec chown -R immich:immich {} +
|
||||
chown immich:immich "${UPLOAD_DIR:-$INSTALL_DIR/upload}" 2>/dev/null || true
|
||||
chown immich:immich ./uv.lock
|
||||
export VIRTUAL_ENV="${ML_DIR}"/ml-venv
|
||||
export UV_HTTP_TIMEOUT=300
|
||||
@@ -263,7 +266,20 @@ EOF
|
||||
[[ ! -f /usr/bin/immich ]] && ln -sf "$APP_DIR"/cli/bin/immich /usr/bin/immich
|
||||
[[ ! -f /usr/bin/immich-admin ]] && ln -sf "$APP_DIR"/bin/immich-admin /usr/bin/immich-admin
|
||||
|
||||
chown -R immich:immich "$INSTALL_DIR"
|
||||
if ! grep -q '^DB_HOSTNAME=' "$INSTALL_DIR"/.env; then
|
||||
sed -i '/^DB_DATABASE_NAME/a DB_HOSTNAME=127.0.0.1' "$INSTALL_DIR"/.env
|
||||
fi
|
||||
|
||||
if grep -q 'ExecStart=/usr/bin/node' /etc/systemd/system/immich-web.service; then
|
||||
sed -i '/^EnvironmentFile=/d' /etc/systemd/system/immich-web.service
|
||||
sed -i "s|^ExecStart=.*|ExecStart=${APP_DIR}/bin/start.sh|" /etc/systemd/system/immich-web.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
# chown excluding upload dir contents (may be a mount with restricted permissions)
|
||||
chown immich:immich "$INSTALL_DIR"
|
||||
find "$INSTALL_DIR" -maxdepth 1 -mindepth 1 ! -name upload -exec chown -R immich:immich {} +
|
||||
chown immich:immich "${UPLOAD_DIR:-$INSTALL_DIR/upload}" 2>/dev/null || true
|
||||
if [[ "${MAINT_MODE:-0}" == 1 ]]; then
|
||||
msg_info "Disabling Maintenance Mode"
|
||||
cd /opt/immich/app/bin
|
||||
|
||||
56
install/birdnet-install.sh
Normal file
56
install/birdnet-install.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2026 community-scripts ORG
|
||||
# Author: MickLesk (CanbiZ)
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://github.com/tphakala/birdnet-go
|
||||
|
||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||
color
|
||||
verb_ip6
|
||||
catch_errors
|
||||
setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt install -y \
|
||||
libasound2 \
|
||||
sox \
|
||||
alsa-utils \
|
||||
ffmpeg
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
fetch_and_deploy_gh_release "birdnet" "tphakala/birdnet-go" "prebuild" "latest" "/opt/birdnet" "birdnet-go-linux-amd64.tar.gz"
|
||||
|
||||
msg_info "Setting up BirdNET"
|
||||
cp /opt/birdnet/birdnet-go /usr/local/bin/birdnet-go
|
||||
chmod +x /usr/local/bin/birdnet-go
|
||||
cp -r /opt/birdnet/libtensorflowlite_c.so /usr/local/lib/ || true
|
||||
ldconfig
|
||||
mkdir -p /opt/birdnet/data/clips
|
||||
msg_ok "Set up BirdNET"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/birdnet.service
|
||||
[Unit]
|
||||
Description=BirdNET
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/birdnet/data
|
||||
ExecStart=/usr/local/bin/birdnet-go realtime
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now birdnet
|
||||
msg_ok "Created Service"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
cleanup_lxc
|
||||
@@ -110,7 +110,7 @@ export AUTOGRAPH_VERBOSITY=0
|
||||
export GLOG_minloglevel=3
|
||||
export GLOG_logtostderr=0
|
||||
|
||||
fetch_and_deploy_gh_release "frigate" "blakeblackshear/frigate" "tarball" "v0.17.0" "/opt/frigate"
|
||||
fetch_and_deploy_gh_release "frigate" "blakeblackshear/frigate" "tarball" "v0.17.1" "/opt/frigate"
|
||||
|
||||
msg_info "Building Nginx"
|
||||
$STD bash /opt/frigate/docker/main/build_nginx.sh
|
||||
@@ -182,23 +182,6 @@ cp /opt/frigate/audio-labelmap.txt /audio-labelmap.txt
|
||||
rm -f /tmp/yamnet.tar.gz
|
||||
msg_ok "Downloaded Audio Model"
|
||||
|
||||
msg_info "Installing HailoRT Runtime"
|
||||
$STD bash /opt/frigate/docker/main/install_hailort.sh
|
||||
cp -a /opt/frigate/docker/main/rootfs/. /
|
||||
sed -i '/^.*unset DEBIAN_FRONTEND.*$/d' /opt/frigate/docker/main/install_deps.sh
|
||||
echo "libedgetpu1-max libedgetpu/accepted-eula boolean true" | debconf-set-selections
|
||||
echo "libedgetpu1-max libedgetpu/install-confirm-max boolean true" | debconf-set-selections
|
||||
echo 'force-overwrite' >/etc/dpkg/dpkg.cfg.d/force-overwrite
|
||||
$STD bash /opt/frigate/docker/main/install_deps.sh
|
||||
rm -f /etc/dpkg/dpkg.cfg.d/force-overwrite
|
||||
$STD pip3 install -U /wheels/*.whl
|
||||
ldconfig
|
||||
msg_ok "Installed HailoRT Runtime"
|
||||
|
||||
msg_info "Installing MemryX Runtime"
|
||||
$STD bash /opt/frigate/docker/main/install_memryx.sh
|
||||
msg_ok "Installed MemryX Runtime"
|
||||
|
||||
msg_info "Installing OpenVino"
|
||||
$STD pip3 install -r /opt/frigate/docker/main/requirements-ov.txt
|
||||
msg_ok "Installed OpenVino"
|
||||
@@ -228,6 +211,23 @@ else
|
||||
msg_warn "OpenVino build failed (CPU may not support required instructions). Frigate will use CPU model."
|
||||
fi
|
||||
|
||||
msg_info "Installing HailoRT Runtime"
|
||||
$STD bash /opt/frigate/docker/main/install_hailort.sh
|
||||
cp -a /opt/frigate/docker/main/rootfs/. /
|
||||
sed -i '/^.*unset DEBIAN_FRONTEND.*$/d' /opt/frigate/docker/main/install_deps.sh
|
||||
echo "libedgetpu1-max libedgetpu/accepted-eula boolean true" | debconf-set-selections
|
||||
echo "libedgetpu1-max libedgetpu/install-confirm-max boolean true" | debconf-set-selections
|
||||
echo 'force-overwrite' >/etc/dpkg/dpkg.cfg.d/force-overwrite
|
||||
$STD bash /opt/frigate/docker/main/install_deps.sh
|
||||
rm -f /etc/dpkg/dpkg.cfg.d/force-overwrite
|
||||
$STD pip3 install -U /wheels/*.whl
|
||||
ldconfig
|
||||
msg_ok "Installed HailoRT Runtime"
|
||||
|
||||
msg_info "Installing MemryX Runtime"
|
||||
$STD bash /opt/frigate/docker/main/install_memryx.sh
|
||||
msg_ok "Installed MemryX Runtime"
|
||||
|
||||
msg_info "Building Frigate Application (Patience)"
|
||||
cd /opt/frigate
|
||||
$STD pip3 install -r /opt/frigate/docker/main/requirements-dev.txt
|
||||
|
||||
@@ -295,7 +295,7 @@ ML_DIR="${APP_DIR}/machine-learning"
|
||||
GEO_DIR="${INSTALL_DIR}/geodata"
|
||||
mkdir -p {"${APP_DIR}","${UPLOAD_DIR}","${GEO_DIR}","${INSTALL_DIR}"/cache}
|
||||
|
||||
fetch_and_deploy_gh_release "Immich" "immich-app/immich" "tarball" "v2.6.1" "$SRC_DIR"
|
||||
fetch_and_deploy_gh_release "Immich" "immich-app/immich" "tarball" "v2.6.2" "$SRC_DIR"
|
||||
PNPM_VERSION="$(jq -r '.packageManager | split("@")[1] | split("+")[0]' ${SRC_DIR}/package.json)"
|
||||
NODE_VERSION="24" NODE_MODULE="pnpm@${PNPM_VERSION}" setup_nodejs
|
||||
|
||||
@@ -344,7 +344,11 @@ msg_ok "Installed Immich Server, Web and Plugin Components"
|
||||
|
||||
cd "$SRC_DIR"/machine-learning
|
||||
$STD useradd -U -s /usr/sbin/nologin -r -M -d "$INSTALL_DIR" immich
|
||||
mkdir -p "$ML_DIR" && chown -R immich:immich "$INSTALL_DIR"
|
||||
mkdir -p "$ML_DIR"
|
||||
# chown excluding upload dir contents (may be a mount with restricted permissions)
|
||||
chown immich:immich "$INSTALL_DIR"
|
||||
find "$INSTALL_DIR" -maxdepth 1 -mindepth 1 ! -name upload -exec chown -R immich:immich {} +
|
||||
chown immich:immich "$UPLOAD_DIR" 2>/dev/null || true
|
||||
export VIRTUAL_ENV="${ML_DIR}/ml-venv"
|
||||
export UV_HTTP_TIMEOUT=300
|
||||
if [[ -f ~/.openvino ]]; then
|
||||
@@ -469,8 +473,7 @@ User=immich
|
||||
Group=immich
|
||||
UMask=0077
|
||||
WorkingDirectory=${APP_DIR}
|
||||
EnvironmentFile=${INSTALL_DIR}/.env
|
||||
ExecStart=/usr/bin/node ${APP_DIR}/dist/main
|
||||
ExecStart=${APP_DIR}/bin/start.sh
|
||||
Restart=on-failure
|
||||
SyslogIdentifier=immich-web
|
||||
StandardOutput=append:/var/log/immich/web.log
|
||||
@@ -500,7 +503,11 @@ StandardError=append:/var/log/immich/ml.log
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
chown -R immich:immich "$INSTALL_DIR" /var/log/immich
|
||||
chown -R immich:immich /var/log/immich
|
||||
# chown excluding upload dir contents (may be a mount with restricted permissions)
|
||||
chown immich:immich "$INSTALL_DIR"
|
||||
find "$INSTALL_DIR" -maxdepth 1 -mindepth 1 ! -name upload -exec chown -R immich:immich {} +
|
||||
chown immich:immich "$UPLOAD_DIR" 2>/dev/null || true
|
||||
systemctl enable -q --now immich-ml.service immich-web.service
|
||||
msg_ok "Modified user, created env file, scripts and services"
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ sed \
|
||||
-e "s|^SPARKY_FITNESS_SERVER_HOST=.*|SPARKY_FITNESS_SERVER_HOST=localhost|" \
|
||||
-e "s|^SPARKY_FITNESS_SERVER_PORT=.*|SPARKY_FITNESS_SERVER_PORT=3010|" \
|
||||
-e "s|^SPARKY_FITNESS_FRONTEND_URL=.*|SPARKY_FITNESS_FRONTEND_URL=http://${LOCAL_IP}:80|" \
|
||||
-e "s|^GARMIN_MICROSERVICE_URL=.*|GARMIN_MICROSERVICE_URL=http://${LOCAL_IP}:8000|" \
|
||||
-e "s|^SPARKY_FITNESS_API_ENCRYPTION_KEY=.*|SPARKY_FITNESS_API_ENCRYPTION_KEY=$(openssl rand -hex 32)|" \
|
||||
-e "s|^BETTER_AUTH_SECRET=.*|BETTER_AUTH_SECRET=$(openssl rand -hex 32)|" \
|
||||
"/etc/sparkyfitness/.env"
|
||||
|
||||
@@ -135,10 +135,34 @@ network_check() {
|
||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
}
|
||||
|
||||
# This function updates the Container OS by running apt-get update and upgrade
|
||||
# This function updates the Container OS by running apk upgrade with mirror fallback
|
||||
update_os() {
|
||||
msg_info "Updating Container OS"
|
||||
$STD apk -U upgrade
|
||||
if ! $STD apk -U upgrade; then
|
||||
msg_warn "apk update failed (dl-cdn.alpinelinux.org), trying alternate mirrors..."
|
||||
local alpine_mirrors="mirror.init7.net ftp.halifax.rwth-aachen.de mirrors.edge.kernel.org alpine.mirror.wearetriple.com mirror.leaseweb.com uk.alpinelinux.org dl-2.alpinelinux.org dl-4.alpinelinux.org"
|
||||
local apk_ok=false
|
||||
for m in $(printf '%s\n' $alpine_mirrors | shuf); do
|
||||
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
||||
msg_custom "${INFO}" "${YW}" "Attempting mirror: ${m}"
|
||||
cat <<EOF >/etc/apk/repositories
|
||||
http://$m/alpine/latest-stable/main
|
||||
http://$m/alpine/latest-stable/community
|
||||
EOF
|
||||
if $STD apk -U upgrade; then
|
||||
msg_ok "CDN set to ${m}: tests passed"
|
||||
apk_ok=true
|
||||
break
|
||||
else
|
||||
msg_warn "Mirror ${m} failed"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "$apk_ok" != true ]]; then
|
||||
msg_error "All Alpine mirrors failed. Check network or try again later."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
local tools_content
|
||||
tools_content=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) || {
|
||||
msg_error "Failed to download tools.func"
|
||||
|
||||
@@ -20,7 +20,7 @@ need_tool() {
|
||||
msg_info "Installing tools: $*"
|
||||
apk add --no-cache "$@" >/dev/null 2>&1 || {
|
||||
msg_error "apk add failed for: $*"
|
||||
return 1
|
||||
return 100
|
||||
}
|
||||
msg_ok "Tools ready: $*"
|
||||
fi
|
||||
@@ -52,17 +52,17 @@ ensure_usr_local_bin_persist() {
|
||||
download_with_progress() {
|
||||
# $1 url, $2 dest
|
||||
local url="$1" out="$2" cl
|
||||
need_tool curl pv || return 1
|
||||
need_tool curl pv || return 127
|
||||
cl=$(curl -fsSLI "$url" 2>/dev/null | awk 'tolower($0) ~ /^content-length:/ {print $2}' | tr -d '\r')
|
||||
if [ -n "$cl" ]; then
|
||||
curl -fsSL "$url" | pv -s "$cl" >"$out" || {
|
||||
msg_error "Download failed: $url"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
else
|
||||
curl -fL# -o "$out" "$url" || {
|
||||
msg_error "Download failed: $url"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
fi
|
||||
}
|
||||
@@ -82,14 +82,14 @@ check_for_gh_release() {
|
||||
|
||||
net_resolves api.github.com || {
|
||||
msg_error "DNS/network error: api.github.com"
|
||||
return 1
|
||||
return 6
|
||||
}
|
||||
need_tool curl jq || return 1
|
||||
need_tool curl jq || return 127
|
||||
|
||||
tag=$(curl -fsSL "https://api.github.com/repos/${source}/releases/latest" | jq -r '.tag_name // empty')
|
||||
[ -z "$tag" ] && {
|
||||
msg_error "Unable to fetch latest tag for $app"
|
||||
return 1
|
||||
return 22
|
||||
}
|
||||
release="${tag#v}"
|
||||
|
||||
@@ -133,12 +133,12 @@ fetch_and_deploy_gh() {
|
||||
|
||||
net_resolves api.github.com || {
|
||||
msg_error "DNS/network error"
|
||||
return 1
|
||||
return 6
|
||||
}
|
||||
need_tool curl jq tar || return 1
|
||||
need_tool curl jq tar || return 127
|
||||
[ "$mode" = "prebuild" ] || [ "$mode" = "singlefile" ] && need_tool unzip >/dev/null 2>&1 || true
|
||||
|
||||
tmpd="$(mktemp -d)" || return 1
|
||||
tmpd="$(mktemp -d)" || return 252
|
||||
mkdir -p "$target"
|
||||
|
||||
# Release JSON
|
||||
@@ -146,13 +146,13 @@ fetch_and_deploy_gh() {
|
||||
json="$(curl -fsSL "https://api.github.com/repos/$repo/releases/latest")" || {
|
||||
msg_error "GitHub API failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 22
|
||||
}
|
||||
else
|
||||
json="$(curl -fsSL "https://api.github.com/repos/$repo/releases/tags/$version")" || {
|
||||
msg_error "GitHub API failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 22
|
||||
}
|
||||
fi
|
||||
|
||||
@@ -163,7 +163,7 @@ fetch_and_deploy_gh() {
|
||||
[ -z "$version" ] && {
|
||||
msg_error "No tag in release json"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 65
|
||||
}
|
||||
|
||||
case "$mode" in
|
||||
@@ -173,26 +173,26 @@ fetch_and_deploy_gh() {
|
||||
filename="${app_lc}-${version}.tar.gz"
|
||||
download_with_progress "$url" "$tmpd/$filename" || {
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
tar -xzf "$tmpd/$filename" -C "$tmpd" || {
|
||||
msg_error "tar extract failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 251
|
||||
}
|
||||
unpack="$(find "$tmpd" -mindepth 1 -maxdepth 1 -type d | head -n1)"
|
||||
# copy content of unpack to target
|
||||
(cd "$unpack" && tar -cf - .) | (cd "$target" && tar -xf -) || {
|
||||
msg_error "copy failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
;;
|
||||
prebuild)
|
||||
[ -n "$pattern" ] || {
|
||||
msg_error "prebuild requires asset pattern"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 65
|
||||
}
|
||||
url="$(printf '%s' "$json" | jq -r '.assets[].browser_download_url' | awk -v p="$pattern" '
|
||||
BEGIN{IGNORECASE=1}
|
||||
@@ -201,19 +201,19 @@ fetch_and_deploy_gh() {
|
||||
[ -z "$url" ] && {
|
||||
msg_error "asset not found for pattern: $pattern"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
filename="${url##*/}"
|
||||
download_with_progress "$url" "$tmpd/$filename" || {
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
# unpack archive (Zip or tarball)
|
||||
case "$filename" in
|
||||
*.zip)
|
||||
need_tool unzip || {
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 127
|
||||
}
|
||||
mkdir -p "$tmpd/unp"
|
||||
unzip -q "$tmpd/$filename" -d "$tmpd/unp"
|
||||
@@ -225,7 +225,7 @@ fetch_and_deploy_gh() {
|
||||
*)
|
||||
msg_error "unsupported archive: $filename"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 251
|
||||
;;
|
||||
esac
|
||||
# top-level folder strippen
|
||||
@@ -234,13 +234,13 @@ fetch_and_deploy_gh() {
|
||||
(cd "$unpack" && tar -cf - .) | (cd "$target" && tar -xf -) || {
|
||||
msg_error "copy failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
else
|
||||
(cd "$tmpd/unp" && tar -cf - .) | (cd "$target" && tar -xf -) || {
|
||||
msg_error "copy failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
fi
|
||||
;;
|
||||
@@ -248,7 +248,7 @@ fetch_and_deploy_gh() {
|
||||
[ -n "$pattern" ] || {
|
||||
msg_error "singlefile requires asset pattern"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 65
|
||||
}
|
||||
url="$(printf '%s' "$json" | jq -r '.assets[].browser_download_url' | awk -v p="$pattern" '
|
||||
BEGIN{IGNORECASE=1}
|
||||
@@ -257,19 +257,19 @@ fetch_and_deploy_gh() {
|
||||
[ -z "$url" ] && {
|
||||
msg_error "asset not found for pattern: $pattern"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
filename="${url##*/}"
|
||||
download_with_progress "$url" "$target/$app" || {
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
chmod +x "$target/$app"
|
||||
;;
|
||||
*)
|
||||
msg_error "Unknown mode: $mode"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 65
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -291,20 +291,20 @@ setup_yq() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
need_tool curl || return 1
|
||||
need_tool curl || return 127
|
||||
local arch bin url tmp
|
||||
case "$(uname -m)" in
|
||||
x86_64) arch="amd64" ;;
|
||||
aarch64) arch="arm64" ;;
|
||||
*)
|
||||
msg_error "Unsupported arch for yq: $(uname -m)"
|
||||
return 1
|
||||
return 238
|
||||
;;
|
||||
esac
|
||||
url="https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${arch}"
|
||||
tmp="$(mktemp)"
|
||||
download_with_progress "$url" "$tmp" || return 1
|
||||
install -m 0755 "$tmp" /usr/local/bin/yq
|
||||
download_with_progress "$url" "$tmp" || return 250
|
||||
/usr/bin/install -m 0755 "$tmp" /usr/local/bin/yq
|
||||
rm -f "$tmp"
|
||||
msg_ok "Setup yq ($(yq --version 2>/dev/null))"
|
||||
}
|
||||
@@ -313,13 +313,13 @@ setup_yq() {
|
||||
# Adminer – Alpine
|
||||
# ------------------------------
|
||||
setup_adminer() {
|
||||
need_tool curl || return 1
|
||||
need_tool curl || return 127
|
||||
msg_info "Setup Adminer (Alpine)"
|
||||
mkdir -p /var/www/localhost/htdocs/adminer
|
||||
curl -fsSL https://github.com/vrana/adminer/releases/latest/download/adminer.php \
|
||||
-o /var/www/localhost/htdocs/adminer/index.php || {
|
||||
msg_error "Adminer download failed"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
msg_ok "Adminer at /adminer (served by your webserver)"
|
||||
}
|
||||
@@ -329,7 +329,7 @@ setup_adminer() {
|
||||
# optional: PYTHON_VERSION="3.12"
|
||||
# ------------------------------
|
||||
setup_uv() {
|
||||
need_tool curl tar || return 1
|
||||
need_tool curl tar || return 127
|
||||
local UV_BIN="/usr/local/bin/uv"
|
||||
local arch tarball url tmpd ver installed
|
||||
|
||||
@@ -338,7 +338,7 @@ setup_uv() {
|
||||
aarch64) arch="aarch64-unknown-linux-musl" ;;
|
||||
*)
|
||||
msg_error "Unsupported arch for uv: $(uname -m)"
|
||||
return 1
|
||||
return 238
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -346,7 +346,7 @@ setup_uv() {
|
||||
ver="${ver#v}"
|
||||
[ -z "$ver" ] && {
|
||||
msg_error "uv: cannot determine latest version"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
|
||||
if has "$UV_BIN"; then
|
||||
@@ -360,29 +360,29 @@ setup_uv() {
|
||||
msg_info "Setup uv $ver"
|
||||
fi
|
||||
|
||||
tmpd="$(mktemp -d)" || return 1
|
||||
tmpd="$(mktemp -d)" || return 252
|
||||
tarball="uv-${arch}.tar.gz"
|
||||
url="https://github.com/astral-sh/uv/releases/download/v${ver}/${tarball}"
|
||||
|
||||
download_with_progress "$url" "$tmpd/uv.tar.gz" || {
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
tar -xzf "$tmpd/uv.tar.gz" -C "$tmpd" || {
|
||||
msg_error "uv: extract failed"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 251
|
||||
}
|
||||
|
||||
# tar contains ./uv
|
||||
if [ -x "$tmpd/uv" ]; then
|
||||
install -m 0755 "$tmpd/uv" "$UV_BIN"
|
||||
/usr/bin/install -m 0755 "$tmpd/uv" "$UV_BIN"
|
||||
else
|
||||
# fallback: in subfolder
|
||||
install -m 0755 "$tmpd"/*/uv "$UV_BIN" 2>/dev/null || {
|
||||
/usr/bin/install -m 0755 "$tmpd"/*/uv "$UV_BIN" 2>/dev/null || {
|
||||
msg_error "uv binary not found in tar"
|
||||
rm -rf "$tmpd"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
fi
|
||||
rm -rf "$tmpd"
|
||||
@@ -395,13 +395,13 @@ setup_uv() {
|
||||
$0 ~ "^cpython-"maj"\\." { print $0 }' | awk -F- '{print $2}' | sort -V | tail -n1)"
|
||||
[ -z "$match" ] && {
|
||||
msg_error "No matching Python for $PYTHON_VERSION"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
if ! uv python list | grep -q "cpython-${match}-linux"; then
|
||||
msg_info "Installing Python $match via uv"
|
||||
uv python install "$match" || {
|
||||
msg_error "uv python install failed"
|
||||
return 1
|
||||
return 150
|
||||
}
|
||||
msg_ok "Python $match installed (uv)"
|
||||
fi
|
||||
@@ -421,7 +421,7 @@ setup_java() {
|
||||
msg_info "Setup Java (OpenJDK $JAVA_VERSION)"
|
||||
apk add --no-cache "$pkg" >/dev/null 2>&1 || {
|
||||
msg_error "apk add $pkg failed"
|
||||
return 1
|
||||
return 100
|
||||
}
|
||||
# set JAVA_HOME
|
||||
local prof="/etc/profile.d/20-java.sh"
|
||||
@@ -441,32 +441,32 @@ setup_go() {
|
||||
msg_info "Setup Go (apk)"
|
||||
apk add --no-cache go >/dev/null 2>&1 || {
|
||||
msg_error "apk add go failed"
|
||||
return 1
|
||||
return 100
|
||||
}
|
||||
msg_ok "Go ready: $(go version 2>/dev/null)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
need_tool curl tar || return 1
|
||||
need_tool curl tar || return 127
|
||||
local ARCH TARBALL URL TMP
|
||||
case "$(uname -m)" in
|
||||
x86_64) ARCH="amd64" ;;
|
||||
aarch64) ARCH="arm64" ;;
|
||||
*)
|
||||
msg_error "Unsupported arch for Go: $(uname -m)"
|
||||
return 1
|
||||
return 238
|
||||
;;
|
||||
esac
|
||||
TARBALL="go${GO_VERSION}.linux-${ARCH}.tar.gz"
|
||||
URL="https://go.dev/dl/${TARBALL}"
|
||||
msg_info "Setup Go $GO_VERSION (tarball)"
|
||||
TMP="$(mktemp)"
|
||||
download_with_progress "$URL" "$TMP" || return 1
|
||||
download_with_progress "$URL" "$TMP" || return 250
|
||||
rm -rf /usr/local/go
|
||||
tar -C /usr/local -xzf "$TMP" || {
|
||||
msg_error "extract go failed"
|
||||
rm -f "$TMP"
|
||||
return 1
|
||||
return 251
|
||||
}
|
||||
rm -f "$TMP"
|
||||
ln -sf /usr/local/go/bin/go /usr/local/bin/go
|
||||
@@ -488,7 +488,7 @@ setup_composer() {
|
||||
# Fallback to generic php if 83 not available
|
||||
apk add --no-cache php-cli php-openssl php-phar php-iconv >/dev/null 2>&1 || {
|
||||
msg_error "Failed to install php-cli for composer"
|
||||
return 1
|
||||
return 100
|
||||
}
|
||||
}
|
||||
msg_ok "PHP CLI ready: $(php -v | head -n1)"
|
||||
@@ -500,14 +500,14 @@ setup_composer() {
|
||||
msg_info "Setup Composer"
|
||||
fi
|
||||
|
||||
need_tool curl || return 1
|
||||
need_tool curl || return 127
|
||||
curl -fsSL https://getcomposer.org/installer -o /tmp/composer-setup.php || {
|
||||
msg_error "composer installer download failed"
|
||||
return 1
|
||||
return 250
|
||||
}
|
||||
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer >/dev/null 2>&1 || {
|
||||
msg_error "composer install failed"
|
||||
return 1
|
||||
return 150
|
||||
}
|
||||
rm -f /tmp/composer-setup.php
|
||||
ensure_usr_local_bin_persist
|
||||
|
||||
192
misc/build.func
192
misc/build.func
@@ -267,12 +267,12 @@ install_ssh_keys_into_ct() {
|
||||
msg_info "Installing selected SSH keys into CT ${CTID}"
|
||||
pct exec "$CTID" -- sh -c 'mkdir -p /root/.ssh && chmod 700 /root/.ssh' || {
|
||||
msg_error "prepare /root/.ssh failed"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
pct push "$CTID" "$SSH_KEYS_FILE" /root/.ssh/authorized_keys >/dev/null 2>&1 ||
|
||||
pct exec "$CTID" -- sh -c "cat > /root/.ssh/authorized_keys" <"$SSH_KEYS_FILE" || {
|
||||
msg_error "write authorized_keys failed"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
pct exec "$CTID" -- sh -c 'chmod 600 /root/.ssh/authorized_keys' || true
|
||||
msg_ok "Installed SSH keys into CT ${CTID}"
|
||||
@@ -839,7 +839,7 @@ choose_and_set_storage_for_file() {
|
||||
template) key="var_template_storage" ;;
|
||||
*)
|
||||
msg_error "Unknown storage class: $class"
|
||||
return 1
|
||||
return 65
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -862,7 +862,7 @@ choose_and_set_storage_for_file() {
|
||||
fi
|
||||
else
|
||||
# If the current value is preselectable, we could show it, but per your requirement we always offer selection
|
||||
select_storage "$class" || return 1
|
||||
select_storage "$class" || return 150
|
||||
fi
|
||||
|
||||
_write_storage_to_vars "$vf" "$key" "$STORAGE_RESULT"
|
||||
@@ -1264,7 +1264,7 @@ default_var_settings() {
|
||||
return 0
|
||||
}
|
||||
done
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
# Allow override of storages via env (for non-interactive use cases)
|
||||
[ -n "${var_template_storage:-}" ] && TEMPLATE_STORAGE="$var_template_storage"
|
||||
@@ -1357,7 +1357,7 @@ EOF
|
||||
local dv
|
||||
dv="$(_find_default_vars)" || {
|
||||
msg_error "default.vars not found after ensure step"
|
||||
return 1
|
||||
return 252
|
||||
}
|
||||
load_vars_file "$dv"
|
||||
|
||||
@@ -1642,7 +1642,7 @@ maybe_offer_save_app_defaults() {
|
||||
if whiptail --backtitle "Proxmox VE Helper Scripts" \
|
||||
--yesno "Save these advanced settings as defaults for ${APP}?\n\nThis will create:\n${app_vars_path}" 12 72; then
|
||||
mkdir -p "$(dirname "$app_vars_path")"
|
||||
install -m 0644 "$new_tmp" "$app_vars_path"
|
||||
/usr/bin/install -m 0644 "$new_tmp" "$app_vars_path"
|
||||
msg_ok "Saved app defaults: ${app_vars_path}"
|
||||
fi
|
||||
rm -f "$new_tmp" "$diff_tmp"
|
||||
@@ -1676,7 +1676,7 @@ maybe_offer_save_app_defaults() {
|
||||
|
||||
case "$sel" in
|
||||
"Update Defaults")
|
||||
install -m 0644 "$new_tmp" "$app_vars_path"
|
||||
/usr/bin/install -m 0644 "$new_tmp" "$app_vars_path"
|
||||
msg_ok "Updated app defaults: ${app_vars_path}"
|
||||
break
|
||||
;;
|
||||
@@ -4088,8 +4088,31 @@ https://dl-cdn.alpinelinux.org/alpine/latest-stable/main
|
||||
https://dl-cdn.alpinelinux.org/alpine/latest-stable/community
|
||||
EOF'
|
||||
pct exec "$CTID" -- ash -c "apk add bash newt curl openssh nano mc ncurses jq" >>"$BUILD_LOG" 2>&1 || {
|
||||
msg_error "Failed to install base packages in Alpine container"
|
||||
install_exit_code=1
|
||||
msg_warn "apk install failed (dl-cdn.alpinelinux.org), trying alternate mirrors..."
|
||||
local alpine_exit=0
|
||||
pct exec "$CTID" -- ash -c '
|
||||
ALPINE_MIRRORS="mirror.init7.net ftp.halifax.rwth-aachen.de mirrors.edge.kernel.org alpine.mirror.wearetriple.com mirror.leaseweb.com uk.alpinelinux.org dl-2.alpinelinux.org dl-4.alpinelinux.org"
|
||||
for m in $(printf "%s\n" $ALPINE_MIRRORS | shuf); do
|
||||
if wget -q --spider --timeout=2 "http://$m/alpine/latest-stable/main/" 2>/dev/null; then
|
||||
echo " Attempting mirror: $m"
|
||||
cat <<EOF >/etc/apk/repositories
|
||||
http://$m/alpine/latest-stable/main
|
||||
http://$m/alpine/latest-stable/community
|
||||
EOF
|
||||
if apk update >/dev/null 2>&1 && apk add bash newt curl openssh nano mc ncurses jq >/dev/null 2>&1; then
|
||||
echo " CDN set to $m: tests passed"
|
||||
exit 0
|
||||
else
|
||||
echo " Mirror $m failed"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
exit 2
|
||||
' && alpine_exit=0 || alpine_exit=$?
|
||||
if [[ $alpine_exit -ne 0 ]]; then
|
||||
msg_error "Failed to install base packages in Alpine container"
|
||||
install_exit_code=1
|
||||
fi
|
||||
}
|
||||
else
|
||||
sleep 3
|
||||
@@ -4115,9 +4138,140 @@ EOF'
|
||||
msg_warn "Skipping timezone setup – zone '$tz' not found in container"
|
||||
fi
|
||||
|
||||
# Detect broken DNS resolver (e.g. Tailscale MagicDNS) and inject public DNS
|
||||
if ! pct exec "$CTID" -- bash -c "getent hosts deb.debian.org >/dev/null 2>&1 && getent hosts archive.ubuntu.com >/dev/null 2>&1"; then
|
||||
msg_warn "APT repository DNS resolution failed in container, injecting public DNS servers"
|
||||
pct exec "$CTID" -- bash -c "echo -e 'nameserver 8.8.8.8\nnameserver 1.1.1.1' >/etc/resolv.conf"
|
||||
fi
|
||||
|
||||
pct exec "$CTID" -- bash -c "apt-get update 2>&1 && apt-get install -y sudo curl mc gnupg2 jq 2>&1" >>"$BUILD_LOG" 2>&1 || {
|
||||
msg_error "apt-get base packages installation failed"
|
||||
install_exit_code=1
|
||||
local failed_mirror
|
||||
failed_mirror=$(pct exec "$CTID" -- bash -c "grep -m1 -oP '(?<=URIs: https?://)[^/]+' /etc/apt/sources.list.d/debian.sources 2>/dev/null || grep -m1 -oP '(?<=deb https?://)[^/]+' /etc/apt/sources.list 2>/dev/null" 2>/dev/null || echo "unknown")
|
||||
msg_warn "apt-get update failed (${failed_mirror}), trying alternate mirrors..."
|
||||
local mirror_exit=0
|
||||
pct exec "$CTID" -- bash -c '
|
||||
APT_BASE="sudo curl mc gnupg2 jq"
|
||||
DISTRO=$(. /etc/os-release 2>/dev/null && echo "$ID" || echo "debian")
|
||||
|
||||
if [ "$DISTRO" = "ubuntu" ]; then
|
||||
EU_MIRRORS="de.archive.ubuntu.com fr.archive.ubuntu.com se.archive.ubuntu.com nl.archive.ubuntu.com it.archive.ubuntu.com ch.archive.ubuntu.com mirrors.xtom.de"
|
||||
US_MIRRORS="us.archive.ubuntu.com archive.ubuntu.com mirrors.edge.kernel.org mirror.csclub.uwaterloo.ca mirrors.ocf.berkeley.edu mirror.math.princeton.edu"
|
||||
AP_MIRRORS="au.archive.ubuntu.com jp.archive.ubuntu.com kr.archive.ubuntu.com tw.archive.ubuntu.com mirror.aarnet.edu.au"
|
||||
else
|
||||
EU_MIRRORS="ftp.de.debian.org ftp.fr.debian.org ftp.nl.debian.org ftp.uk.debian.org ftp.ch.debian.org ftp.se.debian.org ftp.it.debian.org ftp.fau.de ftp.halifax.rwth-aachen.de debian.mirror.lrz.de mirror.init7.net debian.ethz.ch mirrors.dotsrc.org debian.mirrors.ovh.net"
|
||||
US_MIRRORS="ftp.us.debian.org ftp.ca.debian.org debian.csail.mit.edu mirrors.ocf.berkeley.edu mirrors.wikimedia.org debian.osuosl.org mirror.cogentco.com"
|
||||
AP_MIRRORS="ftp.au.debian.org ftp.jp.debian.org ftp.tw.debian.org ftp.kr.debian.org ftp.hk.debian.org ftp.sg.debian.org mirror.aarnet.edu.au mirror.nitc.ac.in"
|
||||
fi
|
||||
|
||||
TZ=$(cat /etc/timezone 2>/dev/null || echo "UTC")
|
||||
case "$TZ" in
|
||||
Europe/*|Arctic/*) REGIONAL="$EU_MIRRORS"; OTHERS="$US_MIRRORS $AP_MIRRORS" ;;
|
||||
America/*) REGIONAL="$US_MIRRORS"; OTHERS="$EU_MIRRORS $AP_MIRRORS" ;;
|
||||
Asia/*|Australia/*|Pacific/*) REGIONAL="$AP_MIRRORS"; OTHERS="$EU_MIRRORS $US_MIRRORS" ;;
|
||||
*) REGIONAL=""; OTHERS="$EU_MIRRORS $US_MIRRORS $AP_MIRRORS" ;;
|
||||
esac
|
||||
|
||||
echo "Acquire::By-Hash \"no\";" >/etc/apt/apt.conf.d/99no-by-hash
|
||||
|
||||
try_mirrors() {
|
||||
for src in /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list; do
|
||||
[ -f "$src" ] && sed -i "s|URIs: http[s]*://[^/]*/|URIs: http://${1}/|g; s|deb http[s]*://[^/]*/|deb http://${1}/|g" "$src"
|
||||
done
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
APT_OUT=$(apt-get update 2>&1)
|
||||
APT_RC=$?
|
||||
if echo "$APT_OUT" | grep -qi "hashsum\|hash sum"; then
|
||||
echo " Mirror $1 failed (hash mismatch)"
|
||||
return 1
|
||||
elif echo "$APT_OUT" | grep -qi "SSL\|certificate"; then
|
||||
echo " Mirror $1 failed (SSL/certificate error)"
|
||||
return 1
|
||||
elif [ $APT_RC -ne 0 ]; then
|
||||
echo " Mirror $1 failed (apt-get update error)"
|
||||
return 1
|
||||
elif apt-get install -y $APT_BASE >/dev/null 2>&1; then
|
||||
echo " CDN set to $1: tests passed"
|
||||
return 0
|
||||
else
|
||||
echo " Mirror $1 failed (package install error)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
scan_reachable() {
|
||||
local result=""
|
||||
for m in $1; do
|
||||
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
||||
result="$result $m"
|
||||
fi
|
||||
done
|
||||
echo "$result" | xargs
|
||||
}
|
||||
|
||||
# Phase 1: Scan global mirrors first (independent of local CDN issues)
|
||||
OTHERS_OK=$(scan_reachable "$OTHERS")
|
||||
OTHERS_PICK=$(printf "%s\n" $OTHERS_OK | shuf | head -3 | xargs)
|
||||
|
||||
for mirror in $OTHERS_PICK; do
|
||||
echo " Attempting mirror: $mirror"
|
||||
try_mirrors "$mirror" && exit 0
|
||||
done
|
||||
|
||||
# Phase 2: Try primary mirror
|
||||
if [ "$DISTRO" = "ubuntu" ]; then
|
||||
PRIMARY="archive.ubuntu.com"
|
||||
else
|
||||
PRIMARY="ftp.debian.org"
|
||||
fi
|
||||
if timeout 2 bash -c "echo >/dev/tcp/$PRIMARY/80" 2>/dev/null; then
|
||||
echo " Attempting mirror: $PRIMARY"
|
||||
try_mirrors "$PRIMARY" && exit 0
|
||||
fi
|
||||
|
||||
# Phase 3: Fall back to regional mirrors
|
||||
REGIONAL_OK=$(scan_reachable "$REGIONAL")
|
||||
REGIONAL_PICK=$(printf "%s\n" $REGIONAL_OK | shuf | head -3 | xargs)
|
||||
|
||||
for mirror in $REGIONAL_PICK; do
|
||||
echo " Attempting mirror: $mirror"
|
||||
try_mirrors "$mirror" && exit 0
|
||||
done
|
||||
|
||||
exit 2
|
||||
' && mirror_exit=0 || mirror_exit=$?
|
||||
if [[ $mirror_exit -eq 2 ]]; then
|
||||
msg_warn "Multiple mirrors failed (possible CDN synchronization issue)."
|
||||
if [[ "$var_os" == "ubuntu" ]]; then
|
||||
msg_warn "Find Ubuntu mirrors at: https://launchpad.net/ubuntu/+archivemirrors"
|
||||
else
|
||||
msg_warn "Find Debian mirrors at: https://www.debian.org/mirror/list"
|
||||
fi
|
||||
local custom_mirror=""
|
||||
while true; do
|
||||
read -rp " Enter a mirror hostname (or 'skip' to abort): " custom_mirror </dev/tty
|
||||
[[ -z "$custom_mirror" ]] && continue
|
||||
[[ "$custom_mirror" == "skip" ]] && break
|
||||
[[ ! "$custom_mirror" =~ ^[a-zA-Z0-9._-]+$ ]] && {
|
||||
msg_warn "Invalid hostname format."
|
||||
continue
|
||||
}
|
||||
pct exec "$CTID" -- bash -c "
|
||||
for src in /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list; do
|
||||
[ -f \"\$src\" ] && sed -i \"s|URIs: http[s]*://[^/]*/|URIs: http://${custom_mirror}/|g; s|deb http[s]*://[^/]*/|deb http://${custom_mirror}/|g\" \"\$src\"
|
||||
done
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
apt-get update >/dev/null 2>&1 && apt-get install -y sudo curl mc gnupg2 jq >/dev/null 2>&1
|
||||
" && break
|
||||
msg_warn "Mirror '${custom_mirror}' also failed. Try another or type 'skip'."
|
||||
done
|
||||
if [[ "$custom_mirror" == "skip" ]]; then
|
||||
msg_error "apt-get base packages installation failed"
|
||||
install_exit_code=1
|
||||
fi
|
||||
elif [[ $mirror_exit -ne 0 ]]; then
|
||||
msg_error "apt-get base packages installation failed"
|
||||
install_exit_code=1
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
@@ -4690,7 +4844,7 @@ EOF'
|
||||
destroy_lxc() {
|
||||
if [[ -z "$CT_ID" ]]; then
|
||||
msg_error "No CT_ID found. Nothing to remove."
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
|
||||
# Abort on Ctrl-C / Ctrl-D / ESC
|
||||
@@ -4729,12 +4883,12 @@ resolve_storage_preselect() {
|
||||
case "$class" in
|
||||
template) required_content="vztmpl" ;;
|
||||
container) required_content="rootdir" ;;
|
||||
*) return 1 ;;
|
||||
*) return 65 ;;
|
||||
esac
|
||||
[[ -z "$preselect" ]] && return 1
|
||||
if ! pvesm status -content "$required_content" | awk 'NR>1{print $1}' | grep -qx -- "$preselect"; then
|
||||
msg_warn "Preselected storage '${preselect}' does not support content '${required_content}' (or not found)"
|
||||
return 1
|
||||
return 238
|
||||
fi
|
||||
|
||||
local line total used free
|
||||
@@ -4858,7 +5012,7 @@ select_storage() {
|
||||
;;
|
||||
*)
|
||||
msg_error "Invalid storage class '$CLASS'"
|
||||
return 1
|
||||
return 65
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -4940,7 +5094,7 @@ validate_storage_space() {
|
||||
# Check if storage exists and is active
|
||||
if [[ -z "$storage_line" ]]; then
|
||||
[[ "$show_dialog" == "yes" ]] && whiptail --msgbox "⚠️ Warning: Storage '$storage' not found!\n\nThe storage may be unavailable or disabled." 10 60
|
||||
return 2
|
||||
return 236
|
||||
fi
|
||||
|
||||
# Check storage status (column 3)
|
||||
@@ -4948,7 +5102,7 @@ validate_storage_space() {
|
||||
status=$(awk '{print $3}' <<<"$storage_line")
|
||||
if [[ "$status" == "disabled" ]]; then
|
||||
[[ "$show_dialog" == "yes" ]] && whiptail --msgbox "⚠️ Warning: Storage '$storage' is disabled!\n\nPlease enable the storage first." 10 60
|
||||
return 2
|
||||
return 236
|
||||
fi
|
||||
|
||||
# Get storage type and free space (column 6)
|
||||
@@ -4971,7 +5125,7 @@ validate_storage_space() {
|
||||
if [[ "$show_dialog" == "yes" ]]; then
|
||||
whiptail --msgbox "⚠️ Warning: Storage '$storage' may not have enough space!\n\nStorage Type: ${storage_type}\nRequired: ${required_gb}GB\nAvailable: ${free_gb_fmt}\n\nYou can continue, but creation might fail." 14 70
|
||||
fi
|
||||
return 1
|
||||
return 236
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
@@ -319,11 +319,11 @@ function setup_cloud_init() {
|
||||
if [ "$network_mode" = "static" ]; then
|
||||
if [ -n "$static_ip" ] && ! validate_ip_cidr "$static_ip"; then
|
||||
_ci_msg_error "Invalid static IP format: $static_ip (expected: x.x.x.x/xx)"
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
if [ -n "$gateway" ] && ! validate_ip "$gateway"; then
|
||||
_ci_msg_error "Invalid gateway IP format: $gateway"
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -433,7 +433,7 @@ function configure_cloud_init_interactive() {
|
||||
if ! command -v whiptail >/dev/null 2>&1; then
|
||||
echo "Warning: whiptail not available, skipping interactive configuration"
|
||||
export CLOUDINIT_ENABLE="no"
|
||||
return 1
|
||||
return 127
|
||||
fi
|
||||
|
||||
# Ask if user wants to enable Cloud-Init
|
||||
@@ -603,7 +603,7 @@ function get_vm_ip() {
|
||||
elapsed=$((elapsed + 2))
|
||||
done
|
||||
|
||||
return 1
|
||||
return 7
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -621,7 +621,7 @@ function wait_for_cloud_init() {
|
||||
|
||||
if [ -z "$vm_ip" ]; then
|
||||
_ci_msg_warn "Unable to determine VM IP address"
|
||||
return 1
|
||||
return 7
|
||||
fi
|
||||
|
||||
_ci_msg_info "Waiting for Cloud-Init to complete on ${vm_ip}"
|
||||
@@ -638,7 +638,7 @@ function wait_for_cloud_init() {
|
||||
done
|
||||
|
||||
_ci_msg_warn "Cloud-Init did not complete within ${timeout}s"
|
||||
return 1
|
||||
return 150
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
@@ -858,7 +858,7 @@ get_header() {
|
||||
if [ ! -s "$local_header_path" ]; then
|
||||
if ! curl -fsSL "$header_url" -o "$local_header_path"; then
|
||||
msg_warn "Failed to download header: $header_url"
|
||||
return 1
|
||||
return 250
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1358,7 +1358,7 @@ prompt_select() {
|
||||
if [[ $num_options -eq 0 ]]; then
|
||||
msg_warn "prompt_select called with no options"
|
||||
echo "" >&2
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
|
||||
# Validate default
|
||||
@@ -1600,7 +1600,7 @@ check_or_create_swap() {
|
||||
swap_size_mb=$(prompt_input "Enter swap size in MB (e.g., 2048 for 2GB):" "2048" 60)
|
||||
if ! [[ "$swap_size_mb" =~ ^[0-9]+$ ]]; then
|
||||
msg_error "Invalid swap size: '${swap_size_mb}' (must be a number in MB)"
|
||||
return 1
|
||||
return 65
|
||||
fi
|
||||
|
||||
local swap_file="/swapfile"
|
||||
@@ -1608,19 +1608,19 @@ check_or_create_swap() {
|
||||
msg_info "Creating ${swap_size_mb}MB swap file at $swap_file"
|
||||
if ! dd if=/dev/zero of="$swap_file" bs=1M count="$swap_size_mb" status=progress; then
|
||||
msg_error "Failed to allocate swap file (dd failed)"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
if ! chmod 600 "$swap_file"; then
|
||||
msg_error "Failed to set permissions on $swap_file"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
if ! mkswap "$swap_file"; then
|
||||
msg_error "Failed to format swap file (mkswap failed)"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
if ! swapon "$swap_file"; then
|
||||
msg_error "Failed to activate swap (swapon failed)"
|
||||
return 1
|
||||
return 150
|
||||
fi
|
||||
msg_ok "Swap file created and activated successfully"
|
||||
}
|
||||
@@ -1699,13 +1699,13 @@ function get_lxc_ip() {
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
return 6
|
||||
}
|
||||
|
||||
LOCAL_IP="$(get_current_ip || true)"
|
||||
if [[ -z "$LOCAL_IP" ]]; then
|
||||
msg_error "Could not determine LOCAL_IP (checked: eth0, hostname -I, ip route, IPv6 targets)"
|
||||
return 1
|
||||
return 6
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -210,6 +210,173 @@ network_check() {
|
||||
# SECTION 3: OS UPDATE & PACKAGE MANAGEMENT
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# apt_update_safe()
|
||||
#
|
||||
# - Runs apt-get update with CDN mirror fallback
|
||||
# - On failure, detects distro (Debian/Ubuntu) and tries alternate mirrors
|
||||
# - Three-phase approach: global mirrors → primary mirror → regional mirrors
|
||||
# - Falls back to manual user prompt if all auto mirrors fail
|
||||
# - Detects hash mismatch, SSL errors, and generic apt failures
|
||||
# ------------------------------------------------------------------------------
|
||||
apt_update_safe() {
|
||||
if $STD apt-get update; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local failed_mirror
|
||||
failed_mirror=$(grep -m1 -oP '(?<=URIs: https?://)[^/]+' /etc/apt/sources.list.d/debian.sources 2>/dev/null || grep -m1 -oP '(?<=deb https?://)[^/]+' /etc/apt/sources.list 2>/dev/null || echo "unknown")
|
||||
msg_warn "apt-get update failed (${failed_mirror}), trying alternate mirrors..."
|
||||
|
||||
local distro
|
||||
distro=$(. /etc/os-release 2>/dev/null && echo "$ID" || echo "debian")
|
||||
|
||||
local eu_mirrors us_mirrors ap_mirrors
|
||||
if [[ "$distro" == "ubuntu" ]]; then
|
||||
eu_mirrors="de.archive.ubuntu.com fr.archive.ubuntu.com se.archive.ubuntu.com nl.archive.ubuntu.com it.archive.ubuntu.com ch.archive.ubuntu.com mirrors.xtom.de"
|
||||
us_mirrors="us.archive.ubuntu.com archive.ubuntu.com mirrors.edge.kernel.org mirror.csclub.uwaterloo.ca mirrors.ocf.berkeley.edu mirror.math.princeton.edu"
|
||||
ap_mirrors="au.archive.ubuntu.com jp.archive.ubuntu.com kr.archive.ubuntu.com tw.archive.ubuntu.com mirror.aarnet.edu.au"
|
||||
else
|
||||
eu_mirrors="ftp.de.debian.org ftp.fr.debian.org ftp.nl.debian.org ftp.uk.debian.org ftp.ch.debian.org ftp.se.debian.org ftp.it.debian.org ftp.fau.de ftp.halifax.rwth-aachen.de debian.mirror.lrz.de mirror.init7.net debian.ethz.ch mirrors.dotsrc.org debian.mirrors.ovh.net"
|
||||
us_mirrors="ftp.us.debian.org ftp.ca.debian.org debian.csail.mit.edu mirrors.ocf.berkeley.edu mirrors.wikimedia.org debian.osuosl.org mirror.cogentco.com"
|
||||
ap_mirrors="ftp.au.debian.org ftp.jp.debian.org ftp.tw.debian.org ftp.kr.debian.org ftp.hk.debian.org ftp.sg.debian.org mirror.aarnet.edu.au mirror.nitc.ac.in"
|
||||
fi
|
||||
|
||||
local tz regional others
|
||||
tz=$(cat /etc/timezone 2>/dev/null || echo "UTC")
|
||||
case "$tz" in
|
||||
Europe/* | Arctic/*)
|
||||
regional="$eu_mirrors"
|
||||
others="$us_mirrors $ap_mirrors"
|
||||
;;
|
||||
America/*)
|
||||
regional="$us_mirrors"
|
||||
others="$eu_mirrors $ap_mirrors"
|
||||
;;
|
||||
Asia/* | Australia/* | Pacific/*)
|
||||
regional="$ap_mirrors"
|
||||
others="$eu_mirrors $us_mirrors"
|
||||
;;
|
||||
*)
|
||||
regional=""
|
||||
others="$eu_mirrors $us_mirrors $ap_mirrors"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo 'Acquire::By-Hash "no";' >/etc/apt/apt.conf.d/99no-by-hash
|
||||
|
||||
_try_apt_mirror() {
|
||||
local m=$1
|
||||
for src in /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list; do
|
||||
[[ -f "$src" ]] && sed -i "s|URIs: http[s]*://[^/]*/|URIs: http://${m}/|g; s|deb http[s]*://[^/]*/|deb http://${m}/|g" "$src"
|
||||
done
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
local out
|
||||
out=$(apt-get update 2>&1)
|
||||
if echo "$out" | grep -qi "hashsum\|hash sum"; then
|
||||
msg_warn "Mirror ${m} failed (hash mismatch)"
|
||||
return 1
|
||||
elif echo "$out" | grep -qi "SSL\|certificate"; then
|
||||
msg_warn "Mirror ${m} failed (SSL/certificate error)"
|
||||
return 1
|
||||
elif echo "$out" | grep -q "^E:"; then
|
||||
msg_warn "Mirror ${m} failed (apt-get update error)"
|
||||
return 1
|
||||
else
|
||||
msg_ok "CDN set to ${m}: tests passed"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
_scan_reachable() {
|
||||
local result=""
|
||||
for m in $1; do
|
||||
if timeout 2 bash -c "echo >/dev/tcp/$m/80" 2>/dev/null; then
|
||||
result="$result $m"
|
||||
fi
|
||||
done
|
||||
echo "$result" | xargs
|
||||
}
|
||||
|
||||
local apt_ok=false
|
||||
|
||||
# Phase 1: Scan global mirrors first (independent of local CDN issues)
|
||||
local others_ok
|
||||
others_ok=$(_scan_reachable "$others")
|
||||
local others_pick
|
||||
others_pick=$(printf '%s\n' $others_ok | shuf | head -3 | xargs)
|
||||
|
||||
for mirror in $others_pick; do
|
||||
msg_custom "${INFO}" "${YW}" "Attempting mirror: ${mirror}"
|
||||
if _try_apt_mirror "$mirror"; then
|
||||
apt_ok=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Phase 2: Try primary mirror
|
||||
if [[ "$apt_ok" != true ]]; then
|
||||
local primary
|
||||
if [[ "$distro" == "ubuntu" ]]; then
|
||||
primary="archive.ubuntu.com"
|
||||
else
|
||||
primary="ftp.debian.org"
|
||||
fi
|
||||
if timeout 2 bash -c "echo >/dev/tcp/$primary/80" 2>/dev/null; then
|
||||
msg_custom "${INFO}" "${YW}" "Attempting mirror: ${primary}"
|
||||
if _try_apt_mirror "$primary"; then
|
||||
apt_ok=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Phase 3: Fall back to regional mirrors
|
||||
if [[ "$apt_ok" != true ]]; then
|
||||
local regional_ok
|
||||
regional_ok=$(_scan_reachable "$regional")
|
||||
local regional_pick
|
||||
regional_pick=$(printf '%s\n' $regional_ok | shuf | head -3 | xargs)
|
||||
|
||||
for mirror in $regional_pick; do
|
||||
msg_custom "${INFO}" "${YW}" "Attempting mirror: ${mirror}"
|
||||
if _try_apt_mirror "$mirror"; then
|
||||
apt_ok=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Phase 4: All auto mirrors failed, prompt user
|
||||
if [[ "$apt_ok" != true ]]; then
|
||||
msg_warn "Multiple mirrors failed (possible CDN synchronization issue)."
|
||||
if [[ "$distro" == "ubuntu" ]]; then
|
||||
msg_warn "Find Ubuntu mirrors at: https://launchpad.net/ubuntu/+archivemirrors"
|
||||
else
|
||||
msg_warn "Find Debian mirrors at: https://www.debian.org/mirror/list"
|
||||
fi
|
||||
local custom_mirror
|
||||
while true; do
|
||||
read -rp " Enter a mirror hostname (or 'skip' to abort): " custom_mirror </dev/tty
|
||||
[[ -z "$custom_mirror" ]] && continue
|
||||
[[ "$custom_mirror" == "skip" ]] && break
|
||||
[[ ! "$custom_mirror" =~ ^[a-zA-Z0-9._-]+$ ]] && {
|
||||
msg_warn "Invalid hostname format."
|
||||
continue
|
||||
}
|
||||
if _try_apt_mirror "$custom_mirror"; then
|
||||
apt_ok=true
|
||||
break
|
||||
fi
|
||||
msg_warn "Mirror '${custom_mirror}' also failed. Try another or type 'skip'."
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$apt_ok" != true ]]; then
|
||||
msg_error "All mirrors failed. Check network or try again later."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# update_os()
|
||||
#
|
||||
|
||||
602
misc/tools.func
602
misc/tools.func
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@ get_header() {
|
||||
|
||||
if [ ! -s "$local_header_path" ]; then
|
||||
if ! curl -fsSL "$header_url" -o "$local_header_path"; then
|
||||
return 1
|
||||
return 250
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
173
tools/addon/sparkyfitness-garmin.sh
Normal file
173
tools/addon/sparkyfitness-garmin.sh
Normal file
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2026 community-scripts ORG
|
||||
# Author: Tom Frenzel (tomfrenzel)
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://github.com/CodeWithCJ/SparkyFitness
|
||||
|
||||
if ! command -v curl &>/dev/null; then
|
||||
printf "\r\e[2K%b" '\033[93m Setup Source \033[m' >&2
|
||||
apt-get update >/dev/null 2>&1
|
||||
apt-get install -y curl >/dev/null 2>&1
|
||||
fi
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 2>/dev/null || true
|
||||
declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "sparkyfitness-garmin" "addon"
|
||||
|
||||
# Enable error handling
|
||||
set -Eeuo pipefail
|
||||
trap 'error_handler' ERR
|
||||
load_functions
|
||||
|
||||
# ==============================================================================
|
||||
# CONFIGURATION
|
||||
# ==============================================================================
|
||||
APP="SparkyFitness Garmin Microservice"
|
||||
APP_TYPE="addon"
|
||||
INSTALL_PATH="/opt/sparkyfitness-garmin"
|
||||
CONFIG_PATH="/etc/sparkyfitness-garmin/.env"
|
||||
SERVICE_PATH="/etc/systemd/system/sparkyfitness-garmin.service"
|
||||
DEFAULT_PORT=8000
|
||||
|
||||
# ==============================================================================
|
||||
# OS DETECTION
|
||||
# ==============================================================================
|
||||
if ! grep -qE 'ID=debian|ID=ubuntu' /etc/os-release 2>/dev/null; then
|
||||
echo -e "${CROSS} Unsupported OS detected. This script only supports Debian and Ubuntu."
|
||||
exit 238
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# SparkyFitness LXC DETECTION
|
||||
# ==============================================================================
|
||||
if [[ ! -d /opt/sparkyfitness ]]; then
|
||||
echo -e "${CROSS} No SparkyFitness installation detected. This addon must be installed within a container that already has SparkyFitness installed."
|
||||
exit 238
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# UNINSTALL
|
||||
# ==============================================================================
|
||||
function uninstall() {
|
||||
msg_info "Uninstalling ${APP}"
|
||||
systemctl disable --now sparkyfitness-garmin.service &>/dev/null || true
|
||||
rm -rf "$SERVICE_PATH" "$CONFIG_PATH" "$INSTALL_PATH" ~/.sparkyfitness-garmin
|
||||
msg_ok "${APP} has been uninstalled"
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# UPDATE
|
||||
# ==============================================================================
|
||||
function update() {
|
||||
if check_for_gh_release "sparkyfitness-garmin" "CodeWithCJ/SparkyFitness"; then
|
||||
PYTHON_VERSION="3.13" setup_uv
|
||||
|
||||
msg_info "Stopping service"
|
||||
systemctl stop sparkyfitness-garmin.service &>/dev/null || true
|
||||
msg_ok "Stopped service"
|
||||
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "sparkyfitness-garmin" "CodeWithCJ/SparkyFitness" "tarball" "latest" $INSTALL_PATH
|
||||
|
||||
msg_info "Starting service"
|
||||
systemctl start sparkyfitness-garmin
|
||||
msg_ok "Started service"
|
||||
msg_ok "Updated successfully"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# INSTALL
|
||||
# ==============================================================================
|
||||
function install() {
|
||||
PYTHON_VERSION="3.13" setup_uv
|
||||
fetch_and_deploy_gh_release "sparkyfitness-garmin" "CodeWithCJ/SparkyFitness" "tarball" "latest" $INSTALL_PATH
|
||||
|
||||
msg_info "Setting up ${APP}"
|
||||
mkdir -p "/etc/sparkyfitness-garmin"
|
||||
cp "/opt/sparkyfitness-garmin/docker/.env.example" $CONFIG_PATH
|
||||
cd $INSTALL_PATH/SparkyFitnessGarmin
|
||||
$STD uv venv --clear .venv
|
||||
$STD uv pip install -r requirements.txt
|
||||
sed -i -e "s|^#\?GARMIN_MICROSERVICE_URL=.*|GARMIN_MICROSERVICE_URL=http://${LOCAL_IP}:${DEFAULT_PORT}|" $CONFIG_PATH
|
||||
cat <<EOF >/etc/systemd/system/sparkyfitness-garmin.service
|
||||
[Unit]
|
||||
Description=${APP}
|
||||
After=network.target sparkyfitness-server.service
|
||||
Requires=sparkyfitness-server.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=$INSTALL_PATH/SparkyFitnessGarmin
|
||||
EnvironmentFile=$CONFIG_PATH
|
||||
ExecStart=$INSTALL_PATH/SparkyFitnessGarmin/.venv/bin/python3 -m uvicorn main:app --host 0.0.0.0 --port ${DEFAULT_PORT}
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now sparkyfitness-garmin
|
||||
msg_ok "Set up ${APP} - reachable at http://${LOCAL_IP}:${DEFAULT_PORT}"
|
||||
msg_ok "You might need to update the GARMIN_MICROSERVICE_URL in your SparkyFitness .env file to http://${LOCAL_IP}:${DEFAULT_PORT}"
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# MAIN
|
||||
# ==============================================================================
|
||||
header_info
|
||||
ensure_usr_local_bin_persist
|
||||
get_lxc_ip
|
||||
|
||||
# Handle type=update (called from update script)
|
||||
if [[ "${type:-}" == "update" ]]; then
|
||||
if [[ -d "$INSTALL_PATH" ]]; then
|
||||
update
|
||||
else
|
||||
msg_error "${APP} is not installed. Nothing to update."
|
||||
exit 233
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if already installed
|
||||
if [[ -d "$INSTALL_PATH" && -n "$(ls -A "$INSTALL_PATH" 2>/dev/null)" ]]; then
|
||||
msg_warn "${APP} is already installed."
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Uninstall ${APP}? (y/N): "
|
||||
read -r uninstall_prompt
|
||||
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
uninstall
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "${TAB}Update ${APP}? (y/N): "
|
||||
read -r update_prompt
|
||||
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
update
|
||||
exit 0
|
||||
fi
|
||||
|
||||
msg_warn "No action selected. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fresh installation
|
||||
msg_warn "${APP} is not installed."
|
||||
echo ""
|
||||
echo -e "${TAB}${INFO} This will install:"
|
||||
echo -e "${TAB} - UV (Python Version Manager)"
|
||||
echo -e "${TAB} - SparkyFitness Garmin Microservice"
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Install ${APP}? (y/N): "
|
||||
read -r install_prompt
|
||||
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
install
|
||||
else
|
||||
msg_warn "Installation cancelled. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
6
tools/headers/sparkyfitnessgarmin
Normal file
6
tools/headers/sparkyfitnessgarmin
Normal file
@@ -0,0 +1,6 @@
|
||||
_____ __ _______ __ ______ _ __ ____ _
|
||||
/ ___/____ ____ ______/ /____ __/ ____(_) /_____ ___ __________ / ____/___ __________ ___ (_)___ / |/ (_)_____________ ________ ______ __(_)_______
|
||||
\__ \/ __ \/ __ `/ ___/ //_/ / / / /_ / / __/ __ \/ _ \/ ___/ ___/ / / __/ __ `/ ___/ __ `__ \/ / __ \ / /|_/ / / ___/ ___/ __ \/ ___/ _ \/ ___/ | / / / ___/ _ \
|
||||
___/ / /_/ / /_/ / / / ,< / /_/ / __/ / / /_/ / / / __(__ |__ ) / /_/ / /_/ / / / / / / / / / / / / / / / / / /__/ / / /_/ (__ ) __/ / | |/ / / /__/ __/
|
||||
/____/ .___/\__,_/_/ /_/|_|\__, /_/ /_/\__/_/ /_/\___/____/____/ \____/\__,_/_/ /_/ /_/ /_/_/_/ /_/ /_/ /_/_/\___/_/ \____/____/\___/_/ |___/_/\___/\___/
|
||||
/_/ /____/
|
||||
Reference in New Issue
Block a user