Skip to content

Commit

Permalink
v0.2
Browse files Browse the repository at this point in the history
N: configuration - enable/disable beta releases in extensions list
N: check hardware platform to use midnightcommander on i386 too
F: disabling extension not possible, leads to an error message
  • Loading branch information
crestAT committed Aug 9, 2016
1 parent 4658944 commit 6b18289
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 55 deletions.
13 changes: 13 additions & 0 deletions onebuttoninstaller/ext/ext/onebuttoninstaller/fail2ban.postinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
$command = "fail2ban_start.sh";
$cmd = dirname(__FILE__)."/".$command;
require_once("config.inc");
require_once("functions.inc");
$i =0;
if ( is_array($config['rc']['postinit'] ) && is_array( $config['rc']['postinit']['cmd'] ) ) {
for ($i; $i < count($config['rc']['postinit']['cmd']);) {
if (preg_match("/$command/", $config['rc']['postinit']['cmd'][$i])) break; ++$i; }
}
$config['rc']['postinit']['cmd'][$i] = $config['cmd']."$cmd";
write_config();
?>
4 changes: 3 additions & 1 deletion onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
# date: 2013-08-23 ; Fetch files from packages-9.2-release ; add libssh2
# date: 2014-12-18 ; Update for v9.3; Clean up
# date: 2015-02-21 ; Update mc package to mc-4.8.11.tbz
# date: 2016-08-04 ; check hardware platform to use it on i386 too - author: crest <[email protected]>
# purpose: Install Midnight Commander on NAS4Free (embedded version).
# Note: Check the end of the page.
#
#----------------------- Set variables ------------------------------------------------------------------
DIR=`dirname $0`;
URL="ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/amd64/packages-9.2-release/Latest"
HWPLATFORM=`uname -m`;
URL="ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/${HWPLATFORM}/packages-9.2-release/Latest"
MCLIGHTFILE="mc.tbz"
LIBSLANGFILE="libslang2.tbz"
LIBSSH2FILE="libssh2.tbz"
Expand Down
29 changes: 18 additions & 11 deletions onebuttoninstaller/ext/onebuttoninstaller-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,28 @@ function change_perms($dir) {
unset($input_errors);
if (empty($input_errors)) {
$config['onebuttoninstaller']['enable'] = isset($_POST['enable']) ? true : false;
$config['onebuttoninstaller']['storage_path'] = !empty($_POST['storage_path']) ? $_POST['storage_path'] : $g['media_path'];
$config['onebuttoninstaller']['storage_path'] = rtrim($config['onebuttoninstaller']['storage_path'],'/'); // ensure to have NO trailing slash
if (strpos($config['onebuttoninstaller']['storage_path'], "/mnt/") === false) {
$input_errors[] = gettext("The common directory for all extensions MUST be set to a directory below <b>'/mnt/'</b> to prevent to loose the extensions after a reboot on embedded systems!");
}
else {
if (!is_dir($config['onebuttoninstaller']['storage_path'])) mkdir($config['onebuttoninstaller']['storage_path'], 0775, true);
change_perms($_POST['storage_path']);
$config['onebuttoninstaller']['auto_update'] = isset($_POST['auto_update']) ? true : false;
$savemsg .= get_std_save_message(write_config());
if (isset($_POST['enable'])) {
$config['onebuttoninstaller']['storage_path'] = !empty($_POST['storage_path']) ? $_POST['storage_path'] : $g['media_path'];
$config['onebuttoninstaller']['storage_path'] = rtrim($config['onebuttoninstaller']['storage_path'],'/'); // ensure to have NO trailing slash
if (strpos($config['onebuttoninstaller']['storage_path'], "/mnt/") === false) {
$input_errors[] = gettext("The common directory for all extensions MUST be set to a directory below <b>'/mnt/'</b> to prevent to loose the extensions after a reboot on embedded systems!");
}
else {
if (!is_dir($config['onebuttoninstaller']['storage_path'])) mkdir($config['onebuttoninstaller']['storage_path'], 0775, true);
change_perms($_POST['storage_path']);
$config['onebuttoninstaller']['auto_update'] = isset($_POST['auto_update']) ? true : false;
$config['onebuttoninstaller']['show_beta'] = isset($_POST['show_beta']) ? true : false;
$savemsg .= get_std_save_message(write_config());
}
}
else $savemsg .= get_std_save_message(write_config());
} // end of empty input_errors
}

$pconfig['enable'] = isset($config['onebuttoninstaller']['enable']) ? true : false;
$pconfig['storage_path'] = !empty($config['onebuttoninstaller']['storage_path']) ? $config['onebuttoninstaller']['storage_path'] : $g['media_path'];
$pconfig['auto_update'] = isset($config['onebuttoninstaller']['auto_update']) ? true : false;
$pconfig['show_beta'] = isset($config['onebuttoninstaller']['show_beta']) ? true : false;

bindtextdomain("nas4free", "/usr/local/share/locale"); // to get the right main menu language
include("fbegin.inc");
Expand All @@ -108,6 +113,7 @@ function enable_change(enable_change) {
document.iform.storage_path.disabled = endis;
document.iform.storage_pathbrowsebtn.disabled = endis;
document.iform.auto_update.disabled = endis;
document.iform.show_beta.disabled = endis;
}
//-->
</script>
Expand All @@ -130,9 +136,10 @@ function enable_change(enable_change) {
<?php if (!empty($savemsg)) print_info_box($savemsg);?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<?php html_titleline_checkbox("enable", gettext("OneButtonInstaller"), $pconfig['enable'], gettext("Enable"), "enable_change(false)");?>
<?php html_text("installation_directory", gettext("Installation directory"), sprintf(gettext("The extension is installed in %s."), $config['onebuttoninstaller']['rootfolder']));?>
<?php html_text("installation_directory", gettext("Installation directory"), sprintf(gettext("The extension is installed in %s"), $config['onebuttoninstaller']['rootfolder']));?>
<?php html_filechooser("storage_path", gettext("Common directory"), $pconfig['storage_path'], gettext("Common directory for all extensions (a persistant place where all extensions are/should be - a directory below <b>/mnt/</b>)."), $pconfig['storage_path'], true, 60);?>
<?php html_checkbox("auto_update", gettext("Update"), $pconfig['auto_update'], gettext("Update extensions list automatically."), "", false);?>
<?php html_checkbox("show_beta", gettext("Beta releases"), $pconfig['show_beta'], gettext("If enabled, extensions in beta state will be shown in the extensions list."), "", false);?>
</table>
<div id="submit">
<input id="save" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>"/>
Expand Down
63 changes: 34 additions & 29 deletions onebuttoninstaller/ext/onebuttoninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function log_display($loginfo) {
* EXTENSIONS.TXT format description: PARAMETER DELIMITER -> ###
* PMID COMMENT
* name: 0 extension name
* version: 1 extension version (base for config entry - could change for newer versions)
* version: 1 extension version (base for config entry - could change for newer versions), check for beta releases
* xmlstring: 2 config.xml or installation directory
* command(list)1: 3 execution of SHELL commands / scripts (e.g. download installer, untar, chmod, ...)
* command(list)2: 4 empty ("-") or PHP script name (file MUST exist)
Expand All @@ -132,35 +132,40 @@ function log_display($loginfo) {
if ((FALSE === $result) || (0 == $result)) continue;
echo "<tr valign=\"top\">\n";
for ($i = 0; $i < count($loginfo['columns']); $i++) { // handle pmids (columns)
if ($i == count($loginfo['columns']) - 1) {
// check if extension is already installed (existing config.xml or postinit cmd entry)
if ((isset($config[$result[2]])) || (log_get_status($result[2]) == 1)) {
echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}'> <img src='{$image_path}status_enabled.png' border='0' alt='' title='".gettext('Enabled')."' /></td>\n";
}
else { // not installed
$supported_app = true;
if (!empty($result[6])) { // something unsupported exist
$unsupported = explode(",", str_replace(" ", "", $result[6]));
for ($k = 0; $k < count($unsupported); $k++) { // check for unsupported release / architecture / platforms
if (!check_min_release($unsupported[$k]) || ($unsupported[$k] == $g['arch']) || ($unsupported[$k] == $g['platform'])) {
echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}'> <img src='{$image_path}status_disabled.png' border='0' alt='' title='".gettext('Unsupported architecture/platform/release').': '.$unsupported[$k]."' /></td>\n";
$supported_app = false;
break;
if (!isset($config['onebuttoninstaller']['show_beta']) && (strpos($result[1], "RELEASE") === false)) continue; //check for beta state
else {
if ($i == count($loginfo['columns']) - 1) {


// check if extension is already installed (existing config.xml or postinit cmd entry)
if ((isset($config[$result[2]])) || (log_get_status($result[2]) == 1)) {
echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}'> <img src='{$image_path}status_enabled.png' border='0' alt='' title='".gettext('Enabled')."' /></td>\n";
}
else { // not installed
$supported_app = true;
if (!empty($result[6])) { // something unsupported exist
$unsupported = explode(",", str_replace(" ", "", $result[6]));
for ($k = 0; $k < count($unsupported); $k++) { // check for unsupported release / architecture / platforms
if (!check_min_release($unsupported[$k]) || ($unsupported[$k] == $g['arch']) || ($unsupported[$k] == $g['platform'])) {
echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}'> <img src='{$image_path}status_disabled.png' border='0' alt='' title='".gettext('Unsupported architecture/platform/release').': '.$unsupported[$k]."' /></td>\n";
$supported_app = false;
break;
}
}
}
}
if ($supported_app === true) {
// data for installation
echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}' title='".gettext('Select to install')."' >
<input type='checkbox' name='name[".$j."][extension]' value='".$result[2]."' />
<input type='hidden' name='name[".$j."][truename]' value='".$result[0]."' />
<input type='hidden' name='name[".$j."][command1]' value='".$result[3]."' />
<input type='hidden' name='name[".$j."][command2]' value='".$result[4]."' />
</td>\n";
}
} // EOnot-installed
} // EOcount
else echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}'>" . $result[$loginfo['columns'][$i]['pmid']] . "</td>\n";
}
if ($supported_app === true) {
// data for installation
echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}' title='".gettext('Select to install')."' >
<input type='checkbox' name='name[".$j."][extension]' value='".$result[2]."' />
<input type='hidden' name='name[".$j."][truename]' value='".$result[0]."' />
<input type='hidden' name='name[".$j."][command1]' value='".$result[3]."' />
<input type='hidden' name='name[".$j."][command2]' value='".$result[4]."' />
</td>\n";
}
} // EOnot-installed
} // EOcount
else echo "<td {$loginfo['columns'][$i]['param']} class='{$loginfo['columns'][$i]['class']}'>" . $result[$loginfo['columns'][$i]['pmid']] . "</td>\n";
} //EObeta-check
} // EOcolumns
echo "</tr>\n";
$j++;
Expand Down
Loading

0 comments on commit 6b18289

Please sign in to comment.