aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/Fit123/cass.xml59
-rw-r--r--config/Fit123/ddns.xml38
-rw-r--r--config/Fit123/fit123.inc143
-rw-r--r--config/Fit123/fit123.xml6
4 files changed, 224 insertions, 22 deletions
diff --git a/config/Fit123/cass.xml b/config/Fit123/cass.xml
new file mode 100644
index 00000000..7d4fcf05
--- /dev/null
+++ b/config/Fit123/cass.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright></copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>cass</name>
+ <title>CASS</title>
+ <include_file>/usr/local/pkg/fit123.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Fit123</text>
+ <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>DDNS</text>
+ <url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>CASS</text>
+ <url>/pkg_edit.php?xml=cass.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <fielddescr>Clear a single state</fielddescr>
+ <fieldname>cass2</fieldname>
+ <description>
+ When your dynamic ip on wan changes, the states of your voip phone needs to be cleared. </description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Your phone ip address</fielddescr>
+ <fieldname>ypia</fieldname>
+ <description>
+ </description>
+ <type>input</type>
+ <size>15</size>
+ </field>
+ <field>
+ <fielddescr>IP address of your VOIP </fielddescr>
+ <fieldname>iaoyv</fieldname>
+ <description>
+ </description>
+ <type>input</type>
+ <size>15</size>
+ </field>
+ </fields>
+ <custom_add_php_command></custom_add_php_command>
+ <custom_php_command_before_form>cass_config();</custom_php_command_before_form>
+ <custom_php_after_form_command></custom_php_after_form_command>
+ <custom_php_validation_command></custom_php_validation_command>
+ <custom_php_resync_config_command></custom_php_resync_config_command>
+ <custom_php_install_command>Fit123_install_config();</custom_php_install_command>
+ <custom_php_deinstall_command>Fit123_install_deinstall();</custom_php_deinstall_command>
+</packagegui>
diff --git a/config/Fit123/ddns.xml b/config/Fit123/ddns.xml
index ea461254..09b34669 100644
--- a/config/Fit123/ddns.xml
+++ b/config/Fit123/ddns.xml
@@ -6,28 +6,32 @@
<description>Describe your package here</description>
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
- <name>ddns</name>
- <title>DDNS</title>
- <include_file>/usr/local/pkg/fit123.inc</include_file>
- <tabs>
- <tab>
- <text>Fit123</text>
- <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
- <active/>
+ <name>ddns</name>
+ <title>DDNS</title>
+ <include_file>/usr/local/pkg/fit123.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Fit123</text>
+ <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
+ <active/>
</tab>
- <tab>
- <text>DDNS</text>
- <url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
+ <tab>
+ <text>DDNS</text>
+ <url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
</tab>
- </tabs>
- <fields>
- <field>
- <fielddescr>Dynamic DNS</fielddescr>
- <fieldname>enable</fieldname>
+ <tab>
+ <text>CASS</text>
+ <url>/pkg_edit.php?xml=cass.xml&amp;id=0</url>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <fielddescr>Dynamic DNS</fielddescr>
+ <fieldname>enable</fieldname>
<description>
A more customize way to update dynamic dns and mainly for IP's that doesn't change very often.&lt;br&gt;
Will check for ip change every 5 min via local shell script and will only contact provider on change.&lt;br&gt;
- </description>
+ </description>
<type>checkbox</type>
</field>
<field>
diff --git a/config/Fit123/fit123.inc b/config/Fit123/fit123.inc
index fb3ed8d4..f8e5bab3 100644
--- a/config/Fit123/fit123.inc
+++ b/config/Fit123/fit123.inc
@@ -14,8 +14,8 @@ function Fit123_install_config() {
config_lock();
exec("cd ..");
//Adding new themes
- exec("tar -zxovf /usr/local/pkg/code-red.tar.gz");
- exec("mv code-red /usr/local/www/themes/code-red");
+// exec("tar -zxovf /usr/local/pkg/code-red.tar.gz");
+// exec("mv code-red /usr/local/www/themes/code-red");
//Creating backup directory
exec("mkdir /usr/local/pkg/Fit123");
exec("mkdir /usr/local/pkg/Fit123/backup");
@@ -23,8 +23,8 @@ function Fit123_install_config() {
//Date
exec("cp /usr/local/www/index.php /usr/local/pkg/Fit123/backup/");
//Captive Portal Add-On
- exec("cp /etc/inc/filter.inc /usr/local/pkg/Fit123/backup/");
- exec("cp /usr/local/www/services_captiveportal.php /usr/local/pkg/Fit123/backup/");
+// exec("cp /etc/inc/filter.inc /usr/local/pkg/Fit123/backup/");
+// exec("cp /usr/local/www/services_captiveportal.php /usr/local/pkg/Fit123/backup/");
//LTSP network boot Option
exec("cp /etc/inc/services.inc /usr/local/pkg/Fit123/backup/");
exec("cp /usr/local/www/services_dhcp.php /usr/local/pkg/Fit123/backup/");
@@ -99,6 +99,141 @@ global $config;
exec("cp /usr/local/pkg/Fit123/backup/system.php /usr/local/www/system.php");
}
+function cass_config(){
+global $config;
+// Is CASS enable or not
+ $hoba2 = $config['installedpackages']['cass']['config'][0]['cass2'];
+ if($hoba2){
+ // Is CASS.sh already added as a conjob
+ $task_key = '/usr/local/pkg/Fit123/CASS.sh';
+ $x_name='';
+ $x=0;
+ foreach($config['cron']['item'] as $item) {
+ if($item['command']==$task_key) {
+ $x_name = $x;
+ }
+ $x++;
+ }
+ unset($x);
+ if(!$x_name > 0)
+ {
+ // Add cron job CASS.sh to config.xml
+ $cron_item = array();
+ $cron_item['minute'] = "*/1";
+ $cron_item['hour'] = "*";
+ $cron_item['mday'] = "*";
+ $cron_item['month'] = "*";
+ $cron_item['wday'] = "*";
+ $cron_item['who'] = "root";
+ $cron_item['command'] = "/usr/local/pkg/Fit123/CASS.sh";
+ $config['cron']['item'][] = $cron_item;
+ write_config();
+ configure_cron();
+ }
+ }
+ else
+ {
+ // Remove CASS.sh cron entry from config.xml
+ $task_key = '/usr/local/pkg/Fit123/CASS.sh';
+ $x_name='';
+ $x=0;
+ foreach($config['cron']['item'] as $item) {
+ if($item['command']==$task_key) {
+ $x_name = $x;
+ }
+ $x++;
+ }
+ unset($x);
+ if($x_name > 0)
+ {
+ unset($config['cron']['item'][$x_name]);
+ write_config();
+ }
+ configure_cron();
+}
+
+// Create local shell script to watch for wan ip change
+ $local_voip = $config['installedpackages']['cass']['config'][0]['ypia'];
+ $voip_p = $config['installedpackages']['cass']['config'][0]['iaoyv'];
+
+ //Open CASS.sh for writing
+ $hfd = fopen("/usr/local/pkg/Fit123/CASS.sh","w");
+ if(!$hfd) {
+ log_error("could not open /usr/local/pkg/Fit123/CASS.sh for writing");
+ exit;
+ }
+ // The start of the config file
+ fwrite($hfd, '#!/bin/sh');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'lip="');
+ fwrite($hfd, $local_voip);
+ fwrite($hfd, '"');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'rip="');
+ fwrite($hfd, $voip_p);
+ fwrite($hfd, '"');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'dns_file="/usr/local/pkg/Fit123/CASS.ip"');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'EXIT_SUCCESS=0');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'EXIT_FAILURE=1');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'if [ `id -u` -ne 0 ]');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'then');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' echo "Only root may run this program."');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' exit $EXIT_FAILURE');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'fi');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'get_ip(){');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' if [ -f $dns_file ]');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' then');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' registered_ip=`cat ${dns_file}`');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' else');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' registered_ip=""');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' fi');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' current_ip=`fetch -qo- http://jackson.io/ip/`');
+ fwrite($hfd, "\n");
+ fwrite($hfd, '}');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'update_hosts(){');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' if [ "$registered_ip" != "$current_ip" ]');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' then');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' /sbin/pfctl -k $lip -k $rip');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' echo $current_ip > $dns_file');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' echo "WAN ip address changed, clearing states entries.." | logger');
+ fwrite($hfd, "\n");
+ fwrite($hfd, ' fi');
+ fwrite($hfd, "\n");
+ fwrite($hfd, '}');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'get_ip');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'update_hosts');
+ fwrite($hfd, "\n");
+ fwrite($hfd, 'exit $EXIT_SUCCESS');
+ fwrite($hfd, "\n");
+ fclose($hfd);
+
+ exec("chmod 744 /usr/local/pkg/Fit123/CASS.sh");
+}
+
function ddns_config(){
global $config;
diff --git a/config/Fit123/fit123.xml b/config/Fit123/fit123.xml
index 77db722f..fc7f85c3 100644
--- a/config/Fit123/fit123.xml
+++ b/config/Fit123/fit123.xml
@@ -26,6 +26,10 @@
<text>DDNS</text>
<url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
</tab>
+ <tab>
+ <text>CASS</text>
+ <url>/pkg_edit.php?xml=cass.xml&amp;id=0</url>
+ </tab>
</tabs>
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
@@ -40,7 +44,7 @@
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0644</chmod>
- <item>http://www.pfsense.com/packages/config/Fit123/bin/theme/code-red.tar.gz</item>
+ <item>http://www.pfsense.com/packages/config/Fit123/cass.xml</item>
</additional_files_needed>
<fields>
<field>