add ip address option

This commit is contained in:
Derek Macias 2016-01-07 00:01:17 -07:00
parent edf42e7f78
commit d81b6eec4f
4 changed files with 45 additions and 10 deletions

View File

@ -3,7 +3,7 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "shellinabox-plugin">
<!ENTITY author "dmacias72">
<!ENTITY version "2016.01.06">
<!ENTITY version "2016.01.07">
<!ENTITY launch "Settings/Shellinabox">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master">
<!ENTITY pluginURL "&gitURL;/plugins/&name;.plg">
@ -20,6 +20,11 @@ This Plugin installs and controls shellinabox for unRaid 6.1 All dependencies a
-->
<CHANGES>
###2016.01.07
- add ip address connection option
- add install certificate button
- fix starting service with changed settings not saving
- default config file
###2016.01.06
- change package path to plugin directory
- fix Tool/Command Line page misspelled cfg file and defaulting to port 8088 instead of 4200
@ -62,6 +67,16 @@ This Plugin installs and controls shellinabox for unRaid 6.1 All dependencies a
<MD5>f5d4e99dc0b65f4d6b3bacf479c9c6e2</MD5>
</FILE>
<FILE Name="/boot/config/plugins/shellinabox-plugin/shellinabox-plugin.cfg">
<INLINE>
<![CDATA[
SERVICE="disable"
IPADDR="disable"
PORT="4200"
RUNAS="nobody"
]]>
</INLINE>
</FILE>
<!--
The 'plugin' package file.
@ -151,6 +166,7 @@ echo ""
# This will check each entry in the config so nothing is missing, and if missing, sets to default
CFGFILE=/boot/config/plugins/shellinabox-plugin/shellinabox-plugin.cfg
[ ! `cat "$CFGFILE" | grep SERVICE` ] && echo "SERVICE=\"disable\"" >> "$CFGFILE"
[ ! `cat "$CFGFILE" | grep IPADDR` ] && echo "IPADDR=\"disable\"" >> "$CFGFILE"
[ ! `cat "$CFGFILE" | grep ^PORT` ] && echo "PORT=\"4200\"" >> "$CFGFILE"
[ ! `cat "$CFGFILE" | grep RUNAS` ] && echo "RUNAS=\"nobody\"" >> "$CFGFILE"
rm /tmp/shellinabox-chkconf

View File

@ -11,8 +11,13 @@ Shell In A Box implements a web server that can export arbitrary command line to
</Description>
<Support>http://lime-technology.com/forum/index.php?topic=42683.0</Support>
<Icon>https://raw.githubusercontent.com/dmacias72/unRAID-plugins/master/plugins/shellinabox-plugin.png</Icon>
<Date>2016-01-06</Date>
<Date>2016-01-07</Date>
<Changes>
###2016.01.07
- add ip address connection option
- add install certificate button
- fix starting service with changed settings not saving
- default config file
###2016.01.06
- change package path to plugin directory
- fix Tool/Command Line page misspelled cfg file and defaulting to port 8088 instead of 4200

View File

