Set CFLAGS to -O2 -Wall when running configure
[tinc] / debian / init.d
1 #! /usr/bin/perl -w
2 #
3 # System startup script for tinc
4 # $Id: init.d,v 1.14.2.3 2000/10/31 16:22:49 guus Exp $
5 #
6 # Based on Lubomir Bulej's Redhat init script.
7 #
8 # Create a file $NETSFILE (/etc/tinc/nets.boot), and put all the names of
9 # the networks in there.  These names must be valid directory names under
10 # $TCONF (/etc/tinc).  Lines starting with a # will be ignored in this
11 # file.
12 #
13
14 my $DAEMON="/usr/sbin/tincd";
15 my $NAME="tinc";
16 my $DESC="tinc daemons";
17 my $TCONF="/etc/tinc";
18 my $EXTRA="";
19 my $NETSFILE="$TCONF/nets.boot";
20 my @NETS=();
21
22
23 if (! -f $DAEMON) { exit 0; }
24
25
26
27 sub find_nets {
28     if(! open(FH, $NETSFILE)) {
29         warn "Please create $NETSFILE.\n";
30         exit 0;
31     }
32     while (<FH>) {
33         chomp;
34         if( /^[ ]*([^ \#]+)/i ) {
35             push(@NETS, "$1");
36         }
37     }
38     if($#NETS == -1) {
39         warn "$NETSFILE doesn't contain any nets.\n";
40         exit 0;
41     }
42     
43 }
44
45 if(!defined($ARGV[0])) {
46     die "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}\n";
47 }
48
49 if($ARGV[0] eq "start") {
50     find_nets;
51     print "Starting $DESC:";
52     foreach $n (@NETS) {
53         print " $n";
54         system("$DAEMON -n $_[0] $EXTRA");
55     }
56     print ".\n";
57 } elsif ($ARGV[0] eq "stop") {
58     find_nets;
59     print "Stopping $DESC:";
60     foreach $n (@NETS) {
61         print " $n";
62         system("$DAEMON -n $_[0] $EXTRA -k");
63     }
64     print ".\n";
65 } elsif ($ARGV[0] eq "restart" || $ARGV[0] eq "force-reload") {
66     find_nets;
67     print "Stopping $DESC:";
68     foreach $n (@NETS) {
69         print " $n";
70         system("$DAEMON -n $_[0] $EXTRA -k");
71     }
72     print ".\n";
73     print "Starting $DESC:";
74     foreach $n (@NETS) {
75         print " $n";
76         system("$DAEMON -n $_[0] $EXTRA");
77     }
78     print ".\n";
79 } else {
80     die "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}\n";
81 }