diff --git a/bin/setup b/bin/setup index de7fdc9..b904298 100755 --- a/bin/setup +++ b/bin/setup @@ -9,15 +9,21 @@ BIN_DIR=/usr/local/bin install -m 700 -o root -g root -D "${DIR}/bin/tund" "${BIN_DIR}/tund" # Install upstart script -if [ -d "/etc/init" ] +if [[ $(sudo stat /proc/1/exe |grep systemd) ]] then - install -m 644 -o root -g root "${DIR}/etc/init/tund.conf" /etc/init/tund.conf + install -m 644 -o root -g root "${DIR}/etc/init/tund.service" }/etc/systemd/system/tund.service else - install -m 755 -o root -g root "${DIR}/etc/init.d/tund" /etc/init.d/tund - update-rc.d tund defaults + if [[ $(sudo stat /proc/1/exe |grep init) ]] + if [ -d "/etc/init" ] + then + install -m 644 -o root -g root "${DIR}/etc/init/tund.conf" /etc/init/tund.conf + else + install -m 755 -o root -g root "${DIR}/etc/init.d/tund" /etc/init.d/tund + update-rc.d tund defaults + fi + fi fi - if [ ! -e "${ETC_DIR}/key" ] then if [ ! -e "${DIR}/etc/key" ] diff --git a/etc/init/tund.service b/etc/init/tund.service new file mode 100644 index 0000000..26e0984 --- /dev/null +++ b/etc/init/tund.service @@ -0,0 +1,9 @@ +[Unit] +Description=Tund tunnel +Documentation=https://github.com/aphyr/tund + +[Service] +Type=simple +ExecStart=/usr/local/bin/tund +StandardOutput=null +Restart=on-failure