diff --git a/LICENSE.txt b/LICENSE.txt
index 8944d5f..a23e24e 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
BSD 2-Clause License
-Copyright (c) 2015 - 2017 Andreas Schmidhuber, aka crest(AT)
+Copyright (c) 2015 - 2018 Andreas Schmidhuber
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/OBI.php b/OBI.php
index c4182a4..a66813a 100644
--- a/OBI.php
+++ b/OBI.php
@@ -2,7 +2,7 @@
/*
OBI.php
- Copyright (c) 2015 - 2016 Andreas Schmidhuber
+ Copyright (c) 2015 - 2018 Andreas Schmidhuber
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -24,10 +24,6 @@
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.
-
- The views and conclusions contained in the software and documentation are those
- of the authors and should not be interpreted as representing official policies,
- either expressed or implied, of the FreeBSD Project.
*/
require("auth.inc");
require("guiconfig.inc");
@@ -37,6 +33,10 @@
if (!isset($config['onebuttoninstaller']) || !is_array($config['onebuttoninstaller'])) $config['onebuttoninstaller'] = array();
+$platform = $g['platform'];
+if ($platform == "livecd" || $platform == "liveusb")
+ $input_errors[] = sprintf(gettext("Attention: the used XigmaNAS platform '%s' is not recommended for extensions! After a reboot all extensions will no longer be available, use XigmaNAS embedded or full platform instead!"), $platform);
+
/* Check if the directory exists, the mountpoint has at least o=rx permissions and
* set the permission to 775 for the last directory in the path
*/
@@ -85,7 +85,7 @@ function change_perms($dir) {
$config['onebuttoninstaller']['path_check'] = isset($_POST['path_check']) ? true : false;
$install_dir = $config['onebuttoninstaller']['storage_path']."/"; // get directory where the installer script resides
if (!is_dir("{$install_dir}onebuttoninstaller/log")) { mkdir("{$install_dir}onebuttoninstaller/log", 0775, true); }
- $return_val = mwexec("fetch {$verify_hostname} -vo {$install_dir}onebuttoninstaller/onebuttoninstaller-install.php 'https://raw.github.com/crestAT/nas4free-onebuttoninstaller/master/onebuttoninstaller/onebuttoninstaller-install.php'", true);
+ $return_val = mwexec("fetch {$verify_hostname} -vo {$install_dir}onebuttoninstaller/onebuttoninstaller-install.php 'https://raw.github.com/crestAT/nas4free-onebuttoninstaller/master/onebuttoninstaller/onebuttoninstaller-install.php'", false);
if ($return_val == 0) {
chmod("{$install_dir}onebuttoninstaller/onebuttoninstaller-install.php", 0775);
require_once("{$install_dir}onebuttoninstaller/onebuttoninstaller-install.php");
diff --git a/README.md b/README.md
index 5b1ee18..c803f78 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
OneButtonInstaller
------------------
-Description in the NAS4Free forum -> OneButtonInstaller
-
+Please visit the XigmaNAS forum for full description and installation guide -> OneButtonInstaller
diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/fail2ban.postinit b/onebuttoninstaller/apps/fail2ban.postinit
similarity index 90%
rename from onebuttoninstaller/ext/ext/onebuttoninstaller/fail2ban.postinit
rename to onebuttoninstaller/apps/fail2ban.postinit
index 062392b..642fc17 100644
--- a/onebuttoninstaller/ext/ext/onebuttoninstaller/fail2ban.postinit
+++ b/onebuttoninstaller/apps/fail2ban.postinit
@@ -2,7 +2,7 @@
/*
fail2ban.postinit
- Copyright (c) 2015 - 2017 Andreas Schmidhuber
+ Copyright (c) 2015 - 2018 Andreas Schmidhuber
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -24,10 +24,6 @@
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.
-
- The views and conclusions contained in the software and documentation are those
- of the authors and should not be interpreted as representing official policies,
- either expressed or implied, of the FreeBSD Project.
*/
$command = "fail2ban_start.sh";
diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.postinit b/onebuttoninstaller/apps/mcommander.postinit
similarity index 86%
rename from onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.postinit
rename to onebuttoninstaller/apps/mcommander.postinit
index e296ced..0c3a8c5 100644
--- a/onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.postinit
+++ b/onebuttoninstaller/apps/mcommander.postinit
@@ -1,8 +1,8 @@
= 11.0) { // new rc format
// postinit command
$rc_param = [];
$rc_param['uuid'] = uuid();
- $rc_param['name'] = "MidnightCommander Extension";
+ $rc_param['name'] = "{$appName} Extension";
$rc_param['value'] = "{$cmd}";
- $rc_param['comment'] = "Start MidnightCommander";
+ $rc_param['comment'] = "Start {$appName}";
$rc_param['typeid'] = '2';
$rc_param['enable'] = true;
$config['rc']['param'][] = $rc_param;
diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh b/onebuttoninstaller/apps/mcommander.sh
similarity index 100%
rename from onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh
rename to onebuttoninstaller/apps/mcommander.sh
diff --git a/onebuttoninstaller/apps/ncdu.postinit b/onebuttoninstaller/apps/ncdu.postinit
new file mode 100644
index 0000000..17c8be0
--- /dev/null
+++ b/onebuttoninstaller/apps/ncdu.postinit
@@ -0,0 +1,69 @@
+= 11.0) { // new rc format
+ // postinit command
+ $rc_param = [];
+ $rc_param['uuid'] = uuid();
+ $rc_param['name'] = "{$appName} Extension";
+ $rc_param['value'] = "{$cmd}";
+ $rc_param['comment'] = "Start {$appName}";
+ $rc_param['typeid'] = '2';
+ $rc_param['enable'] = true;
+ $config['rc']['param'][] = $rc_param;
+}
+else {
+ $config['rc']['postinit']['cmd'][] = "{$cmd}";
+}
+write_config();
+?>
diff --git a/onebuttoninstaller/apps/ncdu.sh b/onebuttoninstaller/apps/ncdu.sh
new file mode 100644
index 0000000..f4e7e3b
--- /dev/null
+++ b/onebuttoninstaller/apps/ncdu.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# filename: ncdu.sh
+# author: Graham Inggs
+# date: 2018-05-24 ; Initial release for NAS4Free 11.1.0.4
+# purpose: Install NCurses Disk Usage (ncdu) on NAS4Free (embedded version).
+# Note: Check the end of the page.
+#
+#----------------------- Set variables ------------------------------------------------------------------
+DIR=`dirname $0`;
+PLATFORM=`uname -m`
+RELEASE=`uname -r | cut -d- -f1`
+REL_MAJOR=`echo $RELEASE | cut -d. -f1`
+REL_MINOR=`echo $RELEASE | cut -d. -f2`
+#URL="http://distcache.freebsd.org/FreeBSD:${REL_MAJOR}:${PLATFORM}/release_${REL_MINOR}/All"
+URL="http://distcache.freebsd.org/FreeBSD:${REL_MAJOR}:${PLATFORM}/release_1/All"
+NCDUFILE="ncdu-1.12.txz"
+#----------------------- Set Errors ---------------------------------------------------------------------
+_msg() { case $@ in
+ 0) echo "The script will exit now."; exit 0 ;;
+ 1) echo "No route to server, or file do not exist on server"; _msg 0 ;;
+ 2) echo "Can't find ${FILE} on ${DIR}"; _msg 0 ;;
+ 3) echo "NCurses Disk Usage installed and ready! (ONLY USE DURING A SSH SESSION)"; exit 0 ;;
+ 4) echo "Always run this script using the full path: /mnt/.../directory/ncdu.sh"; _msg 0 ;;
+esac ; exit 0; }
+#----------------------- Check for full path ------------------------------------------------------------
+if [ ! `echo $0 |cut -c1-5` = "/mnt/" ]; then _msg 4; fi
+cd $DIR;
+#----------------------- Download and decompress ncdu files if needed -----------------------------------
+FILE=${NCDUFILE}
+if [ ! -d ${DIR}/usr/local/bin ]; then
+ if [ ! -e ${DIR}/${FILE} ]; then fetch ${URL}/${FILE} || _msg 1; fi
+ if [ -f ${DIR}/${FILE} ]; then tar xzf ${DIR}/${FILE} || _msg 2;
+ rm ${DIR}/+*; rm -R ${DIR}/usr/local/man; rm -R ${DIR}/usr/local/share; fi
+ if [ ! -d ${DIR}/usr/local/bin ] ; then _msg 4; fi
+fi
+#----------------------- Create symlinks ----------------------------------------------------------------
+for i in `ls $DIR/usr/local/bin/`
+ do if [ ! -e /usr/local/bin/${i} ]; then ln -s ${DIR}/usr/local/bin/$i /usr/local/bin; fi; done
+_msg 3 ; exit 0;
+#----------------------- End of Script ------------------------------------------------------------------
+# 1. Keep this script in its own directory.
+# 2. chmod the script u+x,
+# 3. Always run this script using the full path: /mnt/.../directory/ncdu.sh
+# 4. You can add this script to WebGUI: Advanced: Command Scripts as a PostInit command (see 3).
+# 5. To run Ncurses Disk Usage from shell type 'ncdu'.
diff --git a/onebuttoninstaller/ext/extension-lib.inc b/onebuttoninstaller/ext/extension-lib.inc
new file mode 100644
index 0000000..344f9c5
--- /dev/null
+++ b/onebuttoninstaller/ext/extension-lib.inc
@@ -0,0 +1,208 @@
+ 10.3032853, 11.0
+ * return:
+ * true => current release >= minimal release
+ * false => current release < minimal release
+*/
+if (!function_exists('ext_check_release')) {
+ function ext_check_release($min_release) {
+ global $config;
+ $product_version = explode(".", get_product_version()); // p.version = 10.3.0.3, p.revision = 2853
+ $current_release = $product_version[0].".".$product_version[1].$product_version[2].$product_version[3].get_product_revision();
+ if ($current_release < floatval($min_release)) return false; // release not supported
+ else return true; // release supported
+ }
+}
+
+/* function ext_create_rc_commands
+ * params:
+ * $appname: extension name
+ * $postinit: postinit command
+ * $shutdown: shutdown command
+ * $start_action: comment e.g. Start, Run, Initialize
+ * $stop_action: comment e.g. Stop, Closedown
+ * return:
+ * $postinit: uuid or false
+ * $shutdown: uuid or false
+*/
+if (!function_exists('ext_create_rc_commands')) {
+ function ext_create_rc_commands($appname, &$postinit = false, &$shutdown = false, $start_action = "Start", $stop_action = "Stop") {
+ global $config;
+ if (ext_check_release(11.0)) { // new rc format
+ unset($rc_param);
+ // postinit command
+ if (($postinit !== false) && !empty($postinit)) {
+ $rc_param = [];
+ $rc_param['uuid'] = uuid();
+ $rc_param['name'] = "{$appname} Extension";
+ $rc_param['value'] = $postinit;
+ $rc_param['comment'] = "{$start_action} {$appname}";
+ $rc_param['typeid'] = '2';
+ $rc_param['enable'] = true;
+ if (!is_array($config['rc'])) $config['rc'] = [];
+ if (!is_array($config['rc']['param'])) $config['rc']['param'] = [];
+ $config['rc']['param'][] = $rc_param;
+ $postinit = $rc_param['uuid'];
+ unset($rc_param);
+ }
+ // shutdown command
+ if (($shutdown !== false) && !empty($shutdown)) {
+ $rc_param = [];
+ $rc_param['uuid'] = uuid();
+ $rc_param['name'] = "{$appname} Extension";
+ $rc_param['value'] = $shutdown;
+ $rc_param['comment'] = "{$stop_action} {$appname}";
+ $rc_param['typeid'] = '3';
+ $rc_param['enable'] = true;
+ if (!is_array($config['rc'])) $config['rc'] = [];
+ if (!is_array($config['rc']['param'])) $config['rc']['param'] = [];
+ $config['rc']['param'][] = $rc_param;
+ $shutdown = $rc_param['uuid'];
+ unset($rc_param);
+ }
+ }
+ else {
+ if (($postinit !== false) && !empty($postinit)) {
+ $config['rc']['postinit']['cmd'][] = $postinit;
+ $postinit = false;
+ }
+ if (($shutdown !== false) && !empty($shutdown)) {
+ $config['rc']['shutdown']['cmd'][] = $shutdown;
+ $shutdown = false;
+ }
+ }
+ write_config();
+ }
+}
+
+/* function ext_remove_rc_commands
+ * remove postinit / shutdown commands from rc array for both NAS4Free < 11.x and >= 11.x series
+ * params:
+ * $config_name: string to identify the rc command entry in rc|postinit/shutdown|cmd or rc|param|value
+*/
+if (!function_exists('ext_remove_rc_commands')) {
+ function ext_remove_rc_commands($config_name) {
+ global $config;
+ // remove existing old rc format entries
+ if (is_array($config['rc']) && is_array($config['rc']['postinit']) && is_array( $config['rc']['postinit']['cmd'])) {
+ $rc_param_count = count($config['rc']['postinit']['cmd']);
+ for ($i = 0; $i < $rc_param_count; $i++) {
+ if (preg_match("/{$config_name}/", $config['rc']['postinit']['cmd'][$i])) unset($config['rc']['postinit']['cmd'][$i]);
+ }
+ }
+ if (is_array($config['rc']) && is_array($config['rc']['shutdown']) && is_array( $config['rc']['shutdown']['cmd'])) {
+ $rc_param_count = count($config['rc']['shutdown']['cmd']);
+ for ($i = 0; $i < $rc_param_count; $i++) {
+ if (preg_match("/{$config_name}/", $config['rc']['shutdown']['cmd'][$i])) unset($config['rc']['shutdown']['cmd'][$i]);
+ }
+ }
+ // remove existing entries for new rc format
+ if (is_array($config['rc']) && is_array($config['rc']['param']['0'])) {
+ $rc_param_count = count($config['rc']['param']);
+ for ($i = 0; $i < $rc_param_count; $i++) {
+ if (preg_match("/{$config_name}/", $config['rc']['param'][$i]['value'])) unset($config['rc']['param'][$i]);
+ }
+ }
+ write_config();
+ }
+}
+
+/* function ext_check_version
+ * checks an extension if a new version exists against the currently installed version
+ * params:
+ * $test_filename: filename including the full path which holds the version number
+ * $extension_name: extension name in URL format to retrive from Github
+ * $current_version: string of current installed version
+ * $button_name: gettext("name") to create a note for user action, e.g. Maintenance, Update
+ * return:
+ * empty: no new version found
+ * or string: message for user action on new version found
+ * or false: Github version could not be retrieved
+*/
+if (!function_exists('ext_check_version')) {
+ function ext_check_version($test_filename, $extension_name, $current_version, $button_name) {
+ global $config;
+ if (!is_file($test_filename) || filemtime($test_filename) < time() - 86400) { // test if file exists or is older than 24 hours
+ $return_val = mwexec("fetch -o {$test_filename} https://raw.github.com/crestAT/nas4free-{$extension_name}/master/{$extension_name}/version.txt", false);
+ if ($return_val == 0) {
+ $server_version = exec("cat {$test_filename}");
+ if ($server_version != $current_version) return sprintf(gettext("New extension version %s available, push '%s' button to install the new version!"), $server_version, $button_name)."
";
+ }
+ else return false;
+ }
+ }
+}
+
+/* function ext_load_config
+ * loads a json formatted array from a standalone file
+ * params:
+ * $config_file: config file including full path
+ * return:
+ * data array: json formatted array
+ * or false: config file not found or content not retrievable
+*/
+if (!function_exists('ext_load_config')) {
+ function ext_load_config($config_file, $assoc = true, $depth = 512, $options = 0) {
+ if (is_file($config_file)) {
+ if (($config_data = file_get_contents($config_file)) === false) return false;
+ $config_data = utf8_encode($config_data);
+ $config_data = json_decode($config_data, $assoc, $depth, $options);
+ return $config_data;
+ }
+ else return false;
+ }
+}
+
+/* function ext_save_config
+ * loads a json formatted array from a standalone file
+ * params:
+ * $config_file: config file including full path
+ * $config_data: php array with configuration data
+ * return:
+ * error condition
+ */
+if (!function_exists('ext_save_config')) {
+ function ext_save_config($config_file, $config_data){
+ header("Content-Type: application/json; UTF-8\n");
+ file_put_contents($config_file, json_encode($config_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ));
+ return json_last_error();
+ }
+}
+?>
diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/menu.inc b/onebuttoninstaller/ext/menu.inc
similarity index 100%
rename from onebuttoninstaller/ext/ext/onebuttoninstaller/menu.inc
rename to onebuttoninstaller/ext/menu.inc
diff --git a/onebuttoninstaller/ext/onebuttoninstaller-update_extension.php b/onebuttoninstaller/ext/onebuttoninstaller-update_extension.php
deleted file mode 100644
index 17f5270..0000000
--- a/onebuttoninstaller/ext/onebuttoninstaller-update_extension.php
+++ /dev/null
@@ -1,145 +0,0 @@
-
-
-
-
-
-
-