From 94c5ff0aa756113a061852eaac3ec761a29adde4 Mon Sep 17 00:00:00 2001 From: crestAT Date: Mon, 25 Jan 2016 19:12:05 +0100 Subject: [PATCH] alpha alpha release 4 --- .../ext/ext/onebuttoninstaller/mcommander.sh | 123 ++++++++ .../ext/ext/onebuttoninstaller/menu.inc | 1 + .../ext/ext/onebuttoninstaller/spin.min.js | 2 + .../ext/onebuttoninstaller-config.php | 292 ++++++++++++++++++ .../onebuttoninstaller-update_extension.php | 199 ++++++++++++ onebuttoninstaller/ext/onebuttoninstaller.php | 223 +++++++++++++ onebuttoninstaller/extensions.txt | 13 + .../onebuttoninstaller-install.php | 126 ++++++++ .../onebuttoninstaller-start.php | 36 +++ .../onebuttoninstaller-stop.php | 36 +++ .../onebuttoninstaller_start.php | 5 + .../onebuttoninstaller_stop.php | 5 + onebuttoninstaller/release_notes.txt | 6 + onebuttoninstaller/version.txt | 1 + onebuttoninstaller_install.php | 16 + 15 files changed, 1084 insertions(+) create mode 100644 onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh create mode 100644 onebuttoninstaller/ext/ext/onebuttoninstaller/menu.inc create mode 100644 onebuttoninstaller/ext/ext/onebuttoninstaller/spin.min.js create mode 100644 onebuttoninstaller/ext/onebuttoninstaller-config.php create mode 100644 onebuttoninstaller/ext/onebuttoninstaller-update_extension.php create mode 100644 onebuttoninstaller/ext/onebuttoninstaller.php create mode 100644 onebuttoninstaller/extensions.txt create mode 100644 onebuttoninstaller/onebuttoninstaller-install.php create mode 100644 onebuttoninstaller/onebuttoninstaller-start.php create mode 100644 onebuttoninstaller/onebuttoninstaller-stop.php create mode 100644 onebuttoninstaller/onebuttoninstaller_start.php create mode 100644 onebuttoninstaller/onebuttoninstaller_stop.php create mode 100644 onebuttoninstaller/release_notes.txt create mode 100644 onebuttoninstaller/version.txt create mode 100644 onebuttoninstaller_install.php diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh b/onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh new file mode 100644 index 0000000..ba9a9a6 --- /dev/null +++ b/onebuttoninstaller/ext/ext/onebuttoninstaller/mcommander.sh @@ -0,0 +1,123 @@ +#!/bin/sh +# filename: mcommander.sh +# author: Dan Merschi +# date: 2009-07-28 ; Add multiplatform support +# author: Graham Inggs +# date: 2012-04-11 ; Updated for NAS4Free 9.0.0.1 +# date: 2013-02-09 ; Updated for ftp.freebsd.org restructuring and latest mc-light version +# date: 2013-05-05 ; Switch from mc-light to mc ; drop compat7x ; add libslang +# date: 2013-08-10 ; Update mc package name to mc-4.8.8.tbz +# 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 +# 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" +MCLIGHTFILE="mc.tbz" +LIBSLANGFILE="libslang2.tbz" +LIBSSH2FILE="libssh2.tbz" +#----------------------- Set Errors --------------------------------------------------------------------- +_msg() { case $@ in + 0) echo "The script will exit now."; exit 0 ;; + 1) echo "Error! Can not download ${FILE}"; _msg 0 ;; + 2) echo "Can't find ${FILE} on ${DIR}"; _msg 0 ;; + 3) echo "Midnight Commander installed and ready!"; exit 0 ;; + 4) echo "Always run this script using the full path: /path/to/$(basename $0)"; _msg 0 ;; +esac } +#----------------------- Check for full path ------------------------------------------------------------ +[ `echo $0 | cut -c1` = "/" ] || _msg 4 +cd ${DIR} +#----------------------- Download and decompress mc files if don't exist -------------------------------- +FILE=${MCLIGHTFILE} +if [ ! -d ${DIR}/bin ]; then + if [ ! -e ${DIR}/${FILE} ]; then fetch ${URL}/${FILE} || _msg 1; fi + if [ -r ${DIR}/${FILE} ]; then tar -xf ${DIR}/${FILE} || _msg 2; rm ${DIR}/+*; rm -R ${DIR}/man; fi + [ -d ${DIR}/bin ] || _msg 4 +fi +#----------------------- Download and decompress libslang files if don't exist -------------------------- +FILE=${LIBSLANGFILE} +if [ ! -d ${DIR}/lib ]; then + if [ ! -e ${DIR}/${FILE} ]; then fetch ${URL}/${FILE} || _msg 1; fi + if [ -r ${DIR}/${FILE} ]; then tar -xf ${DIR}/${FILE} || _msg 2; rm ${DIR}/+*; + rm -R ${DIR}/libdata; rm -R ${DIR}/man; rm -R ${DIR}/include; rm ${DIR}/lib/*.a; + rm ${DIR}/bin/slsh; rm ${DIR}/etc/slsh.rc; fi + [ -d ${DIR}/lib ] || _msg 4 +fi +#----------------------- Download and decompress libssh2 files if don't exist --------------------------- +FILE=${LIBSSH2FILE} +if [ ! -f ${DIR}/lib/libssh2.so ]; 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}/libdata; rm -R ${DIR}/man; rm -R ${DIR}/include; rm ${DIR}/lib/*.a; rm ${DIR}/lib/*.la; fi + if [ ! -d ${DIR}/lib ]; then _msg 4; fi +fi +#----------------------- Create symlinks ---------------------------------------------------------------- +[ -e /usr/local/share/mc ] || ln -s ${DIR}/share/mc /usr/local/share +[ -e /usr/local/libexec/mc ] || ln -s ${DIR}/libexec/mc /usr/local/libexec +[ -e /usr/local/etc/mc ] || ln -s ${DIR}/etc/mc /usr/local/etc +for i in `ls ${DIR}/bin/`; do + [ -e /usr/local/bin/${i} ] || ln -s ${DIR}/bin/${i} /usr/local/bin +done +for i in `ls ${DIR}/share/locale`; do + if [ ! -e /usr/local/share/locale/${i} ]; then + ln -s ${DIR}/share/locale/${i} /usr/local/share/locale + else + [ -e /usr/local/share/locale/${i}/LC_MESSAGES/mc.mo ] || \ + ln -s ${DIR}/share/locale/${i}/LC_MESSAGES/mc.mo /usr/local/share/locale/${i}/LC_MESSAGES + fi +done +for i in `ls ${DIR}/lib`; do + [ -e /usr/local/lib/${i} ] || ln -s ${DIR}/lib/${i} /usr/local/lib +done + +# Symlinks for v10.1.0.2 +cd /usr/local/lib +[ -e libssl.so.6 ] || ln -s /usr/lib/libssl.so.7 libssl.so.6 +[ -e libcrypto.so.6 ] || ln -s /lib/libcrypto.so.7 libcrypto.so.6 +[ -e libpcre.so.3 ] || ln -s /usr/local/lib/libpcre.so.1 libpcre.so.3 +[ -e libintl.so.9 ] || ln -s /usr/local/lib/libintl.so.8 libintl.so.9 +[ -e libiconv.so.3 ] || ln -s /usr/local/lib/libiconv.so.2 libiconv.so.3 +cd - + +# Aliases +mkdir -p /etc/profile.d +ln -s ${DIR}/libexec/mc/mc.sh /etc/profile.d +ln -s ${DIR}/libexec/mc/mc.csh /etc/profile.d + +cat <<'EOFF' >> /etc/profile + +# Append any additional sh scripts found in /etc/profile.d +for profile_script in /etc/profile.d/*.sh; do + [ -x ${profile_script} ] && . ${profile_script} +done +unset profile_script +EOFF + +cat <<'EOFF' >> /etc/csh.login + +# Append any additional csh scripts found in /etc/profile.d +[ -d /etc/profile.d ] +if ($status == 0) then + set nonomatch + foreach file ( /etc/profile.d/*.csh ) + [ -x $file ] + if ($status == 0) then + source $file + endif + end + unset file nonomatch +endif +EOFF + +# Done +_msg 3 + +#----------------------- End of Script ------------------------------------------------------------------ +# 1. Keep this script in his own directory. +# 2. chmod the script u+x, +# 3. Always run this script using the full path: /mnt/share/directory/mcommander +# 4. You can add this script to WebGUI: Advanced: Commands as Post command (see 3). +# 5. To run Midnight Commander from shell type 'mc'. diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/menu.inc b/onebuttoninstaller/ext/ext/onebuttoninstaller/menu.inc new file mode 100644 index 0000000..6953e92 --- /dev/null +++ b/onebuttoninstaller/ext/ext/onebuttoninstaller/menu.inc @@ -0,0 +1 @@ +OneButtonInstaller \ No newline at end of file diff --git a/onebuttoninstaller/ext/ext/onebuttoninstaller/spin.min.js b/onebuttoninstaller/ext/ext/onebuttoninstaller/spin.min.js new file mode 100644 index 0000000..bd3ae4f --- /dev/null +++ b/onebuttoninstaller/ext/ext/onebuttoninstaller/spin.min.js @@ -0,0 +1,2 @@ +// http://spin.js.org/#v2.3.2 +!function(a,b){"object"==typeof module&&module.exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return m[e]||(k.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",k.cssRules.length),m[e]=1),e}function d(a,b){var c,d,e=a.style;if(b=b.charAt(0).toUpperCase()+b.slice(1),void 0!==e[b])return b;for(d=0;d',c)}k.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.scale*d.width,left:d.scale*d.radius,top:-d.scale*d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.scale*(d.length+d.width),k=2*d.scale*j,l=-(d.width+d.length)*d.scale*2+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;kYou must apply the changes in order for them to take effect."); +$dummy = gettext("The following input errors were detected"); + +$pgtitle = array(gettext("Extensions"), gettext("OneButtonInstaller")." ".$config['onebuttoninstaller']['version'], gettext("Configuration")); + +if (!isset($config['onebuttoninstaller']) || !is_array($config['onebuttoninstaller'])) $config['onebuttoninstaller'] = array(); + +/* 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 + */ +function change_perms($dir) { + global $input_errors; + + $path = rtrim($dir,'/'); // remove trailing slash + if (strlen($path) > 1) { + if (!is_dir($path)) { // check if directory exists + $input_errors[] = sprintf(gettext("Directory %s doesn't exist!"), $path); + } + else { + $path_check = explode("/", $path); // split path to get directory names + $path_elements = count($path_check); // get path depth + $fp = substr(sprintf('%o', fileperms("/$path_check[1]/$path_check[2]")), -1); // get mountpoint permissions for others + if ($fp >= 5) { // transmission needs at least read & search permission at the mountpoint + $directory = "/$path_check[1]/$path_check[2]"; // set to the mountpoint + for ($i = 3; $i < $path_elements - 1; $i++) { // traverse the path and set permissions to rx + $directory = $directory."/$path_check[$i]"; // add next level + exec("chmod o=+r+x \"$directory\""); // set permissions to o=+r+x + } + $path_elements = $path_elements - 1; + $directory = $directory."/$path_check[$path_elements]"; // add last level + exec("chmod 775 {$directory}"); // set permissions to 775 + exec("chown {$_POST['who']} {$directory}*"); + } + else + { + $input_errors[] = sprintf(gettext("OneButtonInstaller needs at least read & execute permissions at the mount point for directory %s! Set the Read and Execute bits for Others (Access Restrictions | Mode) for the mount point %s (in Disks | Mount Point | Management or Disks | ZFS | Datasets) and hit Save in order to take them effect."), $path, "/{$path_check[1]}/{$path_check[2]}"); + } + } + } +} + +function cronjob_process_updatenotification($mode, $data) { + global $config; + $retval = 0; + switch ($mode) { + case UPDATENOTIFY_MODE_NEW: + case UPDATENOTIFY_MODE_MODIFIED: + break; + case UPDATENOTIFY_MODE_DIRTY: + if (is_array($config['cron']['job'])) { + $index = array_search_ex($data, $config['cron']['job'], "uuid"); + if (false !== $index) { + unset($config['cron']['job'][$index]); + write_config(); + } + } + break; + } + return $retval; +} + +if (isset($_POST['save']) && $_POST['save']) { + 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 (!is_dir($config['onebuttoninstaller']['storage_path'])) mkdir($config['onebuttoninstaller']['storage_path'], 0775, true); + change_perms($_POST['storage_path']); + + if (isset($_POST['enable_schedule']) && ($_POST['startup'] == $_POST['closedown'])) { $input_errors[] = gettext("Startup and closedown hour must be different!"); } + else { + if (isset($_POST['enable_schedule'])) { + $config['onebuttoninstaller']['enable_schedule'] = isset($_POST['enable_schedule']) ? true : false; + $config['onebuttoninstaller']['schedule_startup'] = $_POST['startup']; + $config['onebuttoninstaller']['schedule_closedown'] = $_POST['closedown']; + + $cronjob = array(); + $a_cronjob = &$config['cron']['job']; + $uuid = isset($config['onebuttoninstaller']['schedule_uuid_startup']) ? $config['onebuttoninstaller']['schedule_uuid_startup'] : false; + if (isset($uuid) && (FALSE !== ($cnid = array_search_ex($uuid, $a_cronjob, "uuid")))) { + $cronjob['enable'] = true; + $cronjob['uuid'] = $a_cronjob[$cnid]['uuid']; + $cronjob['desc'] = "OneButtonInstaller startup (@ {$config['onebuttoninstaller']['schedule_startup']}:00)"; + $cronjob['minute'] = $a_cronjob[$cnid]['minute']; + $cronjob['hour'] = $config['onebuttoninstaller']['schedule_startup']; + $cronjob['day'] = $a_cronjob[$cnid]['day']; + $cronjob['month'] = $a_cronjob[$cnid]['month']; + $cronjob['weekday'] = $a_cronjob[$cnid]['weekday']; + $cronjob['all_mins'] = $a_cronjob[$cnid]['all_mins']; + $cronjob['all_hours'] = $a_cronjob[$cnid]['all_hours']; + $cronjob['all_days'] = $a_cronjob[$cnid]['all_days']; + $cronjob['all_months'] = $a_cronjob[$cnid]['all_months']; + $cronjob['all_weekdays'] = $a_cronjob[$cnid]['all_weekdays']; + $cronjob['who'] = 'root'; + $cronjob['command'] = "{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller_start.php && logger onebuttoninstaller: scheduled startup"; + } else { + $cronjob['enable'] = true; + $cronjob['uuid'] = uuid(); + $cronjob['desc'] = "OneButtonInstaller startup (@ {$config['onebuttoninstaller']['schedule_startup']}:00)"; + $cronjob['minute'] = 0; + $cronjob['hour'] = $config['onebuttoninstaller']['schedule_startup']; + $cronjob['day'] = true; + $cronjob['month'] = true; + $cronjob['weekday'] = true; + $cronjob['all_mins'] = 0; + $cronjob['all_hours'] = 0; + $cronjob['all_days'] = 1; + $cronjob['all_months'] = 1; + $cronjob['all_weekdays'] = 1; + $cronjob['who'] = 'root'; + $cronjob['command'] = "{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller_start.php && logger onebuttoninstaller: scheduled startup"; + $config['onebuttoninstaller']['schedule_uuid_startup'] = $cronjob['uuid']; + } + if (isset($uuid) && (FALSE !== $cnid)) { + $a_cronjob[$cnid] = $cronjob; + $mode = UPDATENOTIFY_MODE_MODIFIED; + } else { + $a_cronjob[] = $cronjob; + $mode = UPDATENOTIFY_MODE_NEW; + } + updatenotify_set("cronjob", $mode, $cronjob['uuid']); +// write_config(); + + unset ($cronjob); + $cronjob = array(); + $a_cronjob = &$config['cron']['job']; + $uuid = isset($config['onebuttoninstaller']['schedule_uuid_closedown']) ? $config['onebuttoninstaller']['schedule_uuid_closedown'] : false; + if (isset($uuid) && (FALSE !== ($cnid = array_search_ex($uuid, $a_cronjob, "uuid")))) { + $cronjob['enable'] = true; + $cronjob['uuid'] = $a_cronjob[$cnid]['uuid']; + $cronjob['desc'] = "OneButtonInstaller closedown (@ {$config['onebuttoninstaller']['schedule_closedown']}:00)"; + $cronjob['minute'] = $a_cronjob[$cnid]['minute']; + $cronjob['hour'] = $config['onebuttoninstaller']['schedule_closedown']; + $cronjob['day'] = $a_cronjob[$cnid]['day']; + $cronjob['month'] = $a_cronjob[$cnid]['month']; + $cronjob['weekday'] = $a_cronjob[$cnid]['weekday']; + $cronjob['all_mins'] = $a_cronjob[$cnid]['all_mins']; + $cronjob['all_hours'] = $a_cronjob[$cnid]['all_hours']; + $cronjob['all_days'] = $a_cronjob[$cnid]['all_days']; + $cronjob['all_months'] = $a_cronjob[$cnid]['all_months']; + $cronjob['all_weekdays'] = $a_cronjob[$cnid]['all_weekdays']; + $cronjob['who'] = 'root'; + $cronjob['command'] = "{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller_stop.php && logger onebuttoninstaller: scheduled closedown"; + } else { + $cronjob['enable'] = true; + $cronjob['uuid'] = uuid(); + $cronjob['desc'] = "OneButtonInstaller closedown (@ {$config['onebuttoninstaller']['schedule_closedown']}:00)"; + $cronjob['minute'] = 0; + $cronjob['hour'] = $config['onebuttoninstaller']['schedule_closedown']; + $cronjob['day'] = true; + $cronjob['month'] = true; + $cronjob['weekday'] = true; + $cronjob['all_mins'] = 0; + $cronjob['all_hours'] = 0; + $cronjob['all_days'] = 1; + $cronjob['all_months'] = 1; + $cronjob['all_weekdays'] = 1; + $cronjob['who'] = 'root'; + $cronjob['command'] = "{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller_stop.php && logger onebuttoninstaller: scheduled closedown"; + $config['onebuttoninstaller']['schedule_uuid_closedown'] = $cronjob['uuid']; + } + if (isset($uuid) && (FALSE !== $cnid)) { + $a_cronjob[$cnid] = $cronjob; + $mode = UPDATENOTIFY_MODE_MODIFIED; + } else { + $a_cronjob[] = $cronjob; + $mode = UPDATENOTIFY_MODE_NEW; + } + updatenotify_set("cronjob", $mode, $cronjob['uuid']); +// write_config(); + } // end of enable_schedule + else { + $config['onebuttoninstaller']['enable_schedule'] = isset($_POST['enable_schedule']) ? true : false; + updatenotify_set("cronjob", UPDATENOTIFY_MODE_DIRTY, $config['onebuttoninstaller']['schedule_uuid_startup']); + if (is_array($config['cron']['job'])) { + $index = array_search_ex($data, $config['cron']['job'], "uuid"); + if (false !== $index) { + unset($config['cron']['job'][$index]); + } + } +// write_config(); + updatenotify_set("cronjob", UPDATENOTIFY_MODE_DIRTY, $config['onebuttoninstaller']['schedule_uuid_closedown']); + if (is_array($config['cron']['job'])) { + $index = array_search_ex($data, $config['cron']['job'], "uuid"); + if (false !== $index) { + unset($config['cron']['job'][$index]); + } + } +// write_config(); + } // end of disable_schedule -> remove cronjobs + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) { + $retval |= updatenotify_process("cronjob", "cronjob_process_updatenotification"); + config_lock(); + $retval |= rc_update_service("cron"); + config_unlock(); + } +// $savemsg .= get_std_save_message($retval).'
'; + if ($retval == 0) { + updatenotify_delete("cronjob"); + } + } // end of schedule change + + $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']; + +include("fbegin.inc");?> + +
+ + + +
+
    + +
  • +
  • +
  • + +
  • +
  • + +
