ncp-update-nc: fix update termination detection

Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
Tobias Knöppler 2024-08-18 17:04:12 +02:00
parent eea3d51385
commit 1fb070df55
No known key found for this signature in database
GPG Key ID: 3510056072886A8F
3 changed files with 30 additions and 6 deletions

View File

@ -23,19 +23,42 @@ BIN="${0##*/}"
VER="$1"
[[ "$VER" == "" ]] && { echo "Usage ${BIN} <version>"; exit 1; }
if systemctl is-active ncp-update-nc >/dev/null 2>&1
connect_to_nc_update() {
tail -f "/var/log/ncp-update-nc.log" &
tail_pid=$!
while [[ "$(systemctl is-active ncp-update-nc ||:)" == "active" ]]
do
sleep 3
done
kill "$tail_pid"
if [[ "$(systemctl is-active ncp-update-nc ||:)" == "inactive" ]]
then
echo "Nextcloud update finished successfully."
return 0
elif [[ "$(systemctl is-active ncp-update-nc ||:)" == "failed" ]]
then
echo "Nextcloud update failed."
return 1
else
echo "Nextcloud update was not found or failed (unexpected status: '$(systemctl is-active ncp-update-nc ||:)')"
fi
}
if [[ "$(systemctl is-active ncp-update-nc ||:)" == "activating" ]]
then
echo "Existing ncp-update-nc process detected. Connecting..."
tail -f "/var/log/ncp-update-nc.log"
connect_to_nc_update
exit 0
fi
systemd-run -u 'ncp-update-nc' -p "RemainAfterExit=yes" bash -c "DBG='${DBG:-}' /usr/local/bin/ncp-update-nc.d/update-nc.sh '${VER}' |& tee /var/log/ncp-update-nc.log"
systemd-run -u 'ncp-update-nc' bash -c "DBG='${DBG:-}' /usr/local/bin/ncp-update-nc.d/update-nc.sh '${VER}' |& tee /var/log/ncp-update-nc.log"
sleep 5
if ! systemctl is-active ncp-update-nc >/dev/null 2>&1
if [[ "$(systemctl is-active ncp-update-nc ||:)" != "activating" ]]
then
echo "Failed to start ncp-update-nc"
systemctl status --no-pager ncp-update-nc
fi
tail -f "/var/log/ncp-update-nc.log"
connect_to_nc_update

View File

@ -0,0 +1 @@
v24.08

View File

@ -31,7 +31,7 @@ prepare_dirs # tmp cache output
# get latest armbian
[[ -d armbian ]] || {
git clone --depth 1 --branch v24.08 https://github.com/armbian/build armbian
git clone --depth 1 --branch "$(cat "${0}/../armbian/armbian_version")" https://github.com/armbian/build armbian
}
#( cd armbian && git pull --ff-only --tags && git checkout v23.02 )
#sed -i -e '/export rootfs_size=/s/du -sm/du --apparent-size -sm/' armbian/lib/functions/image/partitioning.sh