Skip to content

Commit

Permalink
restart only running Tor processes
Browse files Browse the repository at this point in the history
  • Loading branch information
toralf committed Jun 23, 2024
1 parent 45caead commit 3b75fa9
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions update_tor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,35 @@ function restart() {
export GRACEFUL_TIMEOUT=20

# shellcheck disable=SC2011
ls /etc/init.d/tor? |
ls /etc/init.d/tor{,?} |
xargs -n 1 basename |
while read -r service; do
echo
echo "----------------------------"
date
echo " restarting $service"
echo " $service"
echo
if ! rc-service $service restart; then
local pid
if pid=$(cat /run/tor/$service.pid); then
if kill -0 $pid; then
echo " kill pid $pid"
kill -9 $pid
sleep 1
else
rm /run/tor/$service.pid
echo " stale pid $pid for $service"

if ! rc-service $service status; then
echo -e "\n skipped"
else
if ! rc-service $service restart; then
if pid=$(cat /run/tor/$service.pid); then
if kill -0 $pid; then
echo " kill pid $pid"
kill -9 $pid
sleep 1
else
rm /run/tor/$service.pid
echo " stale pid $pid"
fi
fi
if ! rc-service $service zap start; then
echo "zap start failed"
fi
fi
if ! rc-service $service zap start; then
echo "zap start failed for $service"
fi
fi
echo
done
}

Expand Down

0 comments on commit 3b75fa9

Please sign in to comment.