File: //proc/self/root/scripts.20110531.215904.25158/restartsrv_sshd
#!/usr/bin/perl
# cpanel - restartsrv_sshd Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; }
use RestartSrv;
use Cpanel::OSSys ();
use strict;
eval {
local $SIG{'__DIE__'};
require Cpanel::Rlimit;
Cpanel::Rlimit::set_rlimit_to_infinity();
};
setuppath();
my ( $system, $nodename, $release, $version, $machine ) = Cpanel::OSSys::uname();
my ( $restart, $check, $status ) = parseargv();
my $iscript = '';
my $initdir = '';
my $processowner = 'root';
my $service = 'sshd';
( $processowner, $service ) = servicefixup( $system, $service );
my $disabled = 0;
if ( -e '/etc/sshddisable' ) {
$disabled = 1;
}
if ( $restart && !$disabled ) {
my $lock_file = '/var/run/restartsrv_sshd.lock';
lock_file($lock_file);
$iscript = getinitfile( $service, $system );
my $manualstart = needsmanualstart( $system, $service );
if ( $iscript ne '' && $manualstart != 1 ) {
nooutputsystem( $iscript, 'stop' );
if ( $ENV{'SSH_TTY'} eq '' && $ENV{'SSH_CLIENT'} eq '' ) {
doomedprocess($service);
}
if ( $restart != -1 ) {
system( $iscript, 'start' );
}
}
else {
my ( $servicebin, $serviceflags ) = getmanualserviceinfo( $system, $service );
if ( $ENV{'SSH_TTY'} eq '' && $ENV{'SSH_CLIENT'} eq '' ) {
doomedprocess($service);
}
if ( $restart != -1 ) {
nooutputsystem( $servicebin, $serviceflags );
}
}
unlink $lock_file if -e $lock_file;
}
elsif ($status) {
#--status (show ps)
if ($disabled) {
print "$service is disabled\n";
}
else {
print check_service( 'service' => $service, 'user' => $processowner );
}
}
elsif ($check) {
exit if ($disabled);
if ( check_service( 'service' => $service, 'user' => $processowner ) eq '' ) {
print "$service is not running\n";
}
}