smeserver-systemd-control/root/usr/local/bin/systemdcontrol-test.pl

57 lines
943 B
Perl
Raw Normal View History

#!/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