/[cvs]/nfo/perl/scripts/umltools/uml_boot.pl
ViewVC logotype

Annotation of /nfo/perl/scripts/umltools/uml_boot.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sun Nov 3 01:20:19 2002 UTC (21 years, 6 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -0 lines
File MIME type: text/plain
+ modifications regarding CONFIG_STEP
+ changed template script for uml startup (daemonize action)
+ modification to "ris"???

1 joko 1.1 #!/usr/bin/perl
2     # deactivated: #!/usr/bin/suidperl
3    
4     # apply restrictions
5     use strict;
6     use warnings;
7    
8     $ENV{PATH} = "";
9    
10     # path to modules
11     use lib '/home/service/bin/umltools';
12    
13     # path to config-file
14     use lib '/home/service/etc';
15    
16     # load modules
17     use Getopt::Long;
18     use UML::Config;
19     use UML::Validate;
20     use UML::Utils;
21     use UML::Control;
22    
23     # setup configuration
24     our $DEBUG_STEP;
25    
26     $DEBUG_STEP = 0;
27    
28     # usage
29     sub usage {
30     print "\n";
31     print " Usage: uml_boot.pl [OPTIONS] which may be ...", "\n";
32     print " --vhost=<vhost-name> ", "supply a distingushed name for a virtual host", "\n";
33     print " --prepare ", "prepares vhost (networking, routes, firewall)", "\n";
34     print " --start ", "starts vhost", "\n";
35     print " --stop ", "stops vhost by issuing /sbin/shutdown", "\n";
36     print " --kill ", "kills all vhost-processes", "\n";
37     print " --kill9 ", "kills all vhost-processes by kill -9 (not impl. yet)", "\n";
38     print " --restart ", "restarts vhost", "\n";
39     print " --validate ", "validates vhost (configuration)", "\n";
40     print " --ask ", "prompts for each action", "\n";
41     exit;
42     }
43    
44     # variables
45     my $vhost_name;
46     my $arg_prepare;
47     my $arg_start;
48     my $arg_stop;
49     my $arg_kill;
50     my $arg_restart;
51     my $arg_validate;
52     my $arg_ask;
53    
54     # parse command-line-options/arguments
55     my $args_parsed = GetOptions (
56     "vhost=s" => \$vhost_name,
57     "prepare" => \$arg_prepare,
58     "start" => \$arg_start,
59     "stop" => \$arg_stop,
60     "kill" => \$arg_kill,
61     "restart" => \$arg_restart,
62     "validate" => \$arg_validate,
63     "ask" => \$arg_ask,
64     );
65    
66     # validate arguments
67     if ( (!$vhost_name) || !($arg_prepare || $arg_start || $arg_stop || $arg_kill || $arg_restart || $arg_validate) ) {
68     usage();
69     }
70    
71    
72     # execute tasks/actions dependent on arguments
73    
74     sub vhost_prepare {
75     print "preparing vhost \"$vhost_name\"", "\n";
76     UML::Control::prepare($vhost_name);
77     }
78     sub vhost_start {
79     print "starting vhost \"$vhost_name\"", "\n";
80     UML::Control::start($vhost_name);
81     }
82     sub vhost_stop {
83     print "stopping vhost \"$vhost_name\"", "\n";
84     UML::Control::stop($vhost_name);
85     }
86     sub vhost_kill {
87     print "killing vhost \"$vhost_name\"", "\n";
88     UML::Control::kill($vhost_name);
89     }
90     sub vhost_restart {
91     print "restarting vhost \"$vhost_name\"", "\n";
92     UML::Control::restart($vhost_name);
93     }
94    
95     if ($arg_ask) {
96     $DEBUG_STEP = 1;
97 joko 1.2 $UML::Config::DEBUG_STEP = 1;
98 joko 1.1 }
99    
100     my $arg_validate_mustok;
101     if ($arg_start) {
102     $arg_validate_mustok = 1;
103     }
104    
105     if ($arg_validate) {
106     print "validating vhost \"$vhost_name\"", "\n";
107     UML::Validate::do($vhost_name, {'check' => 1, 'die' => $arg_validate_mustok} );
108     }
109    
110     vhost_prepare() if ($arg_prepare);
111     vhost_start() if ($arg_start);
112     vhost_stop() if ($arg_stop);
113     vhost_kill() if ($arg_kill);
114     vhost_restart() if ($arg_restart);

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed