Ejemplo n.º 1
0
function squid_db()
{
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $squid = LOCATE_SQUID_BIN();
    $SCRIPTFILENAME = dirname(__FILE__) . "/exec.squid-db.php";
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: PHP...: {$php}\n";
        echo "Starting......: " . date("H:i:s") . " [INIT]: Squid.: {$squid}\n";
        echo "Starting......: " . date("H:i:s") . " [INIT]: Script: {$SCRIPTFILENAME}\n";
    }
    if (!is_file($squid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon (squid-db) no such squid\n";
        }
        return;
    }
    if (!is_file("/etc/artica-postfix/FROM_ISO")) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon (squid-db) not from ISO\n";
        }
        return;
    }
    $f[] = "#!/bin/sh";
    $f[] = "### BEGIN INIT INFO";
    $f[] = "# Provides:         squid-db";
    $f[] = "# Required-Start:    \$local_fs \$remote_fs \$syslog \$named \$network \$time";
    $f[] = "# Required-Stop:     \$local_fs \$remote_fs \$syslog \$named \$network";
    $f[] = "# Should-Start:";
    $f[] = "# Should-Stop:";
    $f[] = "# Default-Start:     2 3 4 5";
    $f[] = "# Default-Stop:      0 1 6";
    $f[] = "# Short-Description: Squid MySQL Statistics database";
    $f[] = "# chkconfig: 2345 11 89";
    $f[] = "# description: Squid MySQL Statistics database";
    $f[] = "### END INIT INFO";
    $f[] = "case \"\$1\" in";
    $f[] = " start)";
    $f[] = "    {$php} {$SCRIPTFILENAME} --start --byinitd \$2 \$3";
    $f[] = "    ;;";
    $f[] = "";
    $f[] = "  stop)";
    $f[] = "    {$php} {$SCRIPTFILENAME} --stop --byinitd --force \$2 \$3";
    $f[] = "    ;;";
    $f[] = "";
    $f[] = " restart)";
    $f[] = "    {$php} {$SCRIPTFILENAME} --stop --byinitd --force \$2 \$3";
    $f[] = "    {$php} {$SCRIPTFILENAME} --start --byinitd \$2 \$3";
    $f[] = "    ;;";
    $f[] = "";
    $f[] = "  *)";
    $f[] = "    echo \"Usage: \$0 {start|stop|restart} {ldap|} (+ 'debug' for more infos)\"";
    $f[] = "    exit 1";
    $f[] = "    ;;";
    $f[] = "esac";
    $f[] = "exit 0\n";
    @file_put_contents("/etc/init.d/squid-db", @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon (squid-db) /etc/init.d/squid-db done\n";
    }
    @chmod("/etc/init.d/squid-db", 0755);
    if (is_file('/usr/sbin/update-rc.d')) {
        shell_exec('/usr/sbin/update-rc.d -f squid-db defaults >/dev/null 2>&1');
    }
    if (is_file('/sbin/chkconfig')) {
        shell_exec('/sbin/chkconfig --add squid-db >/dev/null 2>&1');
        shell_exec('/sbin/chkconfig --level 2345 squid-db on >/dev/null 2>&1');
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon (squid-db) success...\n";
    }
}
Ejemplo n.º 2
0
function squid_cache_log()
{
    $squid = LOCATE_SQUID_BIN();
    if (!is_file($squid)) {
        return;
    }
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $dirname = dirname(__FILE__);
    $chmod = $unix->find_program("chmod");
    $conf[] = "#! /bin/sh";
    $conf[] = "# /etc/init.d/cache-tail";
    $conf[] = "#";
    $conf[] = "# cache-tail Debian init script";
    $conf[] = "#";
    $conf[] = "### BEGIN INIT INFO";
    $conf[] = "# Provides:          cache-tail";
    $conf[] = "# Required-Start:    \$syslog";
    $conf[] = "# Required-Stop:     \$syslog";
    $conf[] = "# Should-Start:      \$local_fs";
    $conf[] = "# Should-Stop:       \$local_fs";
    $conf[] = "# Default-Start:     2 3 4 5";
    $conf[] = "# Default-Stop:      1";
    $conf[] = "# Short-Description: Launch squid-tail on cache.log server";
    $conf[] = "# Description:       Launch squid-tail on cache.log server";
    $conf[] = "### END INIT INFO";
    $conf[] = "";
    $conf[] = "case \"\$1\" in";
    $conf[] = " start)";
    $conf[] = "    {$php5} {$dirname}/exec.init-tail-cache.php --start \$1 \$2";
    $conf[] = "    ;;";
    $conf[] = "";
    $conf[] = "  stop)";
    $conf[] = "    {$php5} {$dirname}/exec.init-tail-cache.php --stop \$1 \$2";
    $conf[] = "    ;;";
    $conf[] = "";
    $conf[] = " restart)";
    $conf[] = "\t  {$php5} {$dirname}/exec.init-tail-cache.php --stop \$1 \$2";
    $conf[] = "     {$php5} {$dirname}/exec.init-tail-cache.php --start \$1 \$2";
    $conf[] = "    ;;";
    $conf[] = "";
    $conf[] = " reload)";
    $conf[] = "     {$php5} {$dirname}/exec.init-tail-cache.php --stop \$1 \$2";
    $conf[] = "     {$php5} {$dirname}/exec.init-tail-cache.php --stop \$1 \$2";
    $conf[] = "    ;;";
    $conf[] = "";
    $conf[] = "";
    $conf[] = "  *)";
    $conf[] = "    echo \"Usage: \$0 {start|stop|restart|reload}\"";
    $conf[] = "    exit 1";
    $conf[] = "    ;;";
    $conf[] = "esac";
    $conf[] = "exit 0\n";
    @file_put_contents("/etc/init.d/cache-tail", @implode("\n", $conf));
    $debianbin = $unix->find_program("update-rc.d");
    $redhatbin = $unix->find_program("chkconfig");
    shell_exec("{$chmod} +x /etc/init.d/cache-tail >/dev/null 2>&1");
    if (is_file($debianbin)) {
        shell_exec("{$debianbin} -f cache-tail defaults >/dev/null 2>&1");
        return;
    }
    if (is_file($redhatbin)) {
        shell_exec("{$redhatbin} --add cache-tail >/dev/null 2>&1");
        shell_exec("{$redhatbin} --level 2345 cache-tail on >/dev/null 2>&1");
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Squid-Cache Tail success...\n";
    }
}