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
Line 1: Line 1:
 
#!/bin/sh
 
#!/bin/sh
 
#
 
#
 +
# $NetBSD: chaosvpn
 +
#
  
 
# PROVIDE: chaosvpn
 
# PROVIDE: chaosvpn
# REQUIRE: NETWORKING
+
# REQUIRE: inetd network LOGIN
# BEFORE:
 
# KEYWORD: nojail
 
  
 
+
$_rc_subr_loaded . /etc/rc.subr
 
 
# Define these chaosvpn_* variables in one of these files:
 
#      /etc/rc.conf
 
#      /etc/rc.conf.local
 
#      /etc/rc.conf.d/threeproxy
 
#
 
# DO NOT CHANGE THESE DEFAULT VALUES HERE
 
 
 
chaosvpn_enable=${chaosvpn_enable:-"NO"}
 
 
 
. /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="chaosvpn_stop"
 
stop_cmd="chaosvpn_stop"
#reload_cmd="chaosvpn_reload"
 
#extra_commands="reload"
 
procname=${command:-chaosvpn}
 
  
load_rc_config $name
+
chaosvpn_start(){
  
: ${chaosvpn_config:="/usr/local/etc/tinc/chaosvpn.conf"}
+
  /usr/pkg/sbin/chaosvpn -d
: ${chaosvpn_flags:="-d"}
+
  sleep 10 #give things time to get set up
 
+
  /usr/pkg/etc/tinc/chaos/tinc-up
chaosvpn_prestart()
+
  sleep 10 #give things time to get set up
{
 
  
 +
  #add logic in here later to check if its actually up
 +
  #for now just assume it worked, lol
 +
  echo "chaosvpn up..."
 
}
 
}
  
chaosvpn_start()
+
chaosvpn_stop(){
{
 
        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 ChaosVPN..."
+
  sleep 2 # once again, let things die...
        ps -aux | awk '/chaosvpn/ && !/awk/ {print $2}' | xargs -r kill -9
+
  echo "Killing tincd..."
        echo "Killing tincd..."
+
  ps -aux | awk '/tincd/ && !/awk/ {print $2}' | xargs -r kill -9
        ps -aux | awk '/tincd/ && !/awk/ {print $2}' | xargs -r kill -9
 
  
        #add logic in here later
+
  #add logic in here later to check if its actually down
        echo "done..."
+
  echo "chaosvpn down..."
 
}
 
}
  
 
run_rc_command "$1"
 
run_rc_command "$1"
 
# eof
 
# eof

Revision as of 04:49, 24 October 2013

  1. !/bin/sh
  2. $NetBSD: chaosvpn
  1. PROVIDE: chaosvpn
  2. REQUIRE: inetd network LOGIN

$_rc_subr_loaded . /etc/rc.subr

name="chaosvpn" start_cmd="chaosvpn_start" stop_cmd="chaosvpn_stop"

chaosvpn_start(){

 /usr/pkg/sbin/chaosvpn -d
 sleep 10 #give things time to get set up
 /usr/pkg/etc/tinc/chaos/tinc-up
 sleep 10 #give things time to get set up
 #add logic in here later to check if its actually up
 #for now just assume it worked, lol
 echo "chaosvpn up..."

}

chaosvpn_stop(){

 echo "Killing ChaosVPN..."
 ps -aux | awk '/chaosvpn/ && !/awk/ {print $2}' | xargs -r kill -9
 sleep 2 # once again, let things die...
 echo "Killing tincd..."
 ps -aux | awk '/tincd/ && !/awk/ {print $2}' | xargs -r kill -9
 #add logic in here later to check if its actually down
 echo "chaosvpn down..."

}

run_rc_command "$1"

  1. eof