initial commit of file from CVS for smeserver-systemd-control on Sat Sep 7 21:07:29 AEST 2024
This commit is contained in:
56
root/usr/local/bin/systemdcontrol-test.pl
Normal file
56
root/usr/local/bin/systemdcontrol-test.pl
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/perl -w
|
||||
|
||||
use esmith::Service;
|
||||
|
||||
####################
|
||||
#
|
||||
# Provides the following functions
|
||||
#
|
||||
# new
|
||||
# start
|
||||
# stop
|
||||
# condrestart
|
||||
# restart
|
||||
# reload
|
||||
# is_configured
|
||||
# is_enabled
|
||||
# is_owned
|
||||
# is_running
|
||||
# is_masked
|
||||
# adjust
|
||||
# get_name
|
||||
####################
|
||||
|
||||
my $servicename = "php55-php-fpm";
|
||||
|
||||
# Create specific object
|
||||
my $systemd1 = new esmith::Service($servicename);
|
||||
|
||||
my $result1 = $systemd1->is_running();
|
||||
|
||||
if ( $result1 == 1 ) {
|
||||
print "Result 1 running $result1\n";
|
||||
}
|
||||
else {
|
||||
print "Result 1 failed $result1\n";
|
||||
}
|
||||
|
||||
# Create non-specific and set servicename later
|
||||
my $systemd2 = new esmith::Service();
|
||||
|
||||
$servicename = "sshd";
|
||||
|
||||
$systemd2->{'serviceName'} = $servicename;
|
||||
$systemd2->{'verbose'} = 1;
|
||||
|
||||
my $result2 = $systemd2->is_running();
|
||||
|
||||
if ( $result2 == 1 ) {
|
||||
print "Result 2 running $result2\n";
|
||||
}
|
||||
else {
|
||||
print "Result 2 failed $result2\n";
|
||||
}
|
||||
|
||||
# So then we can do
|
||||
# (is_configured && is_enabled) do something eg restart
|
Reference in New Issue
Block a user