April 23, 201115 yr So I have been tinkering with unMenu and unRaid the last couple days. Is it just me or is unMenu a square peg being hammered in a round hole? the idea that its based off AWK and able to handle one request at a time seems sooo... rudimentary. The lack of real wget also seems very ... old school. Is there a specific reason why not just use shell scripts? I dont want to tread on any toes but I cant seem to grasp why unMenu over shell script.... wide eyed and curious.... ~ dpc
April 23, 201115 yr UnMenu is an excellent GUI, making life easy for those of us who are not Linux experts. You are of course free not to use it - much of the functionality can be done using shell scripts you write yourself.
April 23, 201115 yr @delicatepc Its something that a forum member/user came up with. I'm sure Joel L would love for somebody else to come up with something a bit slicker and more expansive, but in the mean time many, many users like myself look at it as a free, but useful tool.
April 23, 201115 yr Author Makes sense. Dont get me wrong - not trying to bash on a free solution that fits a user needs. I was more curious on if there was inherent magic unMenu that shell scripts didnt have (outside user point and click friendly). With that in mind I have begun the rewrite of several of the unMenu packages to shell scripts as I like the ability shell has to give me more options (for example in current script I am writing is offering the user option of installing the stable version or beta of the package - this is handy as beta version often carry lot of new features that I like). thank you, ~dpc
April 23, 201115 yr I think the initial impetus is, how much can I do with the tools available in stock unRAID. It's a really fine job! Kudos to all involved. Frankly, I would have done it with miniperl or a mini compiled http server and shell scripts. I had gotten to a point with a compiled C mini http server and embedded mini perl interpreter. unMenu via awk was first and I decided to not bother reinventing the wheel. Since unRAID v5 will have PHP installed, I don't see the need to go down the road of any major tools for gui management. From what I've seen emhttp can do allot of what other tools do. My only issue thus far is to have emhttp be able to run programs in a true CGI environment so I could install NAGIOS for monitoring unRAID. if emhttp could do cgi-bin apps, then people can use php, shell or anything. I realize php can run other tools, but I think the nagios stuff needed a real cgi-bin environment.
April 24, 201115 yr Before you spend too much time rewriting something for the 4.x unRAID series you should check out the v5 Beta series (on a test array first). It is vastly improved for user plugins and addons, so much so, that I view any efforts to develop on 4.x to be completely wasted efforts. I too wish for unRAID v5 to offer a true CGI-bin environment as well. More options the better. Though at least with what it provides for v5, the user can more easily install addons like a genuine web server to have it handle CGI-bin envrionments.
April 24, 201115 yr So I have been tinkering with unMenu and unRaid the last couple days. Is it just me or is unMenu a square peg being hammered in a round hole? the idea that its based off AWK and able to handle one request at a time seems sooo... rudimentary. The lack of real wget also seems very ... old school. At the time unMENU was written, "wget" was not part of unRAID. Nor was any "real" web-server. "php" did not exist, nor lighttpd, nor apache. At the time, I was not aware that bash shell could do networking, or it probably would have been done using it. As it turned out, "gawk" (gnu awk) could open network ports, so I used it. I know it is probably one of the more complex web-interfaces built using it, because I scoured the web looking for examples of its netwlrking capability, and there are darned few except the one in its manual pages. As one other person has said, you are free to not use unMENU. I specifically made it easy for newcommers to extend. It evolved far further that I would have guessed. The recent version of unRAID 5.0beta6 has broken its built-in version of "wget", but just for some. It works here on both my servers. If it were to break here so I could see it not work, I'd fix it. As it is, I'm just going to modify it to use "wget" if it is available. remember, "wget" did not exist, php did not exist, hell, even "awk" did not exist in unRAID if you go back far enough. It is there based on a request I made years ago... and I had no idea it could do networking back then. So, you ask why "awk?" Easy. It was available on everyone's server, with no download. Why unMENU, easy, it is a way to visualize how the user interface could be improved. Why unRAID 5.X, Easy. We proved to lime-tech that an extensible framework would be desirable. I do not expect unMENU to stay around forever, but it sure does a lot that unRAID cannot. Once unRAID 5.0 gets to be more mainstream, it will slowly be replaced with PHP replacements, if, and only if people write the equivalents. In the mean time, I invite you to extend unRAID in any way you like and share your work as I have. You are welcome to extend unMENU, or write a plugin for it. They can be written in shell, and apparently you have shell programming skills. As an example, the network performance plugin ( 15-unmenu-network_perf.cgi ) is entirely in shell, with the bulk of it being the style sheet. Is there a specific reason why not just use shell scripts? I dont want to tread on any toes but I cant seem to grasp why unMenu over shell script.... Again, easy, at the time I did not know bash shell could open network ports and did not know enough about "inetd" to use it with shell scripts. wide eyed and curious.... dpc Hopefully, the answers will help you understand. Joe L.
April 24, 201115 yr Author thank you for the reply folks - especially the detailed one from you Joe. It makes sense. Not so much skilled with shell scripting but lots of info I can find on google and i feel pretty comfortable with terminal sort of stuff - feels very clean once polished. @BRIT - I am actually focusing on 5 latest beta... I like the bleeding edge. I like to create these scripts more for my simplicity sake and then share them out. Last one had 2400+ downloads (crazy number for me).... A sneak peek at the script im working on porting (a good chunk copying from sources here): #!/bin/bash echo echo echo " ******* SABnzbd, SickBeard, and CouchPotato *******" echo " ******* for unRaid 5 *******" echo " ~dpc" echo echo " -------Listing of /mnt/--------" echo ls /mnt echo echo "-- Please enter the drive/volume you want to install your custom packages on: --" echo read customvolume echo echo "-- Creating locations for custom package installations --" echo mkdir /mnt/$customvolume/.custom mkdir /boot/packages sleep 5 echo echo #Define the architecture of the box arch=`uname -m` ip=($(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')) echo " ******* Architecture of Machine is" $arch " *******" echo " Machine IP: $ip" echo " ^^^IP will be used for package install^^^" echo #Pull latest version number and assign to variable and then display it stable=($(wget -q -O - http://sabnzbdplus.sourceforge.net/version/latest | awk '/0/{gsub(/\015/,"");print}')) beta=($(wget -q -O - http://sabnzbdplus.sourceforge.net/version/latest | awk '/2/{gsub(/\015/,"");print}')) echo " Latest SABnzbd Stable version is: $stable" echo " Latest SABnzbd Beta version is: $beta" #Menu echo "" echo " Which Version do you wish to Install?" echo " ----- ------- -- --- ---- -- --------" echo " SickBeard and CouchPotato are also Installed" echo echo "[a] Install SABnzbd 0.6.0RC2 (tested good)" echo "[b] Install latest STABLE SABnzbd $stable" echo "[c] Install latest BETA SABnzbd $beta" echo "[d] Exit" echo #Reads the input user puts in assigns to "option". the -n 1 tells it to read the first character inputted and proceed (without waiting for enter press) read -n 1 option echo cd /tmp #Acts on what user entered case "$option" in "a") echo echo "*******Selected Option A: SABnzbd 0.6.0RC2 (tested good)*******" echo echo "Downloading SABnzbd 0.6.0RC2" wget -nv http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus-beta/sabnzbd-0.6.0RC2/SABnzbd-0.6.0RC2-src.tar.gz ;; "b") echo echo "*******Selected Option B: Latest STABLE SABnzbd $stable*******" echo echo "Downloading latest STABLE SABnzbd $stable" wget -nv http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus/sabnzbd-${stable}/SABnzbd-${stable}-src.tar.gz ;; "c") echo echo "*******Selected Option C: Latest BETA SABnzbd $beta*******" echo echo "Downloading latest BETA SABnzbd ($beta)" wget -nv http://downloads.sourceforge.net/project/sabnzbdplus/sabnzbdplus-beta/sabnzbd-${beta}/SABnzbd-${beta}-src.tar.gz ;; "d") echo echo "Exiting" exit ;; * ) echo echo "Wrong selection nothing selected" echo "Exiting" exit ;; esac echo echo #Continues with script echo "******* 1. Installing the required prerequisites *******" echo cd /boot/packages echo "-- Downloading Perquisites --" wget -q http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/ap/nano-2.2.4-i486-1.txz wget -q http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/d/python-2.6.4-i486-1.txz wget -q http://connie.slackware.com/~alien/slackbuilds/python-cheetah/pkg/13.0/python-cheetah-2.4.2.1-i486-1alien.tgz wget -q http://connie.slackware.com/~alien/slackbuilds/python-yenc/pkg/13.0/python-yenc-0.3-i486-1alien.tgz wget -q http://chuchusoft.com/par2_tbb/par2cmdline-0.4-tbb-20090203-lin32.tar.gz wget -q http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/ap/sqlite-3.6.23.1-i486-1.txz wget -q http://connie.slackware.com/~alien/slackbuilds/unrar/pkg/13.1/unrar-3.9.10-i486-2alien.tgz wget -q http://slackware.cs.utah.edu/pub/slackware/slackware-12.2/slackware/a/infozip-5.52-i486-2.tgz wget -q http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/n/openssl-0.9.8n-i486-1.txz wget -q http://repository.slacky.eu/slackware-13.1/system/pyopenssl/0.10/pyopenssl-0.10-i486-2sl.txz echo "-- Installing Perquisites --" installpkg /boot/packages/nano-2.2.4-i486-1.txz installpkg /boot/packages/python-2.6.4-i486-1.txz installpkg /boot/packages/python-cheetah-2.4.2.1-i486-1alien.tgz installpkg /boot/packages/python-yenc-0.3-i486-1alien.tgz installpkg /boot/packages/par2cmdline-0.4-tbb-20090203-lin32.tar.gz installpkg /boot/packages/sqlite-3.6.23.1-i486-1.txz installpkg /boot/packages/unrar-3.9.10-i486-2alien.tgz installpkg /boot/packages/infozip-5.52-i486-2.tgz installpkg /boot/packages/openssl-0.9.8n-i486-1.txz installpkg /boot/packages/pyopenssl-0.10-i486-2sl.txz echo echo echo "-- Prerequisites Installed --" sleep 5 cd /tmp echo "******* 2. Installing SABnzbd *******" logdirectory=/var/log/sabnzbd echo "-- Port where SABnzbd will be installed (must be higher than 1024), e.g. 8082 --" read sabport mkdir /mnt/$customvolume/.custom/sabnzbd echo "-- Extracting SABnzbd archive --" tar zxpf SABnzbd* -C /mnt/$customvolume/.custom/sabnzbd rm /tmp/SABnzbd*.tar.gz echo "-- Installing SABnzbd --" echo "[misc]" > /mnt/$customvolume/.custom/sabnzbd/sabnzbd.ini echo "log_dir = /var/log/sabnzbd" >> /mnt/$customvolume/.custom/sabnzbd/sabnzbd.ini echo "port = $sabport" >> /mnt/$customvolume/.custom/sabnzbd/sabnzbd.ini echo "host = $ip" >> /mnt/$customvolume/.custom/sabnzbd/sabnzbd.ini mkdir -p $logdirectory chown -R nobody:users $logdirectory usermod -s /bin/bash nobody > /dev/null 2>&1 su nobody -c "python SABnzbd.py -d -f /mnt/$customvolume/.custom/sabnzbd/sabnzbd.ini > /dev/null 2>&1" echo "-- Done - SABnzbd is started --" echo echo "******* 5. Creating /etc/rc.d/unraid.d File *******" mkdir /etc/rc.d/unraid.d #Creating rc.d entries for sabnzbd sabapikey=($(grep ^api_key /mnt/$customvolume/.custom/sabnzbd/sabnzbd.ini | awk '{print $3}')) echo "case \$1 in" > /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " start)" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " if test -e /etc/rc.d/unraid.d/rc.unraid_sabnzbd -a \$(ps auxwww|grep SABnzbd.py|grep -v grep|wc -l) -lt 1; then" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " if [ -d \"/mnt/$customvolume/.custom/sabnzbd\" ]; then" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " cd \"/mnt/$customvolume/.custom/sabnzbd/\"" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " LOG_DIR=\$(awk -F ' = ' '\$1 == \"log_dir\" {print \$2}' sabnzbd.ini)" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " mkdir -p \"\$LOG_DIR\"" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " chown -R nobody:users . \"\$LOG_DIR\"" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " usermod -s /bin/bash nobody > /dev/null 2>&1" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " su nobody -c \"python SABnzbd.py -d -f /mnt/$customvolume/.custom/sabnzbd/sabnzbd/sabnzbd.ini > /dev/null 2>&1\"" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " echo SABnzbd started." >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " else" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " echo SABnzbd could not be started because the installation directory, /mnt/$customvolume/.custom/sabnzbd/, could not be found." >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " echo If SABnzbd is installed on the unRAID array and the array is stopped, run "/etc/rc.d/unraid.d/rc.unraid_sabnzbd start" to start SABnzbd once the array is started." >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " fi" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " else" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " echo SABnzbd is already started." >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " fi" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " ;;" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " stop)" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " if test -e /etc/rc.d/unraid.d/rc.unraid_sabnzbd -a \$(ps auxwww|grep SABnzbd.py|grep -v grep|wc -l) -gt 0; then" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " wget -q "http://"$ip":"$sabport"/sabnzbd/shutdown?session="$sabapikey"" > /dev/null" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " sleep 10" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " kill \$(ps auxwww|grep SABnzbd.py|grep -v grep|awk '{ print \$2 }')" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " sleep 10" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " echo SABnzbd stopped." >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " else" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " echo SABnzbd is already stopped." >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " fi" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " ;;" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " version)" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " cd \"/mnt/$customvolume/.custom/sabnzbd\"" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " python SABnzbd.py --version | grep SABnzbd.py-" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo " ;;" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo "esac" >> /etc/rc.d/unraid.d/rc.unraid_sabnzbd chmod 755 /etc/rc.d/unraid.d/rc.unraid_sabnzbd echo "-- Created /etc/rc.d/unraid.d with entries for SABnzbd --" echo echo " ******* Script is complete *******" echo echo "Access your new services via the following addresses:" echo "SABnzbd --- http://$ip:$sabport" echo "SickBeard --- http://$ip:8081" echo "CouchPotato --- http://$ip:5000" echo echo #sickbearduser= #sickbeardpass= #couchpotatouser= #couchpotatopass= #echo "******* 3. Installing SickBeard *******" #mkdir /mnt/custom/extensions/sickbeard #echo "-- Downloading SickBeard --" #wget "http://github.com/midgetspy/Sick-Beard/tarball/master" #echo "-- Installing SickBeard --" #tar -xzf master #rm master #mv midgetspy* /mnt/custom/extensions/sickbeard #python /mnt/custom/extensions/sickbeard/midget*/SickBeard.py —-quiet & #echo "-- Done - SickBeard is started --" #echo #echo "******* 4. Installing CouchPotato *******" #mkdir /mnt/custom/extensions/couchpotato #echo "-- Downloading CouchPotato --" #wget http://github.com/RuudBurger/CouchPotato/tarball/master #echo "-- Installing CouchPotato --" #tar -xzf master #rm master #mv RuudBurger* /mnt/custom/extensions/couchpotato #python /mnt/custom/extensions/couchpotato/RuudBurger*/CouchPotato.py -d #echo "-- Done - CouchPotato is started --" #echo #echo "wget "http://"$ip":8081/home/shutdown/ «_EOF"" >> /mnt/custom/extensions/sickbeard/shutdown.sh #echo ""$sickbearduser"" >> /mnt/custom/extensions/sickbeard/shutdown.sh #echo ""$sickbeardpass"" >> /mnt/custom/extensions/sickbeard/shutdown.sh #echo "_EOF" >> /mnt/custom/extensions/sickbeard/shutdown.sh #echo "wget "http://"$ip":5000/config/exit/"«_EOF" >> /mnt/custom/extensions/couchpotato/shutdown.sh #echo ""$couchpotatouser"" >> /mnt/custom/extensions/couchpotato/shutdown.sh #echo ""$couchpotatopass"" >> /mnt/custom/extensions/couchpotato/shutdown.sh #echo "_EOF >/dev/null" >> /mnt/custom/extensions/couchpotato/shutdown.sh #echo "/mnt/custom/extensions/sickbeard/shutdown.sh" >> /mnt/$customvolume/shutdown.sh #echo "/mnt/custom/extensions/couchpotato/shutdown.sh" >> /mnt/$customvolume/shutdown.sh #chmod 0555 /mnt/$customvolume/shutdown.sh #chmod 0555 /mnt/custom/extensions/sickbeard/shutdown.sh #chmod 0555 /mnt/custom/extensions/couchpotato/shutdown.sh #echo "-- Shutdown Script Location: /mnt/$customvolume/shutdown.sh --" ~dpc
April 24, 201115 yr The recent version of unRAID 5.0beta6 has broken its built-in version of "wget", but just for some. It works here on both my servers. If it were to break here so I could see it not work, I'd fix it. Ah, I'd been wondering about that. It fails on my machine - is there anything I can do to assist with tracking the source of the problem? Or is the re-write using wget so imminent that fixing the awk version is irrelevant?
April 24, 201115 yr I like to create these scripts more for my simplicity sake and then share them out. Last one had 2400+ downloads (crazy number for me).... A sneak peek at the script im working on porting (a good chunk copying from sources here): Delicatepc learn how to use cat <<-EOF > /tmpscriptfile echo "test message" echo "test message" EOF It's so much cleaner to include embedded scripts and chunklets this way rather then the echo "test message" >> /tmp/scriptfile echo "test message" >> /tmp/scriptfile ...
April 24, 201115 yr Author Hi Weebo, EDIT: Was able to figure it. Excellent article here explaining how a backslash hides the important characters from the shell when sending them to another document. In short one \ for every special character. this is giving out good code: cat <<-EOF > /etc/rc.d/unraid.d/rc.unraid_sabnzbd case \$1 in start) if test -e /etc/rc.d/unraid.d/rc.unraid_sabnzbd -a \$(ps auxwww|grep SABnzbd.py|grep -v grep|wc -l) -lt 1; then if [ -d /mnt/disk1/.custom/SABnzbd* ]; then cd /mnt/disk1/.custom/SABnzbd* LOG_DIR=(\$(grep ^log_dir /mnt/disk1/.custom/SABnzbd*/sabnzbd.ini | awk '{print $3}')) echo \$LOG_DIR mkdir -p \$LOG_DIR chown -R nobody:users . \$LOG_DIR usermod -s /bin/bash nobody > /dev/null 2>&1 su nobody -c "python SABnzbd.py -d -f /mnt/disk1/.custom/SABnzbd*/sabnzbd.ini > /dev/null 2>&1" echo SABnzbd started. else echo SABnzbd could not be started because the installation directory, /mnt/disk1/.custom/SABnzbd*/, could not be found. echo If SABnzbd is installed on the unRAID array and the array is stopped, run /etc/rc.d/unraid.d/rc.unraid_sabnzbd start to start SABnzbd once the array is started. fi else echo SABnzbd is already started. fi ;; stop) if test -e /etc/rc.d/unraid.d/rc.unraid_sabnzbd -a \$(ps auxwww|grep SABnzbd.py|grep -v grep|wc -l) -gt 0; then wget -q http://10.0.0.203:8082/sabnzbd/shutdown?session=e521227aa1f344b055e73002631ca663 > /dev/null sleep 3 echo "SABnzbd stopped using API method (clean)." kill \$(ps auxwww|grep SABnzbd.py|grep -v grep|awk '{ print \$2 }') sleep 4 echo "SABnzbd stopped using KILL method (dirty)." else echo SABnzbd is already stopped. fi ;; version) cd /mnt/disk1/.custom/SABnzbd* python SABnzbd.py --version | grep SABnzbd.py- ;; esac EOF thanks ~dpc
April 24, 201115 yr Author One side question: I want to have two tiered stop command. First one uses a "clean" method to shutdown the application. If that fails it falls back to the kill command and kills the application "dirty" method. Is there way I can make this code attempt shutdown via the clean method below and only proceed to dirty kill if needed? stop) if test -e /etc/rc.d/unraid.d/rc.unraid_sabnzbd -a \$(ps auxwww|grep SABnzbd.py|grep -v grep|wc -l) -gt 0; then wget -q http://10.0.0.203:8082/sabnzbd/shutdown?session=e521227aa1f344b055e73002631ca663 > /dev/null sleep 3 echo "SABnzbd stopped using API method (clean)." kill \$(ps auxwww|grep SABnzbd.py|grep -v grep|awk '{ print \$2 }') sleep 4 echo "SABnzbd stopped using KILL method (dirty)." else echo SABnzbd is already stopped. fi ;; version) cd /mnt/disk1/.custom/SABnzbd* python SABnzbd.py --version | grep SABnzbd.py- ;; esac thanks, ~dpc
April 24, 201115 yr One side question: I want to have two tiered stop command. First one uses a "clean" method to shutdown the application. If that fails it falls back to the kill command and kills the application "dirty" method. Is there way I can make this code attempt shutdown via the clean method below and only proceed to dirty kill if needed? Yes, you can only issue the "kill" if the process still exists. I'd do something like sab_pid=$(ps auxwww|grep SABnzbd.py|grep -v grep|awk '{ print \$2 }') kill -0 $sab_pid && kill $sab_pid
Archived
This topic is now archived and is closed to further replies.