示例#1
0
    $rs = $DB->execute('SELECT `host` FROM `hosts` WHERE `is_foreign` = 0');
    while ($r = $rs->fetchRow()) {
        /*
        if ($r['host'] === '127.0.0.1') {  //FIXME
        	gs_log(GS_LOG_DEBUG, "Reloading local Asterisk");
        	echo "Reloading <b>local</b> Asterisk\n";
        	@ob_flush(); @flush();
        	passThru( 'sudo '. qsa(GS_DIR.'sbin/start-asterisk'), $err );
        }
        else {
        */
        gs_log(GS_LOG_DEBUG, "Reloading Asterisk on " . $r['host']);
        echo "Reloading Asterisk on <b>", $r['host'], "</b>\n";
        @ob_flush();
        @flush();
        passThru('sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=8 -l root ' . qsa($r['host']) . ' ' . qsa(GS_DIR . 'sbin/start-asterisk'), $err);
        /*
        }
        */
        echo "\n", '&rarr; <b>', $err == 0 ? 'OK' : 'ERR', '</b>', "\n\n";
    }
    @ob_implicit_flush(0);
    echo '</pre>';
}
/*
elseif ($action === 'shutdown' && $shutdown_enabled) {
?>
<form method="post" action="<?php echo GS_URL_PATH; ?>">
<?php echo gs_form_hidden($SECTION, $MODULE); ?>
<input type="hidden" name="action" value="shutdown2" />
<br />
示例#2
0
 echo " * \n";
 @ob_flush();
 @flush();
 $err = 0;
 @passThru('sudo sh -c ' . qsa(sPrintF($extract_file_cmd, qsa('./dl/update_script.sh')) . ' 2>&1'), $err);
 if ($err != 0) {
     echo "<br />\nError while extracting ./dl/update_script.sh .<br />\n";
     @exec('sudo rm -rf ' . qsa($gpbx_userdata . 'upgrades/dl/download') . ' 2>>/dev/null');
     @exec('sudo rm -rf ' . qsa($gpbx_userdata . 'upgrades/dl/update_script.sh') . ' 2>>/dev/null');
     return;
 }
 echo " * \n";
 @ob_flush();
 @flush();
 $err = 0;
 @passThru('sudo sh -c ' . qsa(sPrintF($extract_file_cmd, qsa('./upgrade-info')) . ' 2>&1'), $err);
 if ($err != 0) {
     echo "<br />\nError while extracting ./upgrade-info .<br />\n";
     @exec('sudo rm -rf ' . qsa($gpbx_userdata . 'upgrades/dl/download') . ' 2>>/dev/null');
     @exec('sudo rm -rf ' . qsa($gpbx_userdata . 'upgrades/dl/update_script.sh') . ' 2>>/dev/null');
     @exec('sudo rm -rf ' . qsa($gpbx_userdata . 'upgrades/upgrade-info') . ' 2>>/dev/null');
     return;
 }
 echo " * \n";
 @ob_flush();
 @flush();
 @exec('sudo sh -c ' . qsa('echo -n "yes" > ' . qsa($gpbx_userdata . 'upgrades/upgrade-avail') . ' 2>>/dev/null') . ' 2>>/dev/null');
 echo " * \n";
 @ob_flush();
 @flush();
 sleep(1);
示例#3
0
#!/usr/bin/php -q
<?php 
#
# nothing special - just to save some typing
#
passThru('mysqldump --opt --skip-extended-insert --databases asterisk' . '| sed -e \'s/DEFINER *= *[^ ]*/DEFINER=CURRENT_USER()/g\'');
echo "\n";
示例#4
0
<?php 
} else {
    $action = @$_POST['action'];
    if ($action === 'shutdown2' || $action === 'reboot2') {
        if (@$_REQUEST['confirm'] === 'yes') {
            $shutdown = find_executable('shutdown', array('/sbin/', '/bin/'));
            if (!$shutdown) {
                echo 'shutdown not found.', "\n";
            } else {
                if (@file_exists('/usr/sbin/gs-pre-shutdown')) {
                    $err = 0;
                    $out = array();
                    @exec('sudo /usr/sbin/gs-pre-shutdown 2>>/dev/null', $out, $err);
                }
                if ($action === 'shutdown2') {
                    $shutdown_args = ' -h -P now';
                } else {
                    $shutdown_args = ' -r now';
                }
                @flush();
                @ob_implicit_flush(1);
                echo '<pre style="margin:0.9em 0.1em; padding:0.3em; background:#eee;">';
                $err = 0;
                passThru('sudo ' . $shutdown . ' ' . $shutdown_args . ' 2>&1', $err);
                echo "\n";
                echo '&rarr; <b>', $err === 0 ? 'OK' : 'ERR (' . $err . ')', '</b>';
                echo '</pre>';
            }
        }
    }
}