function buildScript() { script_uninstall(); delete(); }
function buildScript() { $unix = new unix(); $sock = new sockets(); $GLOBALS["echobin"] = $unix->find_program("echo"); $php = $unix->LOCATE_PHP5_BIN(); $sh = array(); $parse_rules = parse_rules(); if ($parse_rules == null) { script_uninstall(); return; } $sh[] = "#!/bin/sh -e"; $sh[] = "### BEGIN INIT INFO"; $sh[] = "# Builded on " . date("Y-m-d H:i:s"); $sh[] = "# Provides: fw-stats"; $sh[] = "# Required-Start: \$local_fs"; $sh[] = "# Required-Stop: \$local_fs"; $sh[] = "# Should-Start:\t\t"; $sh[] = "# Should-Stop:\t\t"; $sh[] = "# Default-Start: S"; $sh[] = "# Default-Stop: 0 6"; $sh[] = "# Short-Description: start and stop the Firewall-stats"; $sh[] = "# Description: Artica Firewall Statistics Appliance"; $sh[] = "### END INIT INFO"; $sh[] = "case \"\$1\" in"; $sh[] = "start)"; $sh[] = "if [ ! -f /etc/rsyslog.d/stats-appliance.conf ]; then"; $sh[] = "{$GLOBALS["echobin"]} \"Building syslog configuration\""; $sh[] = "\t{$php} /usr/share/artica-postfix/exec.syslog-engine.php --build-server || true"; $sh[] = "\t/etc/init.d/rsyslog restart || true"; $sh[] = "fi"; $sh[] = "if [ -f /etc/rsyslog.d/stats-appliance.conf ]; then"; $sh[] = "{$GLOBALS["echobin"]} \"Syslog configuration [OK]\""; $sh[] = "fi"; $sh[] = "{$GLOBALS["echobin"]} \"Removing Iptables rules\""; $sh[] = $php . " " . __FILE__ . " --delete >/dev/null || true"; $sh[] = $parse_rules; $sh[] = "{$GLOBALS["echobin"]} \"Iptables rules done.\""; $sh[] = ";;"; $sh[] = " stop)"; $sh[] = $php . " " . __FILE__ . " --delete >/dev/null || true"; $sh[] = ";;"; $sh[] = " reconfigure)"; $sh[] = "{$GLOBALS["echobin"]} \"Removing Iptables rules\""; $sh[] = $php . " " . __FILE__ . " --delete >/dev/null || true"; $sh[] = $php . " " . __FILE__ . " >/dev/null || true"; $sh[] = "{$GLOBALS["echobin"]} \"Iptables rules done.\""; $sh[] = "{$GLOBALS["echobin"]} \"Running builded script\""; $sh[] = "/etc/init.d/iptables-statsapp start"; $sh[] = ";;"; $sh[] = " restart)"; $sh[] = "{$GLOBALS["echobin"]} \"Removing Iptables rules\""; $sh[] = $php . " " . __FILE__ . " --delete >/dev/null || true"; $sh[] = $php . " " . __FILE__ . " >/dev/null || true"; $sh[] = "{$GLOBALS["echobin"]} \"Iptables rules done.\""; $sh[] = "{$GLOBALS["echobin"]} \"Running builded script\""; $sh[] = "/etc/init.d/iptables-statsapp start"; $sh[] = ";;"; $sh[] = "*)"; $sh[] = " echo \"Usage: \$0 {start ,restart,configure or stop only}\""; $sh[] = "exit 1"; $sh[] = ";;"; $sh[] = "esac"; $sh[] = "exit 0\n"; @file_put_contents("/etc/init.d/iptables-statsapp", @implode("\n", $sh)); script_install(); }