add license
[0tDNS.git] / setup.sh
blob8159db67561c5fd7762fd281366ab7994cb62a21
1 #!/bin/sh
3 # https://stackoverflow.com/questions/2990414/echo-that-outputs-to-stderr
4 errcho(){ >&2 echo "$@"; }
6 # run this script as root, once, at installation
7 if id -u 0tdns > /dev/null 2>&1; then
8 errcho "User 0tdns already exists."
9 errcho "Do you have Zero Trust DNS already set up?"
10 errcho "If so, you need to uninstall it properly"
11 errcho "(e.g. via provided uninstall.sh script)"
12 errcho "before setting it up again"
13 exit 1
16 if [ `id -u` != 0 ]; then
17 errcho "This script needs to be run as root"
18 exit 1
21 # part of the program running inside network namespace
22 # will run under this user
23 useradd --system 0tdns
25 # crontab automatically adds a 'DO NOT EDIT' header to
26 # crontab file; if we don't remove it every time - headers
27 # will accumulate :/ (not on Debian, though)
28 # line we want to add to crontab is in 0tdns_crontab file
29 crontab -l 2> /dev/null |
30 grep -vE '^# DO NOT EDIT THIS FILE|^# \(- installed on .*\)|^# \(Cron version .*\)' |
31 cat - 0tdns_crontab | crontab