forked from essandess/macOS-Fortress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
net.hphosts.hosts.plist
26 lines (26 loc) · 2.87 KB
/
net.hphosts.hosts.plist
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.hphosts.hosts.plist</string>
<key>Program</key>
<string>/bin/bash</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>/bin/mkdir -p /usr/local/etc ; ( /bin/test -f /etc/hosts.orig || /usr/bin/install -m 644 -S /etc/hosts /etc/hosts.orig ) && /bin/cp /etc/hosts.orig /tmp/hosts && /opt/local/bin/wget -N -P /usr/local/etc http://hosts-file.net/download/hosts.zip && /opt/local/bin/wget -N -P /usr/local/etc http://hosts-file.net/hphosts-partial.asp && /usr/bin/unzip -o /usr/local/etc/hosts.zip -d /tmp/hphosts && /opt/local/bin/gpg --verify /tmp/hphosts/hosts.txt.asc /tmp/hphosts/hosts.txt && ( /bin/test -f /usr/local/etc/whitelist.txt || /usr/bin/printf '\n# whitelisted hosts (FQDN and DN) will be deleted from hphost'"'"'s host.zip\n#\n' > /usr/local/etc/whitelist.txt ) && /usr/bin/printf '\n# hpHosts hosts.txt from http://hosts-file.net/download/hosts.zip:\n' > /tmp/hosts-block.txt && /bin/cat /tmp/hphosts/hosts.txt | tr -d '\015' | /usr/bin/perl -ane 'use POSIX; use Data::Validate::Domain qw(is_domain); { if (/^127\.0\.0\.1\s*(.+)$/) { print qq#127.0.0.1\t$1\n# if is_domain($1); } else { print; } }' >> /tmp/hosts-block.txt && /usr/bin/printf '\n# hpHosts hphosts-partial.asp from http://hosts-file.net/hphosts-partial.asp:\n' >> /tmp/hosts-block.txt && /bin/cat /usr/local/etc/hphosts-partial.asp | tr -d '\015' | /usr/bin/perl -ane 'use POSIX; use Data::Validate::Domain qw(is_domain); { if (/^127\.0\.0\.1\s*(.+)$/) { print qq#127.0.0.1\t$1\n# if is_domain($1); } else { print; } }' >> /tmp/hosts-block.txt && ( /bin/test -f /usr/local/etc/blacklist.txt && /bin/cat /usr/local/etc/blacklist.txt >> /tmp/hosts ) && /usr/bin/grep -v -E "`/usr/bin/perl -ane 'BEGIN{$s=qw#\\s+(#}; { if (!/^\w*#/&length($F[0])>0){$s = $s . $F[0] . qw(|);}} END{$s = substr($s,0,length($s)-1) . qw#)\\s*#; $s=~s/\\./\\\\./g; print $s;}' /usr/local/etc/whitelist.txt`" /tmp/hosts-block.txt >> /tmp/hosts && /usr/bin/install -m 644 -S /tmp/hosts /etc/hosts-hphosts ; /bin/rm -fr /tmp/hosts /tmp/hphosts /tmp/hosts-block.txt ; /opt/local/sbin/squid -k reconfigure</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>86850</integer>
<key>ServiceDescription</key>
<string>hpHosts.org hosts file update</string>
<key>StandardErrorPath</key>
<string>/var/log/system.log</string>
<key>StandardOutPath</key>
<string>/var/log/system.log</string>
</dict>
</plist>