forked from essandess/macOS-Fortress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macosfortress_boot_check
34 lines (29 loc) · 964 Bytes
/
macosfortress_boot_check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash -x
# macosfortress_boot_check -- check to make sure that all desired services are running
# commands
SUDO=/usr/bin/sudo
LAUNCHCTL=/bin/launchctl
PORT=/opt/local/bin/port
PFCTL=/sbin/pfctl
HEAD=/usr/bin/head
TAIL=/usr/bin/tail
LSOF=/usr/sbin/lsof
KILLALL=/usr/bin/killall
# pfctl
if ! [[ `$SUDO $PFCTL -s info | $HEAD -1 | $TAIL -1` =~ "Status: Enabled" ]]; then
$SUDO $LAUNCHCTL unload -w /Library/LaunchDaemons/net.openbsd.pf.plist
$SUDO $LAUNCHCTL load -w /Library/LaunchDaemons/net.openbsd.pf.plist
fi
# squid
# make sure there aren't multiple squid jobs running
if ! [[ `$SUDO $LSOF -i ':3128' | $TAIL -1` && `ps -ef | grep "/opt/local/sbin/squid -s" | grep -v grep | wc -l` -eq 1 ]]; then
$SUDO $PORT unload squid3
$SUDO $KILLALL 'squid'
$SUDO $KILLALL '(squid-1)'
$SUDO $PORT load squid3
fi
# privoxy
if ! [[ `$SUDO $LSOF -i ':8118' | $TAIL -1` ]]; then
$SUDO $PORT unload privoxy
$SUDO $PORT load privoxy
fi