this repo has no description
1#!/bin/sh
2
3if [ "$(whoami)" != "root" ]
4then
5 echo "$0 must be run as root, invoking sudo"
6 exec sudo su -c "$0" "$@"
7fi
8
9echo "Seeing if Darling is currently running"
10
11# Sometimes `pgrep launchd` doesn't work when `pgrep -f launchd` does. Not sure
12# if we want to include arguments (and capture rare, but possible false
13# positives).
14PID=$(pgrep -f launchd)
15
16while [ -n "$PID" ]
17do
18 THISPID=$(echo $PID | head -n1)
19 RUNNING_USER=$(ps -o uname= -p $THISPID | head -n1)
20 echo "Darling currently running for $RUNNING_USER, shutting it down..."
21 su --login "$RUNNING_USER" -c "darling shutdown"
22 sleep 2
23 PID=$(pgrep -f launchd)
24done
25
26echo "No instances running now"