+
+ + + + + + /mnt/)."), $pconfig['storage_path'], true, 60);?> +
+
+ "/> +
+
+ +
+ + diff --git a/onebuttoninstaller/ext/onebuttoninstaller-update_extension.php b/onebuttoninstaller/ext/onebuttoninstaller-update_extension.php new file mode 100644 index 0000000..01e769a --- /dev/null +++ b/onebuttoninstaller/ext/onebuttoninstaller-update_extension.php @@ -0,0 +1,199 @@ + + +
+ + +
+ + + +
+
    + +
  • +
  • +
  • + +
  • +
  • + +
+
+ + + + + + + +
+
+ Please note: this page will no longer be available. You'll have to re-run OneButtonInstaller extension installation to get it back on your NAS4Free."));?> +
+ " onclick="return confirm('')" /> + " onclick="return confirm('')" /> +
+ + + + + + + +
+
+ +
+
+ +
+
+ +
diff --git a/onebuttoninstaller/ext/onebuttoninstaller.php b/onebuttoninstaller/ext/onebuttoninstaller.php new file mode 100644 index 0000000..f2a48c2 --- /dev/null +++ b/onebuttoninstaller/ext/onebuttoninstaller.php @@ -0,0 +1,223 @@ + TRUE, + "desc" => gettext("Extensions"), + "logfile" => "{$config['onebuttoninstaller']['rootfolder']}extensions.txt", + "filename" => "extensions.txt", + "type" => "plain", + "pattern" => "/^(.*)###(.*)###(.*)###(.*)###(.*)###(.*)$/", + "columns" => array( + array("title" => gettext("Extensions"), "class" => "listlr", "param" => "align=\"left\" valign=\"middle\" nowrap", "pmid" => 0), + array("title" => gettext("Version"), "class" => "listr", "param" => "align=\"center\" valign=\"middle\"", "pmid" => 1), + array("title" => gettext("Description"), "class" => "listr", "param" => "align=\"left\" valign=\"middle\"", "pmid" => 5), + array("title" => gettext("Install"), "class" => "listr", "param" => "align=\"center\" valign=\"middle\"", "pmid" => 4) + )) +); + +function log_get_contents($logfile) { + $content = array(); + if (is_file($logfile)) exec("cat {$logfile}", $extensions); + else return; + $content = $extensions; + return $content; +} + +function log_display($loginfo) { + global $config; + global $savemsg; + + if (!is_array($loginfo)) return; + + // Create table header + echo ""; + foreach ($loginfo['columns'] as $columnk => $columnv) { + echo "".htmlspecialchars($columnv['title'])."\n"; + } + echo ""; + + // Get file content + $content = log_get_contents($loginfo['logfile']); + if (empty($content)) return; + sort($content); + + $j = 0; + +/* + * 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) + * xmlstring: 2 config.xml or installation directory + * command(list)1: 3 SHELL commands + * command(list)2: 4 PHP commands + * description: 5 plain text which can include HTML tags + */ + +/* DEBUGGER +print_r($result[3]); +echo('
'); +print_r($result[4]); +echo('
'); + */ + + // Create table data + foreach ($content as $contentv) { // handle each line => one extension + unset($result); + $result = explode("###", $contentv); // retrieve extension content (pmid based) + if ((FALSE === $result) || (0 == $result)) continue; + echo "\n"; + for ($i = 0; $i < count($loginfo['columns']); $i++) { // handle pmids (columns) + if ($i == count($loginfo['columns']) - 1) { + // check if extension is already installed (config.xml entry or for command line tools based on install directory) + if ((isset($config[$result[2]])) || ((strpos($result[2], "/") == 0) && (is_dir("{$config['onebuttoninstaller']['storage_path']}{$result[2]}")))){ + echo " \n"; + } + else { // data for installation + echo " + + + + \n"; + } + } + else echo "" . $result[$loginfo['columns'][$i]['pmid']] . "\n"; + } + echo "\n"; + $j++; + } +} + +//ob_start(); +//$ausgabe = ob_get_contents(); +//ob_end_clean(); +//foreach ($ausgabe as $msg) $savemsg .= $msg."
"; +if (isset($_POST) && $_POST) { + foreach($_POST[name] as $line) { + if (isset($line['extension'])) { + $savemsg .= "{$line['extension']}"."
"; + $savemsg .= print_r($line, true)."
"; + unset($result); + exec("cd {$config["onebuttoninstaller"]["storage_path"]} && {$line['command1']}", $result, $return_val); + if ($return_val == 0) { + $savemsg .= "command1 successful"."
"; + foreach ($result as $msg) $savemsg .= $msg."
"; + unset($result); +// exec("cd {$config["onebuttoninstaller"]["storage_path"]} && {$line['command2']}", $result, $return_val); +// if (file_exists("{$config["onebuttoninstaller"]["storage_path"]}/{$line['command2']}")) { + if ("{$line['command2']}" != "-") { +ob_start(); + require_once("{$config['onebuttoninstaller']['storage_path']}/{$line['command2']}"); +ob_end_clean(); + if ($return_val == 0) { + $savemsg .= "
"."command2 successful"."
"; +// foreach ($result as $msg) $savemsg .= $msg."
"; + } + else { + $errormsg .= gettext("Error")."
"; +// foreach ($result as $msg) $errormsg .= $msg."
"; + $savemsg .= "command2 NOT successful"."
"; + } + } +// else $errormsg .= "Error: file {$config["onebuttoninstaller"]["storage_path"]}/{$line['command2']} not found!"."
"; + } + else { + $errormsg .= gettext("Error on command1")."
"; + foreach ($result as $msg) $errormsg .= $msg."
"; + $savemsg .= "command1 NOT successful"."
"; + } + } + } +} + +if (!is_file("{$config['onebuttoninstaller']['rootfolder']}extensions.txt")) $savemsg .= sprintf(gettext("File %s not found!"), "{$config['onebuttoninstaller']['rootfolder']}extensions.txt"); + +include("fbegin.inc");?> + +
+ + +
+ + + +
+
    +
  • +
  • +
  • +
+
+ + + + +
+
+ " value="" onclick="return confirm('')" /> + " value="" /> +
+ +
+
+ +
diff --git a/onebuttoninstaller/extensions.txt b/onebuttoninstaller/extensions.txt new file mode 100644 index 0000000..d85f804 --- /dev/null +++ b/onebuttoninstaller/extensions.txt @@ -0,0 +1,13 @@ +Extended GUI###0.5.1.2###extended-gui###mkdir -p extended-gui/backup && mkdir -p extended-gui/log && cd extended-gui && fetch https://raw.github.com/crestAT/nas4free-extended-gui/master/extended-gui/extended-gui-install.php && chmod 770 extended-gui*install.php && echo "fetch OK"###extended-gui/extended-gui-install.php###Extension for NAS4Free with several improvements for the WebGUI and additional functions. Most of the extension affects STATUS | SYSTEM view but also STATUS | GRAPH and DIAGNOSTICS | LOG which got a new entry NOTIFICATIONS.

The extension works on all plattforms (x86 & x64, ARM, embedded & full), does not need jail or pkg_add, enhance pages of the NAS4Free WebGUI, features configuration and extension maintenance (update & removal inside the WebGUI), let you switch between STANDARD (original) and EXTENDED WebGUI view and let you easily configure/enable/disable views and additional functions.
For more information -> NAS4Free Forum +Downloady###0.1###downloady###mkdir -p downloady/log && cd downloady && ls -hal && fetch -v https://raw.github.com/crestAT/nas4free-downloady/master/downloady/downloady-install.php && chmod 770 downloady*install.php && echo "fetch OK"###downloady/downloady-install.php###Simple PHP download manager which is fully integrated into the NAS4Free WebGUI.

Downloady for NAS4Free is based on Downloady - the PHP Download Manager by CyberLeo@cyberLeo Projects and features downloads from http, https and ftp sites as well as download bandwith managment, resume downloads after system startup and a simple scheduler. The extension works on all plattforms (x86 & x64, ARM, embedded & full), does not need jail or pkg_add, enhance pages of the NAS4Free WebGUI and features configuration and extension maintenance. +RRDGraphs###0.3.1###rrdgraphs###mkdir -p rrdgraphs && cd rrdgraphs && fetch https://raw.github.com/crestAT/nas4free-rrdtool/master/rrdgraphs/rrd-install.php && chmod 770 rrd*install.php && echo "fetch OK"###rrdgraphs/rrd-install.php###Extension to install / configure / update and remove RRDTool based graphs for NAS4Free servers.

The extension is based on RRDtool and provides graphs for CPU frequency, CPU temperature, CPU usage, Disk usage (recognition of all mountpoints/shares automatically at RRDG startup), Load averages, Memory usage, Network latency, Network traffic, Processes, UPS, Uptime and ZFS ARC.

The extension is compatible with all versions (9.1.x - 10.x) of NAS4Free except on ARM boxes and works on all plattforms (x86 & x64, embedded & full), does not need jail or pkg_add, add pages to NAS4Free Web GUI extensions, features configuration and extension maintenance (update & removal inside the WebGUI) and is able to work on RAM drives to take care of your HDDs/USB pen drives.
For more information -> NAS4Free Forum +BitTorrent Sync###0.6.4.2###btsync###mkdir -p btsync && cd btsync && fetch https://raw.github.com/crestAT/nas4free-bittorrent-sync/master/bts-install.php && chmod 770 bts*install.php && echo "fetch OK"###btsync/bts-install.php###Extension to install / configure / backup / update / manage and remove BitTorrent Sync application on NAS4Free servers.

The extension can be used with BitTorrent Sync 1.4.x (last version was 1.4.111) as well as 2.x, is compatible with all versions (9.1.x - 10.x) of NAS4Free except on ARM boxes, works on all plattforms (embedded, full), does not need jail or pkg_add, add pages to NAS4Free Web GUI extensions, features configuration, application update & backup management, extension mantenance (update & removal) and log view with filter and search capability.

Note: Standard BitTorrent Sync version is based on 2.x releases, to use the latest 1.x release open Extensions | BitTorrent Sync | Maintenance and change the Download URL for version 1.4.111:
64 bit: http://syncapp.bittorrent.com/1.4.111/btsync_freebsd_x64-1.4.111.tar.gz
32 bit: http://syncapp.bittorrent.com/1.4.111/btsync_freebsd_i386-1.4.111.tar.gz
and hit Save URL, Fetch and Install.
For more information -> NAS4Free Forum +Syncthing###0.1.3###syncthing###mkdir -p syncthing && cd syncthing && fetch https://raw.github.com/crestAT/nas4free-syncthing/master/stg-install.php && chmod 770 stg*install.php && echo "fetch OK"###syncthing/stg-install.php###Extension to install / configure / backup / update / manage and remove Syncthing (STG) application on NAS4Free (N4F) servers.

The extension works on all plattforms, does not need jail or pkg_add, add pages to NAS4Free WebGUI extensions, features configuration, application update & backup management, scheduling and log view with filter / search capabilities.
For more information -> NAS4Free Forum +ezPlex Lite###2.01###ezplex###mkdir -p plex && cd plex && fetch https://dl.dropboxusercontent.com/u/98883057/Unix/NAS4Free/Addons/ezPlex/Release/v2%20Lite/ezplex-201-lite.tgz && tar xf ezplex*.tgz && echo "fetch OK"###plex/plex/ezplex.php###Plex Offline Installer for NAS4Free 9.3/10.2 x64.

The extension works on NAS4Free Embedded and Full platforms 9.3/10.x 64-Bit, don't need chroot/jail or fstab configurations, automatically creates/configure Unionfs on NAS4Free Embedded, Plex package can be natively upgraded through the ezPlex installer or through pkg upgrade on either platforms*, will add the corresponding user configurable Plex entries on the WebGUI automatically, Plex IP address will be locally visible by clients/devices, no changes will be made to the NAS4Free default shell profiles.

Note: After install simply reboot and enjoy ezPlex.
For more information -> NAS4Free Forum +Finch Lite###1.51###finch###mkdir -p finch && cd finch && fetch https://dl.dropboxusercontent.com/u/98883057/Unix/NAS4Free/Addons/Finch-Light/Release/Finch-Light%20for%20N4F%2010.2%20x64/finch-light-151-n4f10.2x64.tgz && echo "fetch OK" && tar -xvf finch-light*.tgz && echo "tar OK"###finch/finch/finch-light.php###Finch-Light Offline Installer for NAS4Free 10.2 based systems.

With this version of Finch(FreeBSD in a chroot) you can quickly install packages directly in to the chroot right after installation with pkg install pkgname, or just issue a portsnap fetch extract if you want to compile them, credits and thanks goes to Dreamcat4 the developer of Finch. After downloading and unzip the main files to the desired directory, run the finch-light.php and the script will gather the current working directory and bring up the install options, the Finch PostInit/Shutdown commands will be added to the WebGUI automatically, also remember to logout and login back to SSH/Console for the new shell to take effect.

Note: default shell for root will be changed from tcsh to bash and is normal Finch behavior.

To auto configure Fstab go to Advanced|Execute command and provide the desired directory in the format shown below and execute it, also you can type dofstab -h for cli usage instead.
Format: cd /path/to/media && dofstab -c

For manually edit Finch-Light fstab use Advanced|File Editor or CLI.
For more information -> NAS4Free Forum +TheBrig###0.92###thebrig###mkdir -p thebrig && cd thebrig && fetch https://raw.githubusercontent.com/fsbruva/thebrig/alcatraz/thebrig_install.sh && chmod a+x thebrig_install.sh && sh thebrig_install.sh###-###Jail manager extension for NAS4Free.

For more information -> NAS4Free Forum +DNSMasq DHCP Server###0.2###dnsmasq###mkdir -p dnsmasq && cd dnsmasq && fetch https://raw.github.com/alexey1234/nas4free-dnsmasq/master/dnsmasq_install.sh && chmod a+x dnsmasq_install.sh && sh dnsmasq_install.sh###-###DNSMasq DHCP Server extension for NAS4Free.

For more information -> NAS4Free Forum +Midnight Commander###2015-02-21###/midnightcommander###mkdir -p midnightcommander && cd midnightcommander && cp /usr/local/www/ext/onebuttoninstaller/mcommander.sh . && echo "copy OK" && chmod u+x mcommander.sh && echo "chmod OK" && `pwd`/mcommander.sh###-###Midnight Commander for NAS4Free.

After the successful installation you can use Midnight Commander in the system console shell or if you connect via ssh. To start the Midnight Commander just enter the command mc in the CLI.
For more information -> NAS4Free Forum +zzz Dummy Project1###1.0###DummyProject###fetch https://raw.github.com/crestAT/nas4free-extended-gui/master/extended-gui_install.php && chmod 770 extended-gui*install.php && echo "fetch OK"###cat TEST/release_notes.txt && echo "\nFERTIG bin ich\n" && chmod 770 TEST/test.sh && TEST/test.sh###This is a testbed for NAS4Free extensions!!!
Note: Don't use this extension!!! +zzz WebGUI Themes###6.6###themes###command1 themes ### command2 themes ### blah blah blah blah blah +zzz RSS Feeder###x.y.z###rssfeed###command1 rssfeed ### command2 rssfeed ### blah blah blah blah blah diff --git a/onebuttoninstaller/onebuttoninstaller-install.php b/onebuttoninstaller/onebuttoninstaller-install.php new file mode 100644 index 0000000..a868abc --- /dev/null +++ b/onebuttoninstaller/onebuttoninstaller-install.php @@ -0,0 +1,126 @@ += 9.3 +$release = explode("-", exec("uname -r")); +if ($release[0] >= 9.3) $verify_hostname = "--no-verify-hostname"; +else $verify_hostname = ""; +// create stripped version name +$vs = str_replace(".", "", $v); +// fetch release archive +$return_val = 0;//mwexec("fetch {$verify_hostname} -vo {$install_dir}master.zip 'https://github.com/crestAT/nas4free-onebuttoninstaller/releases/download/{$v}/onebuttoninstaller-{$vs}.zip'", true); +if ($return_val == 0) { + $return_val = 0;//mwexec("tar -xf {$install_dir}master.zip -C {$install_dir} --exclude='.git*' --strip-components 2", true); + if ($return_val == 0) { +// exec("rm {$install_dir}master.zip"); + exec("chmod -R 775 {$install_dir}"); + if (is_file("{$install_dir}version.txt")) { $file_version = exec("cat {$install_dir}version.txt"); } + else { $file_version = "n/a"; } + $savemsg = sprintf(gettext("Update to version %s completed!"), $file_version); + } + else { + $input_errors[] = sprintf(gettext("Archive file %s not found, installation aborted!"), "master.zip corrupt /"); + return; + } +} +else { + $input_errors[] = sprintf(gettext("Archive file %s not found, installation aborted!"), "master.zip"); + return; +} + +// install / update application on NAS4Free +if ( !isset($config['onebuttoninstaller']) || !is_array($config['onebuttoninstaller'])) { +// new installation + $config['onebuttoninstaller'] = array(); + $config['onebuttoninstaller']['appname'] = $appname; + $config['onebuttoninstaller']['version'] = exec("cat {$install_dir}version.txt"); + $config['onebuttoninstaller']['rootfolder'] = $install_dir; + $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('/onebuttoninstaller/', $config['rc']['postinit']['cmd'][$i])) break; ++$i; } + } + $config['rc']['postinit']['cmd'][$i] = $config['onebuttoninstaller']['rootfolder']."onebuttoninstaller_start.php"; + $i =0; + if ( is_array($config['rc']['shutdown'] ) && is_array( $config['rc']['shutdown']['cmd'] ) ) { + for ($i; $i < count($config['rc']['shutdown']['cmd']); ) { + if (preg_match('/onebuttoninstaller/', $config['rc']['shutdown']['cmd'][$i])) break; ++$i; } + } + $config['rc']['shutdown']['cmd'][$i] = $config['onebuttoninstaller']['rootfolder']."onebuttoninstaller_stop.php"; + write_config(); + require_once("{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller-start.php"); + echo "\n".$appname." Version ".$config['onebuttoninstaller']['version']." installed"; + echo "\n\nInstallation completed, use WebGUI | Extensions | ".$appname." to configure \nthe application (don't forget to refresh the WebGUI before use)!\n"; +} +else { +// update release + $config['onebuttoninstaller']['version'] = exec("cat {$install_dir}version.txt"); + $config['onebuttoninstaller']['rootfolder'] = $install_dir; + $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('/onebuttoninstaller/', $config['rc']['postinit']['cmd'][$i])) break; ++$i; } + } + $config['rc']['postinit']['cmd'][$i] = $config['onebuttoninstaller']['rootfolder']."onebuttoninstaller_start.php"; + $i =0; + if ( is_array($config['rc']['shutdown'] ) && is_array( $config['rc']['shutdown']['cmd'] ) ) { + for ($i; $i < count($config['rc']['shutdown']['cmd']); ) { + if (preg_match('/onebuttoninstaller/', $config['rc']['shutdown']['cmd'][$i])) break; ++$i; } + } + $config['rc']['shutdown']['cmd'][$i] = $config['onebuttoninstaller']['rootfolder']."onebuttoninstaller_stop.php"; + write_config(); + require_once("{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller-start.php"); +} +?> diff --git a/onebuttoninstaller/onebuttoninstaller-start.php b/onebuttoninstaller/onebuttoninstaller-start.php new file mode 100644 index 0000000..7c62121 --- /dev/null +++ b/onebuttoninstaller/onebuttoninstaller-start.php @@ -0,0 +1,36 @@ + diff --git a/onebuttoninstaller/onebuttoninstaller-stop.php b/onebuttoninstaller/onebuttoninstaller-stop.php new file mode 100644 index 0000000..c7fe2f2 --- /dev/null +++ b/onebuttoninstaller/onebuttoninstaller-stop.php @@ -0,0 +1,36 @@ + diff --git a/onebuttoninstaller/onebuttoninstaller_start.php b/onebuttoninstaller/onebuttoninstaller_start.php new file mode 100644 index 0000000..f437d93 --- /dev/null +++ b/onebuttoninstaller/onebuttoninstaller_start.php @@ -0,0 +1,5 @@ +#!/usr/local/bin/php-cgi -f + diff --git a/onebuttoninstaller/onebuttoninstaller_stop.php b/onebuttoninstaller/onebuttoninstaller_stop.php new file mode 100644 index 0000000..de4509a --- /dev/null +++ b/onebuttoninstaller/onebuttoninstaller_stop.php @@ -0,0 +1,5 @@ +#!/usr/local/bin/php-cgi -f + diff --git a/onebuttoninstaller/release_notes.txt b/onebuttoninstaller/release_notes.txt new file mode 100644 index 0000000..e1d21df --- /dev/null +++ b/onebuttoninstaller/release_notes.txt @@ -0,0 +1,6 @@ +Version Date Description +0.1-a1 2016.01.19 initial release + +N: ... new feature +C: ... changes +F: ... bug fix diff --git a/onebuttoninstaller/version.txt b/onebuttoninstaller/version.txt new file mode 100644 index 0000000..9a50c30 --- /dev/null +++ b/onebuttoninstaller/version.txt @@ -0,0 +1 @@ +0.1-a4 diff --git a/onebuttoninstaller_install.php b/onebuttoninstaller_install.php new file mode 100644 index 0000000..d34af41 --- /dev/null +++ b/onebuttoninstaller_install.php @@ -0,0 +1,16 @@ +#!/usr/local/bin/php-cgi -f += 9.3 +$release = explode("-", exec("uname -r")); +if ($release[0] >= 9.3) $verify_hostname = "--no-verify-hostname"; +else $verify_hostname = ""; + +$return_val = 0;//mwexec("fetch {$verify_hostname} -vo onebuttoninstaller/onebuttoninstaller-install.php 'https://raw.github.com/crestAT/nas4free-onebuttoninstaller/master/onebuttoninstaller/onebuttoninstaller-install.php'", true); +if ($return_val == 0) { + chmod("onebuttoninstaller/onebuttoninstaller-install.php", 0775); + require_once("onebuttoninstaller/onebuttoninstaller-install.php"); +} +else { echo "\nInstallation file 'onebuttoninstaller-install.php' not found, installation aborted!\n"; } +?>