From b253c118a9455ecec755271432cd761dae3bf975 Mon Sep 17 00:00:00 2001 From: Felix Richter Date: Fri, 27 May 2011 22:58:53 +0200 Subject: added script to start and stop name resolution via hosts file using magic line will always work because sed will look for the longest match. update_tinc_hosts is made to be daemonized and to be started with tinc --- modules/retiolum/bin/update_tinc_hosts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 modules/retiolum/bin/update_tinc_hosts (limited to 'modules') diff --git a/modules/retiolum/bin/update_tinc_hosts b/modules/retiolum/bin/update_tinc_hosts new file mode 100755 index 00000000..623ea315 --- /dev/null +++ b/modules/retiolum/bin/update_tinc_hosts @@ -0,0 +1,29 @@ +#!/bin/sh +DIRNAME=`dirname $0` +HERE=`readlink -f ${DIRNAME}` + +if test `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +case $1 in + start) + $0 stop + echo "# BEGIN OF RETIOLUM" >> /etc/hosts + $HERE/hosts >> /etc/hosts + echo "# END OF RETIOLUM" >> /etc/hosts + + ;; + stop) + sed -ie "/\# BEGIN OF RETIOLUM/,/\# END OF RETIOLUM/d" /etc/hosts + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "You are made of stupid!" + exit 23 +esac -- cgit v1.2.3