WIP Install / Start /Stop

This commit is contained in:
John Haverlack 2026-02-04 20:30:27 -09:00
parent ee3b315a98
commit 0b5960f61e
4 changed files with 34 additions and 40 deletions

View File

@ -56,11 +56,8 @@ resolve_dirs() {
use_systemd() { use_systemd() {
# Check if systemd user mode is available and service exists # Check if systemd user mode is available and service exists
if systemctl --user status >/dev/null 2>&1; then if systemctl --user status >/dev/null 2>&1; then
# Check if our service file exists
if systemctl --user list-unit-files | grep -q "^sdl-mgr.service"; then
return 0 # Use systemd return 0 # Use systemd
fi fi
fi
return 1 # Use manual scripts return 1 # Use manual scripts
} }
@ -79,7 +76,7 @@ fi
# ------------------------------------------------------------ # ------------------------------------------------------------
# Requirements # Requirements
# ------------------------------------------------------------ # ------------------------------------------------------------
for cmd in awk curl grep jq sed sha256sum tar unzip; do for cmd in awk curl grep jq nc sed sha256sum tar unzip; do
command -v "$cmd" >/dev/null || { command -v "$cmd" >/dev/null || {
echo "ERROR: $cmd is required" echo "ERROR: $cmd is required"
exit 1 exit 1
@ -170,13 +167,8 @@ fi
# ------------------------------------------------------------ # ------------------------------------------------------------
# systemd user service check # Setting SDL variables
# ------------------------------------------------------------ # ------------------------------------------------------------
if ! systemctl --user status >/dev/null 2>&1; then
echo "ERROR: systemd user services are not available"
echo " SDL requires systemd --user support"
exit 1
fi
SDL_VERSION="$(jq -r '.METADATA.version' "$META_FILE")" SDL_VERSION="$(jq -r '.METADATA.version' "$META_FILE")"
SDL_VERSION_DATE="$(jq -r '.METADATA.version_date' "$META_FILE")" SDL_VERSION_DATE="$(jq -r '.METADATA.version_date' "$META_FILE")"
@ -398,46 +390,48 @@ $NPM_BIN install
# ------------------------------------------------------------ # ------------------------------------------------------------
# Copy Start / Stop Scripts # Copy Start / Stop Scripts
# ------------------------------------------------------------ # ------------------------------------------------------------
mkdir -p "$SDL_HOME/scripts/"
cp "$SDL_MGR/current/scripts/start-sdl-mgr.sh" "$SDL_HOME/scripts/" cp "$SDL_MGR/current/scripts/start-sdl-mgr.sh" "$SDL_HOME/scripts/"
cp "$SDL_MGR/current/scripts/stop-sdl-mgr.sh" "$SDL_HOME/scripts/" cp "$SDL_MGR/current/scripts/stop-sdl-mgr.sh" "$SDL_HOME/scripts/"
cp "$SDL_MGR/current/scripts/status-sdl-mgr.sh" "$SDL_HOME/scripts/" cp "$SDL_MGR/current/scripts/status-sdl-mgr.sh" "$SDL_HOME/scripts/"
chmod u+x "$SDL_HOME/scripts/"*
# ------------------------------------------------------------ # ------------------------------------------------------------
# Install Systemd Unit Files # Install Systemd Unit Files
# Copy SDL_MGR/current/scripts/sdl-mgr.service to ~/.config/systemd/user # Copy SDL_MGR/current/scripts/sdl-mgr.service to ~/.config/systemd/user
# ------------------------------------------------------------ # ------------------------------------------------------------
echo "" if use_systemd; then
echo "Installing SystemD Unit Files" echo ""
echo "Installing SystemD Unit Files"
mkdir -p ~/.config/systemd/user
cp "$SDL_MGR/current/scripts/sdl-mgr.service" ~/.config/systemd/user/
mkdir -p ~/.config/systemd/user
cp "$SDL_MGR/current/scripts/sdl-mgr.service" ~/.config/systemd/user/
"${SDL_HOME}/scripts/stop-sdl-mgr.sh"
sleep 1
systemctl --user daemon-reload --no-pager
fi
# ------------------------------------------------------------ # ------------------------------------------------------------
# Start SDL Manager # Start SDL Manager
# ------------------------------------------------------------ # ------------------------------------------------------------
systemctl --user stop sdl-mgr --no-pager "${SDL_HOME}/scripts/start-sdl-mgr.sh"
sleep 2 sleep 2
systemctl --user daemon-reload --no-pager "${SDL_HOME}/scripts/status-sdl-mgr.sh"
systemctl --user restart sdl-mgr --no-pager
sleep 3 if [ $? -ne 0 ]; then
systemctl --user status sdl-mgr --no-pager echo ""
echo "ERROR: SDL Manager failed to start"
exit 1
fi
#
echo "" echo ""
echo "SDL Manager deployed:" echo "SDL Manager deployed:"
echo " to: $SDL_HOME" echo " to: $SDL_HOME"
echo "SDL Controls:"
echo " systemctl --user status sdl-mgr"
echo " systemctl --user start sdl-mgr"
echo " systemctl --user stop sdl-mgr"
echo ""
echo "Removal Commands:"
echo " WARNING: Backup data directory first!!!!"
echo " systemctl --user disable sdl-mgr"
echo " rm -rf $SDL_HOME"

View File

@ -6,7 +6,7 @@ use_systemd() {
# Check if systemd user mode is available and service exists # Check if systemd user mode is available and service exists
if systemctl --user status >/dev/null 2>&1; then if systemctl --user status >/dev/null 2>&1; then
# Check if our service file exists # Check if our service file exists
if systemctl --user list-unit-files | grep -q "^sdl-mgr.service"; then if systemctl --user list-unit-files | grep -q "^sdl-wkr.service"; then
return 0 # Use systemd return 0 # Use systemd
fi fi
fi fi

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# status-sdl-mgr.sh - Script to show status of SDL Manager # status-sdl-wkr.sh - Script to show status of SDL Worker
set -euo pipefail set -euo pipefail
use_systemd() { use_systemd() {
# Check if systemd user mode is available and service exists # Check if systemd user mode is available and service exists
if systemctl --user status >/dev/null 2>&1; then if systemctl --user status >/dev/null 2>&1; then
# Check if our service file exists # Check if our service file exists
if systemctl --user list-unit-files | grep -q "^sdl-mgr.service"; then if systemctl --user list-unit-files | grep -q "^sdl-wkr.service"; then
return 0 # Use systemd return 0 # Use systemd
fi fi
fi fi
@ -16,21 +16,21 @@ use_systemd() {
if use_systemd; then if use_systemd; then
systemctl --user status sdl-wkr systemctl --user status sdl-wkr
else else
# Get sdl-mgr PID # Get sdl-wkr PID
SDL_MGR_PID="" SDL_MGR_PID=""
for pid in $(pgrep -f 'node' 2>/dev/null || true); do for pid in $(pgrep -f 'node' 2>/dev/null || true); do
cwd=$(readlink /proc/$pid/cwd 2>/dev/null || true) cwd=$(readlink /proc/$pid/cwd 2>/dev/null || true)
if [[ "$cwd" == *"sdl-mgr"* ]]; then if [[ "$cwd" == *"sdl-wkr"* ]]; then
SDL_MGR_PID="$pid" SDL_MGR_PID="$pid"
break break
fi fi
done done
if [[ -z "$SDL_MGR_PID" ]]; then if [[ -z "$SDL_MGR_PID" ]]; then
echo "SDL Manager is not running" echo "SDL Worker is not running"
exit 0 exit 0
fi fi
echo "SDL Manager is running with PID: ${SDL_MGR_PID}" echo "SDL Worker is running with PID: ${SDL_MGR_PID}"
exit 0 exit 0
fi fi

View File

@ -6,7 +6,7 @@ use_systemd() {
# Check if systemd user mode is available and service exists # Check if systemd user mode is available and service exists
if systemctl --user status >/dev/null 2>&1; then if systemctl --user status >/dev/null 2>&1; then
# Check if our service file exists # Check if our service file exists
if systemctl --user list-unit-files | grep -q "^sdl-mgr.service"; then if systemctl --user list-unit-files | grep -q "^sdl-wkr.service"; then
return 0 # Use systemd return 0 # Use systemd
fi fi
fi fi