Skip to content

Commit

Permalink
v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
crestAT committed Aug 15, 2018
1 parent 98f5593 commit 535e73b
Show file tree
Hide file tree
Showing 52 changed files with 679 additions and 352 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions OBI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand All @@ -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
*/
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
OneButtonInstaller
------------------

Description in the NAS4Free forum -> <a href="http://forums.nas4free.org/viewtopic.php?f=71&t=11189">OneButtonInstaller</a>

Please visit the XigmaNAS forum for full description and installation guide -> <a href="https://www.xigmanas.com/forums/viewtopic.php?f=71&t=11189">OneButtonInstaller</a>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/*
mcommander.postinnit
universal postinit file for CLI extensions

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
Expand All @@ -24,14 +24,11 @@
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_once("config.inc");

$appName = "Midnight Commander";
$command = "mcommander.sh";
$cmd = dirname(__FILE__)."/".$command;

Expand All @@ -58,9 +55,9 @@ if ($release[0] >= 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;
Expand Down
File renamed without changes.
69 changes: 69 additions & 0 deletions onebuttoninstaller/apps/ncdu.postinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/*
universal postinit file for CLI extensions

Copyright (c) 2015 - 2018 Andreas Schmidhuber
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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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("config.inc");

$appName = "NCurses Disk Usage";
$command = "ncdu.sh";
$cmd = dirname(__FILE__)."/".$command;

// remove start/stop commands
// 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("/{$command}/", $config['rc']['postinit']['cmd'][$i])) unset($config['rc']['postinit']['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("/{$command}/", $config['rc']['param'][$i]['value'])) unset($config['rc']['param'][$i]);
}
}

// check FreeBSD release
$release = explode("-", exec("uname -r"));

if ($release[0] >= 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();
?>
45 changes: 45 additions & 0 deletions onebuttoninstaller/apps/ncdu.sh
Original file line number Diff line number Diff line change
@@ -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'.
Loading

0 comments on commit 535e73b

Please sign in to comment.