aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-05-28 20:26:45 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-05-28 20:26:45 +0200
commitc96321d576e79834f262486f44ab772f33053f7b (patch)
treede87af5d338768da0564a5fd934571c5426bfb30
parentda06969d6d1b7628940ae6ed956f8a1a15ee5b22 (diff)
download0tdns-c96321d576e79834f262486f44ab772f33053f7b.tar.gz
0tdns-c96321d576e79834f262486f44ab772f33053f7b.zip
split installation and setup for easier packaging
-rwxr-xr-xinstall.sh34
-rwxr-xr-xsetup.sh9
-rwxr-xr-xuninstall.sh12
3 files changed, 33 insertions, 22 deletions
diff --git a/install.sh b/install.sh
index 3b3d4e2..dcf24fe 100755
--- a/install.sh
+++ b/install.sh
@@ -1,22 +1,20 @@
#!/bin/sh
-# run this script as root
+# If we have an argument - use it as installation root
+# and prefer it over INSTALL_ROOT variable;
+# Otherwise, use INSTALL_ROOT if set;
+# Otherwise, use "/"
+if [ "x" != "x$1" ]; then
+ INSTALL_ROOT="$1"
+elif [ "x" = "x$INSTALL_ROOT" ]; then
+ INSTALL_ROOT=/
+fi
-# more could go here (e.g. initialization of postgres database)
+# Perhaps libexec could be used for those scripts, but many
+# systems don't use libexec;
+# The reason they won't go to /usr/sbin or the like is because
+# they're not to be executed directly by the user
+install -D -m744 vpn_wrapper.sh "$INSTALL_ROOT"/var/lib/0tdns/vpn_wrapper.sh
+install -D -m744 netns-script "$INSTALL_ROOT"/var/lib/0tdns/netns-script
-mkdir -p /var/lib/0tdns/
-
-mkdir -p /etc/netns/0tdns/
-
-# in case we want some process in the namespace to be able
-# to resolve domain names via libc we put some random public
-# dns in namespace sepcific's resolv.conf;
-# note, that while libunbound we're using will probably have
-# dns addresses provided by us, it is still possible to pass
-# a domain name as forwarder address to unbound, in which case
-# it will try to resolve it first using libc
-echo nameserver 23.253.163.53 > /etc/netns/0tdns/resolv.conf
-
-# part of the program running inside network namespace
-# will run under this user
-sudo useradd --system 0tdns
+# simillar approach will be used to install other files
diff --git a/setup.sh b/setup.sh
new file mode 100755
index 0000000..959a48f
--- /dev/null
+++ b/setup.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# run this script as root, once, at installation
+
+# more will go here (e.g. initialization of postgres database)
+
+# part of the program running inside network namespace
+# will run under this user
+useradd --system 0tdns
diff --git a/uninstall.sh b/uninstall.sh
index f98fe42..9e19676 100755
--- a/uninstall.sh
+++ b/uninstall.sh
@@ -1,8 +1,12 @@
#!/bin/sh
-# revert what was done in install.sh
-rm -rf /var/lib/0tdns/
-
-rm -rf /etc/netns/0tdns/
+# run as root, obviously
+# revert what was done in setup.sh
userdel 0tdns
+
+# 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*
+fi