Dieses Wiki ist ein Archiv bis 2023. Das aktuelle Wiki findet sich unter https://wiki.hamburg.ccc.de/

Difference between revisions of "ChaosVPN:Tims NetBSD chaosvpn rc.d"

From CCCHHWiki
Jump to: navigation, search
m (+x)
m
Line 1: Line 1:
Dont forget to run  '''''# chmod +x /etc/rc.d/chaosvpn'''''
+
#!/bin/sh
 +
#
 +
 
 +
# PROVIDE: chaosvpn
 +
# REQUIRE: NETWORKING
 +
# BEFORE:
 +
# KEYWORD: nojail
 +
 
  
<pre>
 
  
#!/bin/sh
+
# Define these chaosvpn_* variables in one of these files:
 +
#      /etc/rc.conf
 +
#      /etc/rc.conf.local
 +
#      /etc/rc.conf.d/threeproxy
 
#
 
#
# $NetBSD: chaosvpn
+
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
 
  
# PROVIDE: chaosvpn
+
chaosvpn_enable=${chaosvpn_enable:-"NO"}
# REQUIRE: inetd network LOGIN
 
  
$_rc_subr_loaded . /etc/rc.subr
+
. /etc/rc.subr
  
 
name="chaosvpn"
 
name="chaosvpn"
 +
rcvar="chaosvpn_enable"
 +
command="/usr/local/sbin/chaosvpn"
 +
start_precmd="chaosvpn_prestart"
 
start_cmd="chaosvpn_start"
 
start_cmd="chaosvpn_start"
stop_cmd=":"
+
stop_cmd="chaosvpn_stop"
 +
#reload_cmd="chaosvpn_reload"
 +
#extra_commands="reload"
 +
procname=${command:-chaosvpn}
 +
 
 +
load_rc_config $name
 +
 
 +
: ${chaosvpn_config:="/usr/local/etc/tinc/chaosvpn.conf"}
 +
: ${chaosvpn_flags:="-d"}
  
chaosvpn_start()
+
chaosvpn_prestart()
 
{
 
{
  
  /usr/pkg/sbin/chaosvpn -d
+
}
  
  sleep 10 #give things time to get set up
+
chaosvpn_start()
 +
{
 +
        for cfg in ${chaosvpn_config}
 +
        do
 +
                echo "Starting ChaosVPN for ${cfg}"
 +
                $command -d -c $cfg
 +
        done
 +
}
  
  /usr/pkg/etc/tinc/chaos/tinc-up
+
chaosvpn_stop()
 
+
{
  route add 10.100.0.0/16 10.100.44.1 #because the route for 10.100 wasnt being automagically configured
+
        echo "Killing ChaosVPN..."
  route add 172.31.0.0/16 10.100.44.1 #same as above
+
        ps -aux | awk '/chaosvpn/ && !/awk/ {print $2}' | xargs -r kill -9
 +
        echo "Killing tincd..."
 +
        ps -aux | awk '/tincd/ && !/awk/ {print $2}' | xargs -r kill -9
  
 +
        #add logic in here later
 +
        echo "done..."
 
}
 
}
  
load_rc_config $name
 
 
run_rc_command "$1"
 
run_rc_command "$1"
 
+
# eof
</pre>
 
 
 
[[Category:ChaosVPN]]
 

Revision as of 04:36, 24 October 2013

  1. !/bin/sh
  1. PROVIDE: chaosvpn
  2. REQUIRE: NETWORKING
  3. BEFORE:
  4. KEYWORD: nojail


  1. Define these chaosvpn_* variables in one of these files:
  2. /etc/rc.conf
  3. /etc/rc.conf.local
  4. /etc/rc.conf.d/threeproxy
  5. DO NOT CHANGE THESE DEFAULT VALUES HERE

chaosvpn_enable=${chaosvpn_enable:-"NO"}

. /etc/rc.subr

name="chaosvpn" rcvar="chaosvpn_enable" command="/usr/local/sbin/chaosvpn" start_precmd="chaosvpn_prestart" start_cmd="chaosvpn_start" stop_cmd="chaosvpn_stop"

  1. reload_cmd="chaosvpn_reload"
  2. extra_commands="reload"

procname=${command:-chaosvpn}

load_rc_config $name

${chaosvpn_config:="/usr/local/etc/tinc/chaosvpn.conf"}
${chaosvpn_flags:="-d"}

chaosvpn_prestart() {

}

chaosvpn_start() {

       for cfg in ${chaosvpn_config}
       do
               echo "Starting ChaosVPN for ${cfg}"
               $command -d -c $cfg
       done

}

chaosvpn_stop() {

       echo "Killing ChaosVPN..."
       ps -aux | awk '/chaosvpn/ && !/awk/ {print $2}' | xargs -r kill -9
       echo "Killing tincd..."
       ps -aux | awk '/tincd/ && !/awk/ {print $2}' | xargs -r kill -9
        #add logic in here later
       echo "done..."

}

run_rc_command "$1"

  1. eof