Browse Source

Fix: read PID from pidfile instead of using shell $!

congestion
Evgeny 5 months ago
parent
commit
7a46817799
  1. 21
      tools/utun_update.sh

21
tools/utun_update.sh

@ -65,6 +65,9 @@ if [ -f "$PIDFILE" ]; then
rm -f "$PIDFILE"
fi
# Ensure pidfile is removed before start
rm -f "$PIDFILE"
# Git pull
echo "Pulling latest changes..."
if ! git pull; then
@ -107,8 +110,22 @@ echo "Build successful: $(ls -la $UTUN_BIN)"
# Start utun
echo "Starting utun..."
nohup "$UTUN_BIN" > utun_cons.log 2> utun_err.log &
NEW_PID=$!
sleep 2
# Wait for pidfile to be created (up to 10s)
for i in 1 2 3 4 5 6 7 8 9 10; do
if [ -f "$PIDFILE" ]; then
break
fi
sleep 1
done
# Read PID from file
if [ -f "$PIDFILE" ]; then
NEW_PID=$(cat "$PIDFILE")
else
echo "ERROR: Failed to start utun (pidfile not created)" >&2
exit 4
fi
# Verify process is running
if kill -0 "$NEW_PID" 2>/dev/null; then

Loading…
Cancel
Save