summaryrefslogtreecommitdiffstats
path: root/etc/phpshellsessions
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2007-11-23 23:58:39 +0000
committerScott Ullrich <sullrich@pfsense.org>2007-11-23 23:58:39 +0000
commitbc4822363ff242bdcde22d0ed49609405494195d (patch)
tree806a31f69f1bc3259af926132d11e9a15e7eb303 /etc/phpshellsessions
parentbb1a546c49dd69d1ab781aacfa22b72e778e5433 (diff)
downloadpfsense-bc4822363ff242bdcde22d0ed49609405494195d.zip
pfsense-bc4822363ff242bdcde22d0ed49609405494195d.tar.gz
Add pfSense php shell playback scripts
Diffstat (limited to 'etc/phpshellsessions')
-rw-r--r--etc/phpshellsessions/cvssync133
-rw-r--r--etc/phpshellsessions/restartdhcpd4
-rw-r--r--etc/phpshellsessions/restartftphelper16
-rw-r--r--etc/phpshellsessions/restartipsec2
4 files changed, 155 insertions, 0 deletions
diff --git a/etc/phpshellsessions/cvssync b/etc/phpshellsessions/cvssync
new file mode 100644
index 0000000..404f7ab
--- /dev/null
+++ b/etc/phpshellsessions/cvssync
@@ -0,0 +1,133 @@
+/* cvs_sync
+ * Written by Scott Ullrich
+ * (C)2005 Scott Ullrich
+ * Part of the pfSense project pfSsh.php subsystem
+ * For users of cvs accounts to keep your test machine up to date
+ */
+
+function create_supfile($branch) {
+
+ if($branch == "HEAD")
+ $BRANCHTAG = ".";
+ else
+ $BRANCHTAG = $branch;
+
+ $supfile = "
+*default host=cvs.pfsense.com
+*default base=/home/pfsense/$branch
+*default release=cvs tag=$BRANCHTAG
+*default delete use-rel-suffix
+pfSense
+*default compress
+";
+
+ file_put_contents("/var/etc/pfSense-supfile", $supfile);
+}
+
+unlink_if_exists("/tmp/config.cache");
+
+if(!file_exists("/usr/local/bin/cvsup")) {
+ echo "Cannot find cvsup, pkg_add in progress...";
+ system("/usr/sbin/pkg_add -r http://www.pfsense.com/packages/All/cvsup-without-gui-16.1h_2.tbz");
+}
+
+if(!file_exists("/usr/bin/cvs")) {
+ echo "Cannot find cvs, fetching static cvs...";
+ system("fetch -o /usr/bin/cvs http://www.pfsense.com/~sullrich/extra/cvs");
+ system("chmod a+rx /usr/bin/cvs");
+}
+
+global $argv;
+
+/* NOTE: Set branches here */
+$branches = array("HEAD" => "Main development branch",
+ "RELENG_1" => "1.2 Release branch",
+ "RELENG_1_2" => "1.3 development branch");
+
+if(!$argv[3]) {
+ echo "\nPlease select which branch you would like:\n\n";
+ foreach($branches as $branchname => $branchdesc) {
+ echo "{$branchname} - {$branchdesc}\n";
+ }
+ $branch = readline("\n> ");
+ echo "\n";
+} else {
+ $branch = $argv[3];
+}
+
+create_supfile($branch);
+
+$CODIR = "/home/pfsense/$branch";
+
+exec("mkdir -p /home/pfsense/$BRANCHTAG");
+
+$found = false;
+foreach($branches as $branchname => $branchdesc) {
+ if($branchname == $branch)
+ $found = true;
+}
+if(!$found) {
+ echo "\nInvalid branch.\n";
+ exit;
+}
+
+echo "===> Checking out $branch\n";
+exec("mkdir -p /home/pfsense/$branch");
+system("cvsup /var/etc/pfSense-supfile");
+exec("rm -rf /usr/local/www/includes/*");
+exec("rm -rf /usr/local/www/javascript/*");
+exec("find /usr/local/www -name \"*.js\" -exec rm {} \;");
+
+exec("mkdir -p /tmp/lighttpd/cache/compress/");
+
+exec("cd ${CODIR}/ && find . -name CVS -exec rm -rf {} \; 2>/dev/null");
+exec("cd ${CODIR}/ && find . -name pfSense.tgz -exec rm {} \; 2>/dev/null");
+exec("rm -rf ${CODIR}/conf*");
+exec("rm ${CODIR}/pfSense/usr/local/www/trigger_initial_wizard 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/crontab 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/master.passwd 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/passwd 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/fstab 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/ttys 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/group 2>/dev/null");
+exec("rm ${CODIR}/pfSense/etc/fstab 2>/dev/null");
+exec("rm ${CODIR}/pfSense/boot/device.hints 2>/dev/null");
+exec("rm ${CODIR}/pfSense/boot/loader.conf 2>/dev/null");
+exec("rm ${CODIR}/pfSense/boot/loader.rc 2>/dev/null");
+exec("rm -rf ${CODIR}/pfSense/conf/ 2>/dev/null");
+exec("rm -rf ${CODIR}/pfSense/cf/ 2>/dev/null");
+exec("rm -rf ${CODIR}/pfSense/root/.shrc");
+exec("rm -rf ${CODIR}/pfSense/root/.tcshrc");
+
+echo "Installing new files...\n";
+
+exec("cd $CODIR/pfSense ; tar -cpf - . | (cd / ; tar -Uxpf -)");
+
+echo "CVS Sync Complete\n";
+
+echo "Removing FAST-CGI temporary files...\n";
+exec("find /tmp -name \"*php*\" -exec rm -rf {} \;");
+
+exec("rm -rf /tmp/xcache/* 2>/dev/null");
+
+echo "Upgrading configuration...\n";
+
+convert_config();
+/* setup php.ini */
+convert_config();
+sync_webgui_passwords();
+
+echo "Restarting check_reload_status...\n";
+exec("killall check_reload_status");
+mwexec_bg("nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status");
+
+echo "Configuring filter...";
+exec("/etc/rc.filter_configure_sync");
+exec("pfctl -f /tmp/rules.debug");
+echo "\n";
+
+echo "===> Checkout complete. Your system is now sync'd. Scripting terminating.\n";
+
+exec("killall php");
+touch("/tmp/restart_webgui");
+
diff --git a/etc/phpshellsessions/restartdhcpd b/etc/phpshellsessions/restartdhcpd
new file mode 100644
index 0000000..e24c842
--- /dev/null
+++ b/etc/phpshellsessions/restartdhcpd
@@ -0,0 +1,4 @@
+! echo "Killing dhcp server..."
+! killall dhcpd
+! echo "Restarting dhcp server..."
+services_dhcpd_configure();
diff --git a/etc/phpshellsessions/restartftphelper b/etc/phpshellsessions/restartftphelper
new file mode 100644
index 0000000..61c8803
--- /dev/null
+++ b/etc/phpshellsessions/restartftphelper
@@ -0,0 +1,16 @@
+! echo "===> Beginning restartftphelper."
+! echo "Killing ftp-proxy if started..."
+= killall ftp-proxy
+! echo "Killing pftpx if started..."
+= killall pftpx
+! echo "Killing ftpsesame if started..."
+= killall ftpsesame
+! echo "Running php function system_start_ftp_helpers()..."
+system_start_ftp_helpers();
+! echo "Checking if ftp-proxy is running..."
+= ps awux | grep "ftp-proxy"
+! echo "Checking if pftpx is running..."
+= ps awux | grep "pftpx"
+! echo "Checking if ftpsesame is running..."
+= ps awux | grep "ftpsesame"
+! echo "===> End of restartftphelper."
diff --git a/etc/phpshellsessions/restartipsec b/etc/phpshellsessions/restartipsec
new file mode 100644
index 0000000..f325ed2
--- /dev/null
+++ b/etc/phpshellsessions/restartipsec
@@ -0,0 +1,2 @@
+! echo "Restarting ipsec..."
+vpn_ipsec_configure();
OpenPOWER on IntegriCloud