43d043a9cd
* initial commit - add prereqs install script * add env vars prompt * automate latest binary url env var * add install node script * add modes to nym-node install script * start main cli framework * adding branch var for easier deployment and testing * add systemd config * add proxy and wss setup script * add landing page stub and fix nginx script * add nginx setup * fix typo * add checks for existing dir and wg prompt * add nginx commands * add service file check * add service file check * convention alignment * add checks to nginx setup * cleanup old code * add bonding prompt and nym node run fns * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * fix syntax * add service script to init * fix syntax * fix syntax * add chmod * fix script logic * syntax fix * syntax fix * silent mode trial * fix evn prompt script * make scripts interactive * indent fix * correct node-install script * initial mixnode setup working - gws need more love * fix bonding function * syntax fix * improve run noide as service script * improve service script * improve run service fn * fix logic * beautify * beautify * create run node as service script * syntax fix * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * attempt to resolve memory running out issue * setting wireguard * solved memory issues * rename landing page template * modify wireguard enabled fn * layout change * syntax fix * modify node setup script * sync up envs * return missing function * fix urls * fix network manager script execution * fix wss and nginx * fix layout * tweak WG contion * syntax fix * add init placeholder * syntax fix * redefine wireguard check logic * check if node exists * add argparse and dev option * styling * add panic * add error message * improve logic * improve logic * add arg * add dev arg for all levels * add confirmation loop * styling * fix bonding question * syntax edit * syntax edit * syntax edit * refactor for already bonded nodes * add default branch on top and define metavar * fix node install script * clean and prepare for review * indentation fix * fix nginx setup * fix nginx setup * style cleanup * fix try error logic * tune --dev option to run before command correctly * fix y/n convention across the modules * add explorer URL to the message * minor layout fixes
56 lines
1.8 KiB
Bash
56 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
# start_node_systemd_service_sh (control script)
|
|
set -euo pipefail
|
|
|
|
SERVICE="nym-node.service"
|
|
export SYSTEMD_PAGER=""
|
|
export SYSTEMD_COLORS="0"
|
|
SYSTEMCTL="systemctl --no-ask-password --quiet"
|
|
WAIT_TIMEOUT="${WAIT_TIMEOUT:-600}" # seconds
|
|
|
|
reload_and_reset() { $SYSTEMCTL daemon-reload || true; $SYSTEMCTL reset-failed "$SERVICE" || true; }
|
|
|
|
wait_until_active_or_fail() {
|
|
local deadline=$(( $(date +%s) + WAIT_TIMEOUT ))
|
|
local last=""
|
|
while [ "$(date +%s)" -lt "$deadline" ]; do
|
|
local active sub result
|
|
active="$(systemctl show -p ActiveState --value "$SERVICE" 2>/dev/null || echo unknown)"
|
|
sub="$(systemctl show -p SubState --value "$SERVICE" 2>/dev/null || echo unknown)"
|
|
result="$(systemctl show -p Result --value "$SERVICE" 2>/dev/null || echo unknown)"
|
|
local cur="${active}/${sub}/${result}"
|
|
if [ "$cur" != "$last" ]; then
|
|
echo "state: ActiveState=${active} SubState=${sub} Result=${result}"
|
|
last="$cur"
|
|
fi
|
|
[ "$active" = "active" ] && return 0
|
|
if [ "$active" = "failed" ] || [ "$result" = "failed" ] || [ "$result" = "exit-code" ] || [ "$result" = "timeout" ]; then
|
|
return 1
|
|
fi
|
|
sleep 1
|
|
done
|
|
echo "timeout: ${WAIT_TIMEOUT}s exceeded while waiting for ${SERVICE}"
|
|
return 1
|
|
}
|
|
|
|
restart_poll() {
|
|
reload_and_reset
|
|
echo "Restarting $SERVICE (non-blocking) and polling up to ${WAIT_TIMEOUT}s..."
|
|
systemctl --no-ask-password restart --no-block "$SERVICE"
|
|
wait_until_active_or_fail
|
|
}
|
|
|
|
start_poll() {
|
|
reload_and_reset
|
|
echo "Starting $SERVICE (non-blocking) and polling up to ${WAIT_TIMEOUT}s..."
|
|
systemctl --no-ask-password start --no-block "$SERVICE"
|
|
wait_until_active_or_fail
|
|
}
|
|
|
|
case "${1:-}" in
|
|
restart-poll) restart_poll ;;
|
|
start-poll) start_poll ;;
|
|
*) echo "Usage: $0 {start-poll|restart-poll}"; exit 2 ;;
|
|
esac
|