#!/bin/sh # # $FreeBSD: ports/net/vtun/files/vtunclient.in,v 1.1 2007/02/26 11:03:15 miwi Exp $ # $Id: vtunclient,v 1.1.1.1 2008/01/27 14:48:43 shelton Exp $ # BSD License. Copyright (C) by Rashid N. "CityCat" Achilov # # PROVIDE: vtunclient # REQUIRE: DAEMON # # Add the following line to /etc/rc.conf to enable vtunclient: # # vtunclient_enable="YES" # vtunclient_flags=" " # vtunclient_enable=${vtunclient_enable:-"NO"} vtunclient_flags=${vtunclient_flags:-""} . /etc/rc.subr name=vtunclient rcvar=`set_rcvar` required_files="/usr/local/etc/vtund.conf" command="/usr/local/sbin/vtund" # Set defaults vtunclient_sessions=${vtunclient_sessions:-"NO"} vtunclient_domain=${vtunclient_domain:-"NO"} load_rc_config $name start_precmd="vtunclients_prestart" start_cmd="vtunclients_start" stop_cmd="vtunclients_stop" restart_cmd="vtunclients_restart" status_cmd="vtunclients_status" vtunclients_prestart() { if [ ${#vtunclient_sessions} -eq 0 ] || \ [ ${#vtunclient_domain} -eq 0 ]; then echo "VTun client mode session list is empty or domain was omitted" err 10 "VTun session list is empty or domain was omitted" fi } vtunclients_start() { for _session in $vtunclient_sessions do ${command} -p ${_session} ${_session}.${vtunclient_domain} done } vtunclients_stop() { pidlist=`check_process $command` kill -${sig_stop:-TERM} ${pidlist} wait_for_pids ${pidlist} } vtunclients_restart() { vtunclients_stop vtunclients_start } vtunclients_status() { for _session in $vtunclient_sessions do sinfo=`ps -axww | grep ${_session} | grep -v grep` if [ ${#sinfo} -eq 0 ]; then echo "Session ${_session} did not started" else set $sinfo echo "$1 $5 $6 $7" fi done } run_rc_command "$1"