aboutsummaryrefslogtreecommitdiffstats
path: root/config/anyterm/anyterm.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-10-16 22:31:01 -0400
committerScott Ullrich <sullrich@pfsense.org>2009-10-16 22:31:01 -0400
commitb445055499c8ed51acfaaa0020616c06f558de68 (patch)
treeae87e72bc633162275700932a1db696d6cfec6ec /config/anyterm/anyterm.inc
parenta27686574094958e8bec10103e1ffd9ebd58bd60 (diff)
downloadpfsense-packages-b445055499c8ed51acfaaa0020616c06f558de68.tar.gz
pfsense-packages-b445055499c8ed51acfaaa0020616c06f558de68.tar.bz2
pfsense-packages-b445055499c8ed51acfaaa0020616c06f558de68.zip
Adding anyterm package + stunnel support
Diffstat (limited to 'config/anyterm/anyterm.inc')
-rw-r--r--config/anyterm/anyterm.inc108
1 files changed, 108 insertions, 0 deletions
diff --git a/config/anyterm/anyterm.inc b/config/anyterm/anyterm.inc
new file mode 100644
index 00000000..6ae26147
--- /dev/null
+++ b/config/anyterm/anyterm.inc
@@ -0,0 +1,108 @@
+<?php
+/*
+ anyterm.inc
+ pfSense package (http://www.pfSense.com)
+ Copyright (C) 2009 Scott Ullrich <sullrich@pfsense.org>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+function anyterm_deinstall() {
+ global $g, $config;
+ conf_mount_rw();
+ exec("killall anytermd");
+ exec("rm /usr/local/etc/rc.d/anyterm.sh");
+ exec("rm /usr/local/sbin/anytermd");
+}
+
+function anyterm_install() {
+ global $g, $config;
+
+ conf_mount_rw();
+
+ // Grab latest version of executablevi /
+ $freebsdv=trim(`uname -r | cut -d'.' -f1`);
+ `fetch -q -o /usr/local/sbin/ http://www.pfsense.org/packages/config/anyterm/binaries{$freebsdv}/anytermd`;
+ exec("chmod a+rx /usr/local/sbin/anyterm");
+
+ if($config['installedpackages']['anyterm']['config']['username'])
+ $port = " --port {$config['installedpackages']['anyterm']['config']['port']}";
+
+ // This will bring up the pfSense style menu
+ $anytermd_command = "anytermd --user root --command \"/usr/libexec/getty Pc\" --auth trivial $port";
+
+ $anyterm = <<<EOD
+#!/bin/sh
+
+# PROVIDE: anyterm
+# REQUIRE: LOGIN
+# KEYWORD: FreeBSD
+
+. /etc/rc.subr
+
+name="anyterm"
+rcvar=`set_rcvar`
+command="/usr/local/bin/anyterm"
+anyterm_enable=\${anyterm-"YES"}
+
+start_cmd="anyterm_start"
+stop_postcmd="anyterm_stop"
+
+load_rc_config \$name
+
+anyterm_start () {
+ if [ -f /var/etc/anyterm.conf ]; then
+ /usr/bin/env \
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
+ killall anytermd \
+ $anytermd_command
+ fi
+}
+
+anyterm_stop () {
+ echo "Stopping anyterm."
+ killall anyterm
+}
+
+run_rc_command "\$1"
+
+EOD;
+
+ // Write out file
+ $fd = fopen("/usr/local/etc/rc.d/anyterm.sh", "w");
+ fwrite($fd, $anyterm);
+ fclose($fd);
+ // Make executable
+ exec("chmod a+rx /usr/local/etc/rc.d/anyterm.sh")
+
+ // Write out Anyterm configuration file (username and password for auth)
+ $fd = fopen("/var/etc/anyterm.conf", "w");
+ fwrite($fd, $config['installedpackages']['anyterm']['config']['username'] . "\n");
+ fwrite($fd, $config['installedpackages']['anyterm']['config']['password'] . "\n");
+ fclose($fd);
+ exec("chmod a-r /var/etc/anyterm.conf ; chmod ug+r /var/etc/anyterm.conf ; killall anytermd");
+ exec($anytermd_command);
+
+}
+
+?> \ No newline at end of file