Files
pilens/scripts/uninstall.sh
T
Andy Dixon 5dbf85f84e Phase 4: authorised HTTPS interception (Mode B)
Toggleable transparent interception via mitmdump in a venv. Own RSA CA generated
in-app, downloadable (public cert only, key never leaves the box), with per-OS
install guide and fingerprint. nftables redirect accepts only dnat'd connections
(never an open proxy). HTTP Explorer with headers and opt-in body viewers (JSON/
text/hex/image, sandboxed). Honest status: pinned/untrusting = reported errors,
excluded hosts pass through, bodies off by default. Helper op + systemd unit +
installer venv build + boot restore.
2026-10-10 08:05:42 +01:00

35 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Remove PiLens. Captures and settings in /var/lib/pilens are KEPT unless --purge.
# sudo ./uninstall.sh [--purge] [--yes]
set -euo pipefail
PURGE=0; YES=0
for a in "$@"; do case "$a" in --purge) PURGE=1 ;; --yes|-y) YES=1 ;; *) echo "unknown option $a"; exit 2 ;; esac; done
[ "$(id -u)" = 0 ] || { echo "run as root"; exit 1; }
confirm() { [ "$YES" = 1 ] && return 0; read -r -p "$1 [y/N] " a; [[ "$a" =~ ^[Yy] ]]; }
echo "This removes the PiLens services, the 'pilens-ap' access-point profile, the 'inet pilens' firewall table and /opt/pilens."
[ $PURGE = 1 ] && echo "--purge: ALSO deletes /var/lib/pilens: every capture, setting and account."
confirm "Continue?" || exit 1
if [ $PURGE = 1 ]; then
read -r -p "Type DELETE to permanently delete all captures: " x
[ "$x" = DELETE ] || { echo "not confirmed; keeping data"; PURGE=0; }
fi
systemctl disable --now pilens pilens-proxy pilens-dnsmasq pilens-helper pilens-firewall 2>/dev/null || true
nmcli connection delete pilens-ap 2>/dev/null && echo "removed access-point profile (other Wi-Fi profiles were never modified and will reconnect)" || true
rm -f /etc/NetworkManager/system-connections/pilens-ap.nmconnection
nft delete table inet pilens 2>/dev/null && echo "removed firewall table inet pilens" || true
echo "note: IPv4 forwarding was left as it is now ($(sysctl -n net.ipv4.ip_forward)); other services may depend on it"
rm -f /etc/systemd/system/pilens*.service
systemctl daemon-reload
rm -rf /opt/pilens /var/lib/pilens-helper /run/pilens
if [ $PURGE = 1 ]; then
rm -rf /var/lib/pilens
userdel pilens 2>/dev/null || true
echo "data purged"
else
echo "kept /var/lib/pilens (captures, database). Remove it with: sudo rm -rf /var/lib/pilens"
fi
echo "apt packages (tshark, wireshark-common, nftables, dnsmasq-base, iw) were left installed."
echo "Configuration backups are in /var/backups/pilens/."