summaryrefslogtreecommitdiffstats
path: root/modules/retiolum/bin/update_tinc_hosts
blob: 623ea3152592a38c905385e8670e917fa18a9154 (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
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