aboutsummaryrefslogtreecommitdiff
path: root/uninstall.sh
blob: a176e5bce357eddf58df492d7b21bb20b79efa77 (about) (plain)
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
#!/bin/sh

# https://stackoverflow.com/questions/2990414/echo-that-outputs-to-stderr
errcho(){ >&2 echo "$@"; }

# run as root, obviously
if [ `id -u` != 0 ]; then
    errcho "This script needs to be run as root"
    exit 1
fi

# revert what was done in setup.sh
userdel 0tdns

# remove our crontab entry marked with '<AUTO_GENERATED_0TDNS_ENTRY>'
# we also remove the 'DO NOT EDIT' header, as in setup.sh
crontab -l 2> /dev/null |
    grep -vE '^# DO NOT EDIT THIS FILE|^# \(- installed on .*\)|^# \(Cron version .*\)' |
    grep -v '<AUTO_GENERATED_0TDNS_ENTRY>' | crontab

# if told to - also revert what was done in install.sh
if [ "x$1" = "x--delete-files" ]; then
    rm -r /var/lib/0tdns/
    rm -r /etc/netns/0tdns*
    rm /usr/sbin/hourly.py
    rm -r /etc/0tdns
    rm /usr/lib/python3/dist-packages/ztdns_db_connectivity.py
fi