aboutsummaryrefslogtreecommitdiff
path: root/uninstall.sh
blob: 294c15143ee3d6c25250b5067b8d828a468d8a51 (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
29
#!/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 /usr/sbin/check_if_done.py
    rm -r /etc/0tdns
    rm /usr/lib/python3/dist-packages/ztdnslib.py
fi