https://dev.kronoz.win/r/awesome-scripts.git
| 1 |
735f165 |
KronoZ |
1mo ago |
#!/bin/bash |
| 2 |
735f165 |
KronoZ |
1mo ago |
set -e |
| 3 |
735f165 |
KronoZ |
1mo ago |
|
| 4 |
735f165 |
KronoZ |
1mo ago |
# Проверка root |
| 5 |
735f165 |
KronoZ |
1mo ago |
if [ "$EUID" -ne 0 ]; then |
| 6 |
735f165 |
KronoZ |
1mo ago |
echo "ERROR: run with sudo" |
| 7 |
735f165 |
KronoZ |
1mo ago |
exit 1 |
| 8 |
735f165 |
KronoZ |
1mo ago |
fi |
| 9 |
735f165 |
KronoZ |
1mo ago |
|
| 10 |
735f165 |
KronoZ |
1mo ago |
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 11 |
735f165 |
KronoZ |
1mo ago |
|
| 12 |
735f165 |
KronoZ |
1mo ago |
echo "[1/4] Installing script to /usr/local/bin/ensure_dns.sh" |
| 13 |
735f165 |
KronoZ |
1mo ago |
cp "$SCRIPT_DIR/ensure_dns.sh" /usr/local/bin/ensure_dns.sh |
| 14 |
735f165 |
KronoZ |
1mo ago |
chmod +x /usr/local/bin/ensure_dns.sh |
| 15 |
735f165 |
KronoZ |
1mo ago |
chown root:wheel /usr/local/bin/ensure_dns.sh |
| 16 |
735f165 |
KronoZ |
1mo ago |
|
| 17 |
735f165 |
KronoZ |
1mo ago |
echo "[2/4] Installing LaunchDaemon" |
| 18 |
735f165 |
KronoZ |
1mo ago |
cp "$SCRIPT_DIR/com.user.dnsleak-guard.plist" /Library/LaunchDaemons/ |
| 19 |
735f165 |
KronoZ |
1mo ago |
chown root:wheel /Library/LaunchDaemons/com.user.dnsleak-guard.plist |
| 20 |
735f165 |
KronoZ |
1mo ago |
chmod 644 /Library/LaunchDaemons/com.user.dnsleak-guard.plist |
| 21 |
735f165 |
KronoZ |
1mo ago |
|
| 22 |
735f165 |
KronoZ |
1mo ago |
echo "[3/4] Loading LaunchDaemon" |
| 23 |
735f165 |
KronoZ |
1mo ago |
launchctl unload /Library/LaunchDaemons/com.user.dnsleak-guard.plist 2>/dev/null || true |
| 24 |
735f165 |
KronoZ |
1mo ago |
launchctl load /Library/LaunchDaemons/com.user.dnsleak-guard.plist |
| 25 |
735f165 |
KronoZ |
1mo ago |
|
| 26 |
735f165 |
KronoZ |
1mo ago |
echo "[4/4] Verifying" |
| 27 |
735f165 |
KronoZ |
1mo ago |
sleep 2 |
| 28 |
735f165 |
KronoZ |
1mo ago |
if launchctl list | grep -q "com.user.dnsleak-guard"; then |
| 29 |
735f165 |
KronoZ |
1mo ago |
echo "✅ dnsleak-guard installed and running" |
| 30 |
735f165 |
KronoZ |
1mo ago |
echo " Logs: /tmp/dnsleak-guard.log" |
| 31 |
735f165 |
KronoZ |
1mo ago |
echo " Stop: sudo launchctl unload /Library/LaunchDaemons/com.user.dnsleak-guard.plist" |
| 32 |
735f165 |
KronoZ |
1mo ago |
else |
| 33 |
735f165 |
KronoZ |
1mo ago |
echo "❌ Failed to load daemon. Check /tmp/dnsleak-guard.err" |
| 34 |
735f165 |
KronoZ |
1mo ago |
exit 1 |
| 35 |
735f165 |
KronoZ |
1mo ago |
fi |