75 |
usage(); |
usage(); |
76 |
} |
} |
77 |
|
|
78 |
if ($glbl_ask) { our $DEBUG_STEP; $DEBUG_STEP = 1; } |
if ($glbl_ask) { |
79 |
|
our $DEBUG_STEP; |
80 |
|
$DEBUG_STEP = 1; |
81 |
|
$UML::Config::DEBUG_STEP = 1; |
82 |
|
} |
83 |
|
|
84 |
my $vhost = get_host_cfg($vhost_name); |
my $vhost = get_host_cfg($vhost_name); |
85 |
my %vhost = %{$vhost}; |
my %vhost = %{$vhost}; |
175 |
my $initscript_path = "/etc/init.d/$daemon"; |
my $initscript_path = "/etc/init.d/$daemon"; |
176 |
my $runlevel_base = "/etc/init.d/rc$runlevel.d"; |
my $runlevel_base = "/etc/init.d/rc$runlevel.d"; |
177 |
|
|
178 |
|
my $owner = $vhost->{main}{owner}; |
179 |
|
|
180 |
|
# TODO: handle if above determined parameters are not set |
181 |
|
# try not to write out invalid shell scripts! |
182 |
|
|
183 |
# main init script |
# main init script |
184 |
$content = "#!/usr/bin/perl |
$content = "#!/usr/bin/perl |
185 |
|
|
186 |
use strict; |
use strict; |
187 |
use warnings; |
use warnings; |
188 |
my \$action = shift; |
my \$action = shift; |
189 |
if (!\$action) { |
if (!\$action) { |
190 |
print \"no action!\", \"\\n\"; |
print \"\$0 called without action argument!\", \"\\n\"; |
191 |
exit; |
exit; |
192 |
} |
} |
193 |
if (\$action eq \"start\") { |
if (\$action eq \"start\") { |
194 |
system(\"$uml_boot --start --vhost=$vhost_name\"); |
system(\"$uml_boot --prepare --vhost=$vhost_name\"); |
195 |
|
system(\"$sudo -u $owner $uml_boot --start --vhost=$vhost_name\"); |
196 |
} |
} |
197 |
if (\$action eq \"stop\") { |
if (\$action eq \"stop\") { |
198 |
system(\"$uml_boot --stop --vhost=$vhost_name\"); |
system(\"$uml_boot --stop --vhost=$vhost_name\"); |
206 |
# runlevel init scripts |
# runlevel init scripts |
207 |
$filename = "$runlevel_base/S30$daemon"; |
$filename = "$runlevel_base/S30$daemon"; |
208 |
$cmd = "rm $filename; ln $initscript_path -s $filename"; |
$cmd = "rm $filename; ln $initscript_path -s $filename"; |
209 |
askCmd("do it?", $cmd, "unmounting datafs"); |
askCmd("do it?", $cmd, "create $filename"); |
210 |
chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, $filename; |
chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, $filename; |
211 |
|
|
212 |
$filename = "$runlevel_base/K01$daemon"; |
$filename = "$runlevel_base/K01$daemon"; |
213 |
$cmd = "rm $filename; ln $initscript_path -s $filename"; |
$cmd = "rm $filename; ln $initscript_path -s $filename"; |
214 |
askCmd("do it?", $cmd, "unmounting datafs"); |
askCmd("do it?", $cmd, "create $filename"); |
215 |
chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, $filename; |
chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, $filename; |
216 |
|
|
217 |
} |
} |