|
@@ -1,6 +1,8 @@
|
|
|
#!/usr/bin/env bash
|
|
#!/usr/bin/env bash
|
|
|
set -Eeuo pipefail
|
|
set -Eeuo pipefail
|
|
|
umask 077
|
|
umask 077
|
|
|
|
|
+export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
|
+if [[ -d /opt/debtik/go/bin ]]; then export PATH=/opt/debtik/go/bin:$PATH; fi
|
|
|
# Transient systemd units may omit HOME; Go needs explicit cache locations.
|
|
# Transient systemd units may omit HOME; Go needs explicit cache locations.
|
|
|
export HOME=${HOME:-/root}
|
|
export HOME=${HOME:-/root}
|
|
|
export GOPATH=${GOPATH:-/var/cache/debtik/go}
|
|
export GOPATH=${GOPATH:-/var/cache/debtik/go}
|
|
@@ -39,11 +41,12 @@ restore() {
|
|
|
cp -p "$base/previous/$name" "/usr/local/bin/$name.rollback"
|
|
cp -p "$base/previous/$name" "/usr/local/bin/$name.rollback"
|
|
|
mv -f "/usr/local/bin/$name.rollback" "/usr/local/bin/$name"
|
|
mv -f "/usr/local/bin/$name.rollback" "/usr/local/bin/$name"
|
|
|
done
|
|
done
|
|
|
- for name in debtik-update debtik-release-version; do
|
|
|
|
|
|
|
+ for name in debtik-update debtik-release-version debtik-install-dependencies; do
|
|
|
if [[ -f "$base/previous/$name" ]]; then install -m 0750 "$base/previous/$name" "/usr/local/libexec/$name.rollback"; mv -f "/usr/local/libexec/$name.rollback" "/usr/local/libexec/$name"; fi
|
|
if [[ -f "$base/previous/$name" ]]; then install -m 0750 "$base/previous/$name" "/usr/local/libexec/$name.rollback"; mv -f "/usr/local/libexec/$name.rollback" "/usr/local/libexec/$name"; fi
|
|
|
done
|
|
done
|
|
|
if [[ -f "$base/previous_commit" ]]; then cp -p "$base/previous_commit" "$base/installed_commit"; fi
|
|
if [[ -f "$base/previous_commit" ]]; then cp -p "$base/previous_commit" "$base/installed_commit"; fi
|
|
|
if [[ -f "$base/previous_version" ]]; then cp -p "$base/previous_version" "$base/installed_version"; fi
|
|
if [[ -f "$base/previous_version" ]]; then cp -p "$base/previous_version" "$base/installed_version"; fi
|
|
|
|
|
+ if [[ -f "$base/previous/go.mod" ]]; then cp -p "$base/previous/go.mod" "$base/go.mod"; fi
|
|
|
systemctl start proxmox-router.service
|
|
systemctl start proxmox-router.service
|
|
|
systemctl is-active --quiet proxmox-router.service
|
|
systemctl is-active --quiet proxmox-router.service
|
|
|
if [[ -f "$base/previous/iptables.save" ]]; then iptables-restore -c < "$base/previous/iptables.save"; fi
|
|
if [[ -f "$base/previous/iptables.save" ]]; then iptables-restore -c < "$base/previous/iptables.save"; fi
|
|
@@ -77,7 +80,11 @@ cd "$work/source"
|
|
|
commit=$(git rev-parse HEAD)
|
|
commit=$(git rev-parse HEAD)
|
|
|
[[ $(cat VERSION) == "$version" ]] || { state failed; echo 'Release tag and VERSION do not match'; exit 1; }
|
|
[[ $(cat VERSION) == "$version" ]] || { state failed; echo 'Release tag and VERSION do not match'; exit 1; }
|
|
|
bash -n scripts/debtik-update
|
|
bash -n scripts/debtik-update
|
|
|
|
|
+bash -n scripts/install-dependencies.sh
|
|
|
|
|
+bash -n install.sh
|
|
|
python3 -c 'import pathlib; compile(pathlib.Path("scripts/release-version.py").read_text(),"release-version.py","exec")'
|
|
python3 -c 'import pathlib; compile(pathlib.Path("scripts/release-version.py").read_text(),"release-version.py","exec")'
|
|
|
|
|
+state dependencies
|
|
|
|
|
+bash scripts/install-dependencies.sh
|
|
|
state building
|
|
state building
|
|
|
go_cmd=$(command -v go || true)
|
|
go_cmd=$(command -v go || true)
|
|
|
if [[ -x /opt/debtik/go/bin/go ]]; then go_cmd=/opt/debtik/go/bin/go; fi
|
|
if [[ -x /opt/debtik/go/bin/go ]]; then go_cmd=/opt/debtik/go/bin/go; fi
|
|
@@ -86,9 +93,13 @@ CGO_ENABLED=0 "$go_cmd" build -trimpath -ldflags "-X proxmox-router/internal/api
|
|
|
CGO_ENABLED=0 "$go_cmd" build -trimpath -o "$work/debtik-cli" ./cmd/debtik-cli
|
|
CGO_ENABLED=0 "$go_cmd" build -trimpath -o "$work/debtik-cli" ./cmd/debtik-cli
|
|
|
install -d -m 0700 "$base/previous"
|
|
install -d -m 0700 "$base/previous"
|
|
|
for name in proxmox-router debtik-cli; do cp -p "/usr/local/bin/$name" "$base/previous/$name"; done
|
|
for name in proxmox-router debtik-cli; do cp -p "/usr/local/bin/$name" "$base/previous/$name"; done
|
|
|
-for name in debtik-update debtik-release-version; do cp -p "/usr/local/libexec/$name" "$base/previous/$name"; done
|
|
|
|
|
|
|
+for name in debtik-update debtik-release-version debtik-install-dependencies; do
|
|
|
|
|
+ if [[ -f "/usr/local/libexec/$name" ]]; then cp -p "/usr/local/libexec/$name" "$base/previous/$name"; fi
|
|
|
|
|
+done
|
|
|
cp -p "$base/installed_version" "$base/previous_version"
|
|
cp -p "$base/installed_version" "$base/previous_version"
|
|
|
if [[ -f "$base/installed_commit" ]]; then cp -p "$base/installed_commit" "$base/previous_commit"; fi
|
|
if [[ -f "$base/installed_commit" ]]; then cp -p "$base/installed_commit" "$base/previous_commit"; fi
|
|
|
|
|
+if [[ -f "$base/go.mod" ]]; then cp -p "$base/go.mod" "$base/previous/go.mod"; fi
|
|
|
|
|
+install -m 0644 go.mod "$base/go.mod"
|
|
|
printf '%s\n' "$commit" > "$base/candidate_commit"
|
|
printf '%s\n' "$commit" > "$base/candidate_commit"
|
|
|
iptables-save -c > "$base/previous/iptables.save"
|
|
iptables-save -c > "$base/previous/iptables.save"
|
|
|
ip6tables-save -c > "$base/previous/ip6tables.save"
|
|
ip6tables-save -c > "$base/previous/ip6tables.save"
|
|
@@ -103,8 +114,10 @@ for name in proxmox-router debtik-cli; do
|
|
|
done
|
|
done
|
|
|
install -m 0750 scripts/debtik-update /usr/local/libexec/debtik-update.next
|
|
install -m 0750 scripts/debtik-update /usr/local/libexec/debtik-update.next
|
|
|
install -m 0750 scripts/release-version.py /usr/local/libexec/debtik-release-version.next
|
|
install -m 0750 scripts/release-version.py /usr/local/libexec/debtik-release-version.next
|
|
|
|
|
+install -m 0750 scripts/install-dependencies.sh /usr/local/libexec/debtik-install-dependencies.next
|
|
|
mv -f /usr/local/libexec/debtik-update.next /usr/local/libexec/debtik-update
|
|
mv -f /usr/local/libexec/debtik-update.next /usr/local/libexec/debtik-update
|
|
|
mv -f /usr/local/libexec/debtik-release-version.next /usr/local/libexec/debtik-release-version
|
|
mv -f /usr/local/libexec/debtik-release-version.next /usr/local/libexec/debtik-release-version
|
|
|
|
|
+mv -f /usr/local/libexec/debtik-install-dependencies.next /usr/local/libexec/debtik-install-dependencies
|
|
|
systemctl start proxmox-router.service
|
|
systemctl start proxmox-router.service
|
|
|
sleep 3
|
|
sleep 3
|
|
|
systemctl is-active --quiet proxmox-router.service
|
|
systemctl is-active --quiet proxmox-router.service
|