diff options
author | Sebastian Schmelzer | 2009-08-11 14:06:52 +0200 |
---|---|---|
committer | Sebastian Schmelzer | 2009-08-11 14:06:52 +0200 |
commit | 1a05343d41fb6d7fb4c3f6a1b2cdc9522bb035ce (patch) | |
tree | 63bbf06fba7ee341c0003a70f2f32452577af1b0 | |
parent | Do nothing if no partition found ... (diff) | |
download | core-1a05343d41fb6d7fb4c3f6a1b2cdc9522bb035ce.tar.gz core-1a05343d41fb6d7fb4c3f6a1b2cdc9522bb035ce.tar.xz core-1a05343d41fb6d7fb4c3f6a1b2cdc9522bb035ce.zip |
distroutils update
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@3069 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r-- | lib/OpenSLX/DistroUtils/Base.pm | 52 | ||||
-rw-r--r-- | lib/OpenSLX/DistroUtils/InitFile.pm | 44 | ||||
-rw-r--r-- | lib/OpenSLX/DistroUtils/Suse.pm | 52 | ||||
-rw-r--r-- | lib/OpenSLX/DistroUtils/Ubuntu.pm | 77 |
4 files changed, 202 insertions, 23 deletions
diff --git a/lib/OpenSLX/DistroUtils/Base.pm b/lib/OpenSLX/DistroUtils/Base.pm index f4eb45c8..f9e6b13b 100644 --- a/lib/OpenSLX/DistroUtils/Base.pm +++ b/lib/OpenSLX/DistroUtils/Base.pm @@ -139,7 +139,8 @@ sub _renderHighlevelConfig $element->{shortname}, uc($element->{shortname}), $element->{shortname} - ) + ), + $element->{priority} ); $tpl = "echo -n \"Starting %s \"\n"; @@ -152,7 +153,8 @@ sub _renderHighlevelConfig uc($element->{shortname}), uc($element->{shortname}), uc($element->{shortname}) - ) + ), + $element->{priority} ); $tpl = "echo -n \"Shutting down %s\" \n"; @@ -164,7 +166,8 @@ sub _renderHighlevelConfig $element->{desc}, uc($element->{shortname}), uc($element->{shortname}) - ) + ), + 10 - $element->{priority} ); $tpl = "## Stop the service and if this succeeds (i.e. the \n"; @@ -173,7 +176,8 @@ sub _renderHighlevelConfig $tpl .= "# Remember status and be quiet\n"; $tpl .= "rc_status"; $initFile->addToCase('try-restart', - $tpl + $tpl, + $element->{priority} ); $tpl = "## Stop the service and regardless of whether it was \n"; @@ -183,7 +187,8 @@ sub _renderHighlevelConfig $tpl .= "# Remember status and be quiet\n"; $tpl .= "rc_status"; $initFile->addToCase('restart', - $tpl + $tpl, + $element->{priority} ); $tpl = "echo -n \"Reload service %s\"\n"; @@ -196,7 +201,8 @@ sub _renderHighlevelConfig uc($element->{shortname}), uc($element->{shortname}), uc($element->{shortname}) - ) + ), + $element->{priority} ); $tpl = "echo -n \"Checking for service %s\"\n"; @@ -208,11 +214,41 @@ sub _renderHighlevelConfig $element->{desc}, uc($element->{shortname}), uc($element->{shortname}) - ) + ), + $element->{priority} ); } + case 'function' { + my $tpl; + $tpl = "%s () { \n"; + $tpl .= "%s"; + $tpl .= "\n}\n"; + $initFile->addToBlock('functions', + sprintf( + $tpl, + $element->{name}, + $element->{script} + ) + ); + + } + case 'functionCall' { + my $tpl; + $tpl = "%s %s\n"; + #$tpl .= "%s\n "; + $initFile->addToCase($element->{block}, + sprintf( + $tpl, + $element->{function}, + $element->{parameters}, + "" + ), + $element->{priority} + ); + + } } } @@ -378,7 +414,7 @@ sub getKernelVersion } if (!defined $newestKernelFile) { - die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath); + die; #_tr("unable to pick a kernel-file from path '%s'!", $kernelPath); } $newestKernelFile =~ /.*?-([.\-0-9]*)-([a-zA-Z]*?)$/; diff --git a/lib/OpenSLX/DistroUtils/InitFile.pm b/lib/OpenSLX/DistroUtils/InitFile.pm index a77f8ea7..a7e5da5d 100644 --- a/lib/OpenSLX/DistroUtils/InitFile.pm +++ b/lib/OpenSLX/DistroUtils/InitFile.pm @@ -143,11 +143,47 @@ sub setDesc { return $self; } +sub addFunction { + my $self = shift; + my $name = shift; + my $script = shift; + my $flags = shift || {}; + my $priority = $flags->{priority} || 5; + + push(@{$self->{'configHash'}->{'highlevelConfig'}}, + { + name => $name, + script => $script, + priority => $priority, + type => 'function' + }); + return 1; +} + +sub addFunctionCall { + my $self = shift; + my $function = shift; + my $block = shift; + my $flags = shift; + my $priority = $flags->{priority} || 5; + my $parameters = $flags->{parameters} || ""; + + push(@{$self->{'configHash'}->{'highlevelConfig'}}, + { + function => $function, + block => $block, + parameters => $parameters, + priority => $priority, + type => 'functionCall' + }); + return 1; +} + sub addScript { - my $self = shift; - my $name = shift; - my $script = shift; - my $flags = shift || {}; + my $self = shift; + my $name = shift; + my $script = shift; + my $flags = shift || {}; my $block = $flags->{block} || 'start'; my $required = $flags->{required} || 1; my $errormsg = $flags->{errormsg} || "$name failed!"; diff --git a/lib/OpenSLX/DistroUtils/Suse.pm b/lib/OpenSLX/DistroUtils/Suse.pm index 3c370489..8a41c2eb 100644 --- a/lib/OpenSLX/DistroUtils/Suse.pm +++ b/lib/OpenSLX/DistroUtils/Suse.pm @@ -19,6 +19,18 @@ use Switch; use base qw(OpenSLX::DistroUtils::Base); + +sub _renderCasePrefix +{ + return "rc_reset\n"; +} + +sub _renderFooter +{ + return "rc_exit\n"; +} + + sub _renderHighlevelConfig { my $self = shift; my $initFile = shift; @@ -121,9 +133,37 @@ sub _renderHighlevelConfig { } + case 'function' { + my $tpl; + $tpl = "%s () { \n"; + $tpl .= "%s"; + $tpl .= "\n}\n"; + $initFile->addToBlock('functions', + sprintf( + $tpl, + $element->{name}, + $element->{script} + ) + ); + + } + case 'functionCall' { + my $tpl; + $tpl = "%s %s\n"; + #$tpl .= "%s\n "; + $initFile->addToCase($element->{block}, + sprintf( + $tpl, + $element->{function}, + $element->{parameters}, + "" + ), + $element->{priority} + ); + + } } } - } sub _getInitsystemIncludes @@ -131,14 +171,4 @@ sub _getInitsystemIncludes return ". /etc/rc.status\n\n"; } -sub _renderCasePrefix -{ - return "rc_reset\n"; -} - -sub _renderFooter -{ - return "rc_exit\n"; -} - 1;
\ No newline at end of file diff --git a/lib/OpenSLX/DistroUtils/Ubuntu.pm b/lib/OpenSLX/DistroUtils/Ubuntu.pm index b2526828..915c19c6 100644 --- a/lib/OpenSLX/DistroUtils/Ubuntu.pm +++ b/lib/OpenSLX/DistroUtils/Ubuntu.pm @@ -84,9 +84,86 @@ sub _renderHighlevelConfig { $shortname ) ); + + $tpl = "log_daemon_msg \"Restarting %s\" \"%s\"\n"; + $tpl .= "\$0 stop\n"; + $tpl .= "case \"\$?\" in\n"; + $tpl .= " 0|1)\n"; + $tpl .= " \$0 start\n"; + $tpl .= " case \"\$?\" in\n"; + $tpl .= " 0) log_end_msg 0 ;;\n"; + $tpl .= " 1) log_end_msg 1 ;; # Old process is still running\n"; + $tpl .= " *) log_end_msg 1 ;; # Failed to start\n"; + $tpl .= " esac\n"; + $tpl .= " ;;\n"; + $tpl .= " *)\n"; + $tpl .= " # Failed to stop\n"; + $tpl .= " log_end_msg 1\n"; + $tpl .= " ;;\n"; + $tpl .= "esac\n"; + $tpl .= ";;\n"; + $initFile->addToCase('restart', + sprintf( + $tpl, + $shortname + ) + ); + + $tpl = "start-stop-daemon --stop --signal 1 --quiet "; + $tpl .= "--pidfile /var/run/%s.pid --name \$s\n"; + $tpl .= "return 0\n"; + $initFile->addToCase('reload', + sprintf( + $tpl, + $shortname, + $element->{binary} + ) + ); + + $tpl = "status_of_proc -p /var/run/%s.pid %s_BIN %s && exit 0 || exit \$?"; + $initFile->addToCase('status', + sprintf( + $tpl, + $element->{shortname}, + $element->{binary}, + $element->{shortname} + ) + ); + + + } + case 'function' { + my $tpl; + $tpl = "%s () { \n"; + $tpl .= "%s"; + $tpl .= "\n}\n"; + $initFile->addToBlock('functions', + sprintf( + $tpl, + $element->{name}, + $element->{script} + ) + ); + + } + case 'functionCall' { + my $tpl; + $tpl = "%s %s\n"; + #$tpl .= "%s\n "; + $initFile->addToCase($element->{block}, + sprintf( + $tpl, + $element->{function}, + $element->{parameters}, + "" + ), + $element->{priority} + ); + } + } } |