@ -5,6 +5,8 @@ Type="xmenu"
<?php
$sName = "shellinaboxd";
$shellinabox_cfg = parse_plugin_cfg("shellinabox-plugin");
$shellinabox_ipaddr = isset($shellinabox_cfg['IPADDR']) ? $shellinabox_cfg['IPADDR'] : "disable";
$shellinabox_host = ($shellinabox_ipaddr == "disable") ? $var['NAME'] : $var['IPADDR'];
$shellinabox_port = (isset($shellinabox_cfg['PORT']) && is_numeric($shellinabox_cfg['PORT']) && $shellinabox_cfg['PORT'] > 0 && $shellinabox_cfg['PORT'] < 65535 ) ? $shellinabox_cfg['PORT'] : "4200";
?>
<style>
@ -18,7 +20,7 @@ iframe {
</style>
<div>
<iframe id="shell" src="https://<?=$var['NAME'];?>:<?=$shellinabox_port;?>">
<iframe id="shell" src="https://<?=$shellinabox_host?>:<?=$shellinabox_port;?>">
</iframe>
</div>

View File

@ -7,11 +7,13 @@ $sName = "shellinaboxd";
$shellinabox_cfg = parse_plugin_cfg("shellinabox-plugin");
$shellinabox_service = isset($shellinabox_cfg['SERVICE']) ? $shellinabox_cfg['SERVICE'] : "disable";
$shellinabox_runas = isset($shellinabox_cfg['RUNAS']) ? $shellinabox_cfg['RUNAS'] : "nobody";
$shellinabox_ipaddr = isset($shellinabox_cfg['IPADDR']) ? $shellinabox_cfg['IPADDR'] : "disable";
$shellinabox_host = ($shellinabox_ipaddr == "disable") ? $var['NAME'] : $var['IPADDR'];
$shellinabox_port = (isset($shellinabox_cfg['PORT']) && is_numeric($shellinabox_cfg['PORT']) && $shellinabox_cfg['PORT'] > 0 && $shellinabox_cfg['PORT'] < 65535 ) ? $shellinabox_cfg['PORT'] : "4200";
$shellinabox_running = trim(shell_exec( "[ -f /proc/`cat /var/run/shellinaboxd.pid 2> /dev/null`/exe ] && echo 'yes' || echo 'no' 2> /dev/null" ));
$shellinabox_version = shell_exec( "/usr/sbin/shellinaboxd --version 2>&1 | grep ShellInABox | sed -e 's/^ShellInABox version //'" );
$shellinabox_version = ($shellinabox_running == "yes") ?
"<a style='color:green;' target='_blank' href='https://".$var['NAME'].":".$shellinabox_port."' title='Click on link then accept security, then /Tools/CommandLine will work'><b>$shellinabox_version</b></a>":
"<a style='color:green;' target='_blank' href='https://".$shellinabox_host.":".$shellinabox_port."' title='Click on link then accept security, then /Tools/CommandLine will work'><b>$shellinabox_version</b></a>":
"<b><font style='color:orange;'>$shellinabox_version</font></b>";
?>
@ -25,6 +27,12 @@ Enable Shellinabox Server <?=$shellinabox_version;?>:
<?=mk_option($shellinabox_service, "enable", "Yes");?>
</select>
Connect by IP Address:
: <select id="IPADDR" name="IPADDR" size="1" class="stopped">
<?=mk_option($shellinabox_ipaddr, "disable", "No");?>
<?=mk_option($shellinabox_ipaddr, "enable", "Yes");?>
</select>
Port:
: <input id="PORT" type="text" class="stopped" name="PORT" maxlength="40" value="<?=$shellinabox_port;?>" title="port must be 0-65535" placeholder="Default Port is 8000" >
@ -36,7 +44,7 @@ Run as User:
<input type="hidden" name="RUNAS" style="width:222px" maxlength="40" value=<?=$shellinabox_runas;?> >
<input id="DEFAULT" class="stopped" type="submit" value="Default" onClick="resetDATA(this.form)">
: <input id="btnApply" type="submit" value="Apply" onClick="verifyDATA(this.form)"><input type="button" value="Done" onClick="done()">
: <input id="btnApply" type="submit" value="Apply" onClick="verifyDATA(this.form)"><input type="button" value="Done" onClick="done()"><button id="btnCert" type="button" onclick="window.location.href='http://<?=$shellinabox_host;?>/boot/config/plugins/shellinabox-plugin/certificate-server.pem'"> Install Cert </button>
</form>
<script type="text/javascript">
@ -47,6 +55,7 @@ $(function(){
});
function resetDATA(form) {
form.IPADDR.value = "disable";
form.PORT.value = "4200";
form.RUNAS.value = "nobody";
form.USERS.value = "nobody";
@ -56,10 +65,12 @@ function checkRUNNING(form) {
if ("<?=$shellinabox_running;?>" == "yes")
{
$(".stopped").prop("disabled", true);
form.btnApply.disabled = "disabled";
form.btnApply.disabled = true;
form.btnCert.disabled = false;
}else{
$(".stopped").prop("disabled", false);
form.btnCert.disabled = true;
}
else
$(".stopped").prop("disabled", (form.SERVICE.value == "enable"));
if (form.SERVICE.value == "enable")
form.command.value = "/usr/local/emhttp/plugins/shellinabox-plugin/scripts/start";
@ -97,6 +108,7 @@ function verifyDATA(form) {
$shellinabox_runas = "nobody";
}
form.SERVICE.value = form.SERVICE.value.replace(/ /g,"_");
form.IPADDR.value = form.IPADDR.value.replace(/ /g,"_");
form.PORT.value = form.PORT.value.replace(/ /g,"_");
form.RUNAS.value = form.RUNAS.value.replace(/ /g,"_");
}