mirror of
https://github.com/netbirdio/FreeBSD-ports.git
synced 2026-05-22 18:42:42 -07:00
Importing sysutils/pfSense-pkg-Shellcmd from pfPorts
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= pfSense-pkg-Shellcmd
|
||||
PORTVERSION= 0.6
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= # empty
|
||||
DISTFILES= # empty
|
||||
EXTRACT_ONLY= # empty
|
||||
|
||||
MAINTAINER= coreteam@pfsense.org
|
||||
COMMENT= pfSense package Shellcmd
|
||||
|
||||
NO_BUILD= yes
|
||||
NO_MTREE= yes
|
||||
|
||||
SUB_FILES= pkg-install pkg-deinstall
|
||||
SUB_LIST= PORTNAME=${PORTNAME}
|
||||
|
||||
do-extract:
|
||||
${MKDIR} ${WRKSRC}
|
||||
|
||||
do-install:
|
||||
${MKDIR} ${STAGEDIR}${PREFIX}/pkg
|
||||
${MKDIR} ${STAGEDIR}${PREFIX}/www/packages/shellcmd
|
||||
${MKDIR} ${STAGEDIR}${DATADIR}
|
||||
${INSTALL_DATA} -m 0644 ${FILESDIR}${PREFIX}/pkg/shellcmd.xml \
|
||||
${STAGEDIR}${PREFIX}/pkg
|
||||
${INSTALL_DATA} -m 0755 ${FILESDIR}${PREFIX}/pkg/shellcmd.xml \
|
||||
${STAGEDIR}${PREFIX}/pkg
|
||||
${INSTALL_DATA} -m 0755 ${FILESDIR}${PREFIX}/pkg/shellcmd.inc \
|
||||
${STAGEDIR}${PREFIX}/pkg
|
||||
${INSTALL_DATA} -m 0755 ${FILESDIR}${PREFIX}/www/packages/shellcmd/shellcmd.php \
|
||||
${STAGEDIR}${PREFIX}/www/packages/shellcmd
|
||||
${INSTALL_DATA} -m 0755 ${FILESDIR}${PREFIX}/www/packages/shellcmd/shellcmd_edit.php \
|
||||
${STAGEDIR}${PREFIX}/www/packages/shellcmd
|
||||
${INSTALL_DATA} ${FILESDIR}${DATADIR}/info.xml \
|
||||
${STAGEDIR}${DATADIR}
|
||||
|
||||
.include <bsd.port.mk>
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/local/sbin/fcgicli -f /etc/rc.packages -d "pkg=%%PORTNAME%%&when=${2}"
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "${2}" != "POST-INSTALL" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/local/sbin/fcgicli -f /etc/rc.packages -d "pkg=%%PORTNAME%%&when=${2}"
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
/* ========================================================================== */
|
||||
/*
|
||||
shellcmd.inc
|
||||
Copyright (C) 2008 Mark J Crane
|
||||
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.
|
||||
*/
|
||||
|
||||
require_once("services.inc");
|
||||
|
||||
if (!function_exists("pkg_is_service_running")) {
|
||||
function pkg_is_service_running($servicename)
|
||||
{
|
||||
exec("/bin/ps ax | awk '{ print $5 }'", $psout);
|
||||
array_shift($psout);
|
||||
foreach($psout as $line) {
|
||||
$ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line)))));
|
||||
}
|
||||
if(is_service_running($servicename, $ps) or is_process_running($servicename) ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function shellcmd_sync_package()
|
||||
{
|
||||
|
||||
global $config;
|
||||
//synch shellcmd tab
|
||||
//configure_shellcmd();
|
||||
//$handle = popen("/usr/local/etc/rc.d/shellcmd.sh stop", "r");
|
||||
//pclose($handle);
|
||||
//$handle = popen("/usr/local/etc/rc.d/shellcmd.sh start", "r");
|
||||
//pclose($handle);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function shellcmd_install_command()
|
||||
{
|
||||
|
||||
global $config;
|
||||
conf_mount_rw();
|
||||
shellcmd_sync_package();
|
||||
conf_mount_ro();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function shellcmd_deinstall_command()
|
||||
{
|
||||
|
||||
conf_mount_rw();
|
||||
$handle = popen("/usr/local/etc/rc.d/shellcmd.sh stop", "r");
|
||||
//unlink_if_exists("/usr/local/etc/rc.d/shellcmd.sh");
|
||||
conf_mount_ro();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
|
||||
<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
|
||||
<packagegui>
|
||||
<copyright>
|
||||
<![CDATA[
|
||||
/* $Id$ */
|
||||
/* ========================================================================== */
|
||||
/*
|
||||
shellcmd.xml
|
||||
Copyright (C) 2008 Mark J Crane
|
||||
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.
|
||||
*/
|
||||
/* ========================================================================== */
|
||||
]]>
|
||||
</copyright>
|
||||
<description>Shellcmd</description>
|
||||
<requirements>Describe your package requirements here</requirements>
|
||||
<faq>Currently there are no FAQ items provided.</faq>
|
||||
<name>Shellcmd Settings</name>
|
||||
<version>0.4</version>
|
||||
<title>Settings</title>
|
||||
<include_file>/usr/local/pkg/shellcmd.inc</include_file>
|
||||
<menu>
|
||||
<name>Shellcmd</name>
|
||||
<tooltiptext>shellcmd settings.</tooltiptext>
|
||||
<section>Services</section>
|
||||
<configfile>shellcmd.xml</configfile>
|
||||
<url>/packages/shellcmd/shellcmd.php</url>
|
||||
</menu>
|
||||
<tabs>
|
||||
<tab>
|
||||
<text>Settings</text>
|
||||
<url>/pkg_edit.php?xml=shellcmd.xml&id=0</url>
|
||||
<active/>
|
||||
</tab>
|
||||
<tab>
|
||||
<text>Settings</text>
|
||||
<url>/packages/shellcmd/shellcmd.php</url>
|
||||
<active/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<configpath>installedpackages->package->$packagename->configuration->shellcmd</configpath>
|
||||
<additional_files_needed>
|
||||
<prefix>/usr/local/pkg/</prefix>
|
||||
<chmod>0755</chmod>
|
||||
<item>https://packages.pfsense.org/packages/config/shellcmd/shellcmd.xml</item>
|
||||
</additional_files_needed>
|
||||
<additional_files_needed>
|
||||
<prefix>/usr/local/pkg/</prefix>
|
||||
<chmod>0755</chmod>
|
||||
<item>https://packages.pfsense.org/packages/config/shellcmd/shellcmd.inc</item>
|
||||
</additional_files_needed>
|
||||
<additional_files_needed>
|
||||
<prefix>/usr/local/www/packages/shellcmd/</prefix>
|
||||
<chmod>0755</chmod>
|
||||
<item>https://packages.pfsense.org/packages/config/shellcmd/shellcmd.php</item>
|
||||
</additional_files_needed>
|
||||
<additional_files_needed>
|
||||
<prefix>/usr/local/www/packages/shellcmd/</prefix>
|
||||
<chmod>0755</chmod>
|
||||
<item>https://packages.pfsense.org/packages/config/shellcmd/shellcmd_edit.php</item>
|
||||
</additional_files_needed>
|
||||
<fields>
|
||||
<field>
|
||||
<fielddescr>Variable One</fielddescr>
|
||||
<fieldname>var1</fieldname>
|
||||
<description>Enter the variable one here.</description>
|
||||
<type>input</type>
|
||||
</field>
|
||||
<field>
|
||||
<fielddescr>Variable Two</fielddescr>
|
||||
<fieldname>var1</fieldname>
|
||||
<description>Enter the variable one here.</description>
|
||||
<type>input</type>
|
||||
</field>
|
||||
</fields>
|
||||
<custom_add_php_command>
|
||||
</custom_add_php_command>
|
||||
<custom_php_resync_config_command>
|
||||
shellcmd_sync_package();
|
||||
</custom_php_resync_config_command>
|
||||
<custom_delete_php_command>
|
||||
shellcmd_sync_package();
|
||||
</custom_delete_php_command>
|
||||
<custom_php_install_command>
|
||||
shellcmd_install_command();
|
||||
</custom_php_install_command>
|
||||
<custom_php_deinstall_command>
|
||||
shellcmd_deinstall_command();
|
||||
</custom_php_deinstall_command>
|
||||
</packagegui>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<pfsensepkgs>
|
||||
<package>
|
||||
<name>Shellcmd</name>
|
||||
<descr><![CDATA[The shellcmd utility is used to manage commands on system startup.]]></descr>
|
||||
<category>Services</category>
|
||||
<config_file>https://packages.pfsense.org/packages/config/shellcmd/shellcmd.xml</config_file>
|
||||
<version>0.6</version>
|
||||
<status>Beta</status>
|
||||
<required_version>2.2</required_version>
|
||||
<maintainer>markjcrane@gmail.com</maintainer>
|
||||
<configurationfile>shellcmd.xml</configurationfile>
|
||||
</package>
|
||||
</pfsensepkgs>
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
shellcmd.php
|
||||
Copyright (C) 2008 Mark J Crane
|
||||
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.
|
||||
*/
|
||||
|
||||
require("guiconfig.inc");
|
||||
require("/usr/local/pkg/shellcmd.inc");
|
||||
|
||||
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
|
||||
$a_shellcmd = &$config['system']['shellcmd'];
|
||||
//$a_afterfilterchangeshellcmd = &$config['system']['afterfilterchangeshellcmd'];
|
||||
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<p class="pgtitle">Shellcmd: Settings</p>
|
||||
|
||||
<div id="mainlevel">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td class="tabnavtbl">
|
||||
<?php
|
||||
|
||||
$tab_array = array();
|
||||
$tab_array[] = array(gettext("Settings"), false, "/packages/shellcmd/shellcmd.php");
|
||||
display_top_tabs($tab_array);
|
||||
|
||||
?>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td class="tabcont" >
|
||||
|
||||
<form action="shellcmd.php" method="post" name="iform" id="iform">
|
||||
<?php
|
||||
|
||||
//if ($savemsg) print_info_box($savemsg);
|
||||
//if (file_exists($d_hostsdirty_path)): echo"<p>";
|
||||
//print_info_box_np("This is an info box.");
|
||||
//echo"<br />";
|
||||
//endif;
|
||||
|
||||
?>
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<td><p><!--<span class="vexpl"><span class="red"><strong>shellcmd<br></strong></span>-->
|
||||
The shellcmd utility is used to manage commands on system startup.
|
||||
<br /><br />
|
||||
<!--For more information see: <a href='http://www.' target='_blank'>http://www.</a>-->
|
||||
</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="50%" class="listhdrr">Command</td>
|
||||
<td width="30%" class="listhdrr">Type</td>
|
||||
<td width="10%" class="list">
|
||||
|
||||
<table border="0" cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td width="17"></td>
|
||||
<td valign="middle"><a href="shellcmd_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$categories = array("earlyshellcmd","shellcmd");
|
||||
//$categories = array("earlyshellcmd","shellcmd","afterfilterchangeshellcmd");
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$i = 0;
|
||||
// dynamically create the category config name
|
||||
$category_config = "a_".$category;
|
||||
if (count($$category_config) > 0) {
|
||||
foreach ($$category_config as $ent) {
|
||||
// previous versions of shellcmd stored the command in an additional <command>-xmltag, this unnests this for backwards compatibility
|
||||
if (is_array($ent)) { $ent = $ent['command']; }
|
||||
|
||||
echo " <tr>\n";
|
||||
echo " <td class=\"listr\" ondblclick=\"document.location='shellcmd_edit.php?t=".$category."&id=".$i."';\">\n";
|
||||
echo " ".$ent."\n";
|
||||
echo " </td>\n";
|
||||
echo " <td class=\"listbg\" ondblclick=\"document.location='shellcmd_edit.php?t=".$category."&id=".$i."';\">\n";
|
||||
echo " ".$category."\n";
|
||||
echo " </td>\n";
|
||||
echo " <td valign=\"middle\" nowrap class=\"list\">\n";
|
||||
echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td valign=\"middle\"><a href=\"shellcmd_edit.php?t=".$category."&id=".$i."\"><img src=\"/themes/".$g['theme']."/images/icons/icon_e.gif\" width=\"17\" height=\"17\" border=\"0\"></a></td>\n";
|
||||
echo " <td><a href=\"shellcmd_edit.php?t=".$category."&type=cmd&act=del&id=".$i."\" onclick=\"return confirm('Do you really want to delete this?')\"><img src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" width=\"17\" height=\"17\" border=\"0\"></a></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="list" colspan="2"></td>
|
||||
<td class="list">
|
||||
<table border="0" cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td width="17"></td>
|
||||
<td valign="middle"><a href="shellcmd_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="list" colspan="3"></td>
|
||||
<td class="list"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php include("fend.inc"); ?>
|
||||
</body>
|
||||
</html>
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
|
||||
shellcmd_edit.php
|
||||
Copyright (C) 2008 Mark J Crane
|
||||
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.
|
||||
*/
|
||||
|
||||
require("guiconfig.inc");
|
||||
require("/usr/local/pkg/shellcmd.inc");
|
||||
|
||||
|
||||
$id = $_GET['id'];
|
||||
if (strlen($_POST['id'])>0) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
|
||||
$type = $_GET['t'];
|
||||
if (strlen($_POST['t'])>0) {
|
||||
$type = $_POST['t'];
|
||||
}
|
||||
|
||||
if ($_GET['act'] == "del") {
|
||||
if ($_GET['type'] == 'cmd') {
|
||||
|
||||
switch (htmlspecialchars($type)) {
|
||||
case "earlyshellcmd":
|
||||
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
|
||||
unset($a_earlyshellcmd[$_GET['id']]);
|
||||
write_config();
|
||||
shellcmd_sync_package();
|
||||
header("Location: shellcmd.php");
|
||||
exit;
|
||||
break;
|
||||
case "shellcmd":
|
||||
$a_shellcmd = &$config['system']['shellcmd'];
|
||||
unset($a_shellcmd[$_GET['id']]);
|
||||
write_config();
|
||||
shellcmd_sync_package();
|
||||
header("Location: shellcmd.php");
|
||||
exit;
|
||||
break;
|
||||
case "afterfilterchangeshellcmd":
|
||||
// $a_afterfilterchangeshellcmd = &$config['system']['afterfilterchangeshellcmd'];
|
||||
// unset($a_afterfilterchangeshellcmd[$_GET['id']]);
|
||||
// write_config();
|
||||
// shellcmd_sync_package();
|
||||
// header("Location: shellcmd.php");
|
||||
// exit;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//get value for the form edit value
|
||||
if (strlen($id) > 0) {
|
||||
|
||||
switch (htmlspecialchars($type)) {
|
||||
case "earlyshellcmd":
|
||||
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
|
||||
if ($a_earlyshellcmd[$id]) {
|
||||
$pconfig['command'] = $a_earlyshellcmd[$id];
|
||||
}
|
||||
break;
|
||||
case "shellcmd":
|
||||
$a_shellcmd = &$config['system']['shellcmd'];
|
||||
if ($a_shellcmd[$id]) {
|
||||
$pconfig['command'] = $a_shellcmd[$id];
|
||||
}
|
||||
break;
|
||||
case "afterfilterchangeshellcmd":
|
||||
//$a_afterfilterchangeshellcmd = &$config['system']['afterfilterchangeshellcmd'];
|
||||
//if ($a_afterfilterchangeshellcmd[$id]) {
|
||||
// $pconfig['command'] = $a_afterfilterchangeshellcmd[$id];
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// previous version of shellcmd wrapped all commands in a <command>-xmltag, unnesting this for backwards compatibility
|
||||
if (is_array($pconfig['command'])) $pconfig['command'] = $pconfig['command']['command'];
|
||||
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
unset($input_errors);
|
||||
|
||||
if (!$input_errors) {
|
||||
if (strlen($_POST['command']) > 0) {
|
||||
|
||||
$ent = $_POST['command'];
|
||||
|
||||
if (strlen($id)>0) {
|
||||
//update
|
||||
|
||||
switch (htmlspecialchars($type)) {
|
||||
case "earlyshellcmd":
|
||||
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
|
||||
if ($a_earlyshellcmd[$id]) {
|
||||
$a_earlyshellcmd[$id] = $ent;
|
||||
}
|
||||
break;
|
||||
case "shellcmd":
|
||||
$a_shellcmd = &$config['system']['shellcmd'];
|
||||
if ($a_shellcmd[$id]) {
|
||||
$a_shellcmd[$id] = $ent;
|
||||
}
|
||||
break;
|
||||
case "afterfilterchangeshellcmd":
|
||||
//$a_afterfilterchangeshellcmd = &$config['system']['afterfilterchangeshellcmd'];
|
||||
//if ($a_afterfilterchangeshellcmd[$id]) {
|
||||
// $a_afterfilterchangeshellcmd[$id] = $ent;
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
//add
|
||||
switch (htmlspecialchars($type)) {
|
||||
case "earlyshellcmd":
|
||||
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
|
||||
$a_earlyshellcmd[] = $ent;
|
||||
break;
|
||||
case "shellcmd":
|
||||
$a_shellcmd = &$config['system']['shellcmd'];
|
||||
$a_shellcmd[] = $ent;
|
||||
break;
|
||||
case "afterfilterchangeshellcmd":
|
||||
//$a_afterfilterchangeshellcmd = &$config['system']['afterfilterchangeshellcmd'];
|
||||
//$a_afterfilterchangeshellcmd[] = $ent;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
write_config();
|
||||
shellcmd_sync_package();
|
||||
}
|
||||
|
||||
header("Location: shellcmd.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript" language="JavaScript">
|
||||
|
||||
function show_advanced_config() {
|
||||
document.getElementById("showadvancedbox").innerHTML='';
|
||||
aodiv = document.getElementById('showadvanced');
|
||||
aodiv.style.display = "block";
|
||||
</script>
|
||||
|
||||
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<p class="pgtitle">Shellcmd: Edit</p>
|
||||
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
||||
|
||||
<div id="mainlevel">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td class="tabnavtbl">
|
||||
<?php
|
||||
|
||||
$tab_array = array();
|
||||
$tab_array[] = array(gettext("Settings"), false, "/packages/shellcmd/shellcmd.php");
|
||||
display_top_tabs($tab_array);
|
||||
|
||||
?>
|
||||
</td></tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td class="tabcont" >
|
||||
|
||||
<!--
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<td><p><span class="vexpl"><span class="red"><strong>shellcmd<br>
|
||||
</strong></span>
|
||||
</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
-->
|
||||
<br />
|
||||
|
||||
|
||||
<form action="shellcmd_edit.php" method="post" name="iform" id="iform">
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<td width="25%" valign="top" class="vncellreq">Command</td>
|
||||
<td width="75%" class="vtable">
|
||||
<input name="command" type="text" class="formfld" id="command" size="40" value="<?=htmlspecialchars($pconfig['command']);?>">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="25%" valign="top" class="vncellreq">Type</td>
|
||||
<td width="75%" class="vtable">
|
||||
<?php
|
||||
echo " <select name='t' class='formfld'>\n";
|
||||
echo " <option></option>\n";
|
||||
switch (htmlspecialchars($type)) {
|
||||
case "earlyshellcmd":
|
||||
echo " <option value='earlyshellcmd' selected='yes'>earlyshellcmd</option>\n";
|
||||
echo " <option value='shellcmd'>shellcmd</option>\n";
|
||||
//echo " <option value='afterfilterchangeshellcmd'>afterfilterchangeshellcmd</option>\n";
|
||||
break;
|
||||
case "shellcmd":
|
||||
echo " <option value='earlyshellcmd'>earlyshellcmd</option>\n";
|
||||
echo " <option value='shellcmd' selected='yes'>shellcmd</option>\n";
|
||||
//echo " <option value='afterfilterchangeshellcmd'>afterfilterchangeshellcmd</option>\n";
|
||||
break;
|
||||
case "afterfilterchangeshellcmd":
|
||||
//echo " <option value='earlyshellcmd'>earlyshellcmd</option>\n";
|
||||
//echo " <option value='shellcmd'>shellcmd</option>\n";
|
||||
//echo " <option value='afterfilterchangeshellcmd' selected='yes'>afterfilterchangeshellcmd</option>\n";
|
||||
break;
|
||||
default:
|
||||
echo " <option value=''></option>\n";
|
||||
echo " <option value='earlyshellcmd'>earlyshellcmd</option>\n";
|
||||
echo " <option value='shellcmd'>shellcmd</option>\n";
|
||||
//echo " <option value='afterfilterchangeshellcmd'>afterfilterchangeshellcmd</option>\n";
|
||||
break;
|
||||
}
|
||||
echo " </select>\n";
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<!--
|
||||
<tr>
|
||||
<td width="25%" valign="top" class="vncellreq">Description</td>
|
||||
<td width="75%" class="vtable">
|
||||
<input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>">
|
||||
<br><span class="vexpl">Enter the description here.<br></span>
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
<tr>
|
||||
<td valign="top"> </td>
|
||||
<td>
|
||||
<?php if (strlen($id)>0) { ?>
|
||||
<input name="id" type="hidden" value="<?=$id;?>">
|
||||
<?php }; ?>
|
||||
<input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include("fend.inc"); ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
The shellcmd utility is used to manage commands on system startup.
|
||||
@@ -0,0 +1,5 @@
|
||||
pkg/shellcmd.xml
|
||||
pkg/shellcmd.inc
|
||||
www/packages/shellcmd/shellcmd.php
|
||||
www/packages/shellcmd/shellcmd_edit.php
|
||||
%%DATADIR%%/info.xml
|
||||
Reference in New Issue
Block a user