Joe L. Posted August 7, 2010 Author Share Posted August 7, 2010 You did not do too bad. I like how you concatenated the script and then wrote it in one line with "echo -e" Only issues I see are "curl" is not part of unRAID, "wget" is, perhaps you can adapt to use it with something like this: wget -O - -q checkip.dyndns.org | cut -d' ' -f6 | cut -d'<' -f1 (It also returns the IP address, exactly like yours) You'll need to change the "curl" line where you submit the new IP address, but it should be very similar to your existing line, just using "wget -O - -q ........" Next, an unRAID specific issue... Once you change the root crontab you'll also need to copy it to a file used by the unRAID web-interface, otherwise, if you make any changes via it, your entry will be erased. It does not do a crontab -l the next time it modifies cron, it uses the file it used the first time. The line you need to add (before the line where you remove /tmp/crontab) is: PACKAGE_INSTALLATION cp /tmp/crontab /var/spool/cron/crontabs/root- Note, the line ends with a trailing "-" Clearly, you learn quickly... The "package" file is very close to being ready for publishing. Obviously, I specifically made it easy to add packages, to encourage others like yourself to create new packages. As far as "hdparm -C" ... I'll modify the hourly status e-mail to use the trick we used in unmenu.awk. You'll still see messages for a cache drive or drives outside of the array, but it will minimize the extra messages written to the syslog. (but not this weekend, as I'm just about ready to go out for an evening of Ballroom Dancing with my wife. Can't be a complete geek, need some social skills too. ) You'll need to show me a bit more about the apcupsd.conf fixes. I'm very open to making it better. Perhaps you can show me the specific lines involved. Joe L. Quote Link to comment
gfjardim Posted August 7, 2010 Share Posted August 7, 2010 Are you sure about curl, Joe? Here I haven't install it, so it's included in 4.5.6, but since wget do the same, so I'll be changing it. I'll do the suggested modifications, and post it again. Quote Link to comment
Joe L. Posted August 7, 2010 Author Share Posted August 7, 2010 Are you sure about curl, Joe? Here I haven't install it, so it's included in 4.5.6, but since wget do the same, so I'll be changing it. I'll do the suggested modifications, and post it again. Pretty sure it is not included... on 4.5.6 or on 5.0-beta1. root@Tower:/boot# curl -bash: curl: command not found root@Tower:/boot# which curl which: no curl in (/usr/local/sbin:/usr/sbin:/sbin:./:/usr/local/bin:/usr/bin:/bin) Perhaps it was installed along with one of the packages you put into place. Again, thanks for the feedback and the work on the new package. I know it will be useful for many. Glad you were able to figure out the "package" format from the existing examples. Joe L. Quote Link to comment
spinbot Posted August 12, 2010 Share Posted August 12, 2010 Apparently in the past year I've let my unmenu go un-upgraded and it is now deemed "Ancient" The "wheel wasn't broke, do I didn't try to fix it". Now that I am both aware new versions exist and those versions will help clean up my syslog error as well as offer me new features ( and easier updating in the future ), I am going to complete the update. I have backed my entire flash drive up (which I do periodically anyways). The one item that I fought on, for some time, was getting my APC UPS working and to send me an email if the power went out or was restored. Will this be something I need to start over from scratch again or can I copy something over or are the files just left un-affected for this feature? Here's a screen shot of my packages folder, in case it helps any: Quote Link to comment
Joe L. Posted August 12, 2010 Author Share Posted August 12, 2010 You will find it relatively easy to get the new version of apcupsd installed and configured. It now has configurable fields for its setup. The package-manager now includes an e-mail / ssmtp package. You do not need to install it if you have an alternative you are using already. It too has fields to configure it. It is actually distributed in source-code form and one of the new packages is the compiler needed to compile it. Again, it is just a matter of clicking on the button to install the "gcc" compiler, and then clicking on the button to install the ssmtp and mail programs. (Had to do it that way, as no pre-compiled version is available that handles secure TLS mail transactions) This is much more complete e-mail program (not a shell script) and it will be used by "cron" and "at" to send status messages. What program/script are you currently using the send the mail? If currently using unraid_notify.sh and its affiliated mail program, it should work just fine. I'd set up the apcupsd package, and go from there. You'll want to edit the configurable variables (even if you do not change anything) then save the values. That will then enable a "Re-install with new values" button. Press it and the new version will be in place. The editable configuration fields will let you set the behavior as you would prefer. Joe L. Quote Link to comment
squirrellydw Posted August 12, 2010 Share Posted August 12, 2010 ds store cleanup config?? If I install the ds store cleanup script do I need to change any of the configuration? It looks like there are 6 options for the script but only 5 on the wiki or am I just confused and missing something? I would like it to run every Sunday at 3am once a week. Quote Link to comment
Joe L. Posted August 12, 2010 Author Share Posted August 12, 2010 ds store cleanup config?? If I install the ds store cleanup script do I need to change any of the configuration? It looks like there are 6 options for the script but only 5 on the wiki or am I just confused and missing something? I would like it to run every Sunday at 3am once a week. The wiki shows this: .---------------- minute (0 - 59) | .------------- hour (0 - 23) | | .---------- day of month (1 - 31) | | | .------- month (1 - 12) OR jan,feb,mar,apr ... | | | | .----- day of week (0 - 7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat | | | | | * * * * * command to be executed So, you want 0 3 * * 0 as your schedule That is 3 AM on every Sunday, on any day-of-month, in any month. What 6 options are you referring to on the "script" since as distributed it has 40 3 * * * That translates to 3:40 AM on any day, in any month, on any day of the week. That is still only 5 fields. Joe L. Quote Link to comment
squirrellydw Posted August 12, 2010 Share Posted August 12, 2010 ok I get it, thanks Joe. Quote Link to comment
spinbot Posted August 12, 2010 Share Posted August 12, 2010 What program/script are you currently using the send the mail? If currently using unraid_notify.sh and its affiliated mail program, it should work just fine. I followed your advice many months ago with these instructions: I've put my nc and mail.sh in a /boot/custom/bin folder. You can create it by typing: mkdir -p /boot/custom/bin Then, you can execute these 4 commands. They will create a file in your /boot/packages folder that will be invoked every time you re-start your server along with all the other packages you have elected to "Auto-Install on Re-Boot" echo "cp /boot/custom/bin/mail.sh /usr/bin/mail" >>/boot/packages/mail.auto_install echo "cp /boot/custom/bin/nc /usr/bin/nc" >>/boot/packages/mail.auto_install echo "chmod 755 /usr/bin/nc /usr/bin/mail" >>/boot/packages/mail.auto_install echo "echo '[email protected]' >/root/.forward" >>/boot/packages/mail.auto_install The last of those 4 lines must be edited to hold your e-mail address you want the alerts sent to. You will also need to edit the mail.sh file to include your mail service provider and any id/password it needs. Be aware though, it will not work if your e-mail provider needs an encrypted session. There is a different mail script that has been posted that will work for it. Once you have run the 4 lines above, you can then run the script it created by typing /boot/packages/mail.auto_install Am I going to have to do some cleaning up, after the upgrade, as some of the packages this process created will be gone and yet still be called upon? Just trying to figure out which is the easiest solution to complete the upgrade Quote Link to comment
Joe L. Posted August 12, 2010 Author Share Posted August 12, 2010 If your e-mail is working now, you do not need to undo anything. Leave those lines in your "go" script. Just do not install the "mail and ssmtp" package (identified as "ssmtp-2.6x") as it will just install an alternative e-mail program. Actually you can install it if you like, you'll just need to fill in the configure fields and remove those other lines from your go script. Joe L. Quote Link to comment
spinbot Posted August 13, 2010 Share Posted August 13, 2010 My notifications use to work, however i did a quick test and it appears it isn't working ( which makes me wonder if the shutdown part is working either ). Maybe a stupid question, but a few weeks ago I took the server with me for a weekend. When I hooked it back up, I cannot be sure what USB port the UPS was plugged into. Would that make a difference? Quote Link to comment
Joe L. Posted August 13, 2010 Author Share Posted August 13, 2010 It should not matter which USB port you used. Can you get a status report from the UPS? (On the system info page in unMENU there is a button for it) To test your e-mail, just type: echo "this is a test" | mail -s "Testing the mail" root Joe L. Quote Link to comment
spinbot Posted August 13, 2010 Share Posted August 13, 2010 Status Report works (forgot about that) APC : 001,021,0584 DATE : Thu Aug 12 21:31:17 EDT 2010 HOSTNAME : Tower RELEASE : 3.14.3 VERSION : 3.14.3 (20 January 2008) slackware UPSNAME : Tower CABLE : Custom Cable Smart MODEL : Back-UPS ES 550 UPSMODE : Stand Alone STARTTIME: Sat Aug 07 09:09:36 EDT 2010 STATUS : COMMLOST MBATTCHG : 5 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds LASTXFER : Low line voltage NUMXFERS : 2 XONBATT : Thu Aug 12 21:30:37 EDT 2010 TONBATT : 828 seconds CUMONBATT: 875 seconds XOFFBATT : Thu Aug 12 21:06:40 EDT 2010 STATFLAG : 0x07060110 Status Flag END APC : Thu Aug 12 21:44:25 EDT 2010 And as for the test message, the reply: root@Tower:/boot/unmenu# echo "this is a test" | mail -s "Testing the mail" root 220 ironport02.pppoe.ca ESMTP 250-ironport02.pppoe.ca 250-8BITMIME 250-SIZE 104857600 250 STARTTLS 250 sender <[email protected]> ok 250 recipient <[email protected]> ok 354 go ahead 250 ok: Message 72499298 accepted 221 ironport02.pppoe.ca root@Tower:/boot/unmenu# EDIT: I did check the spam folder at gmail, just in case it landed there. Quote Link to comment
Joe L. Posted August 13, 2010 Author Share Posted August 13, 2010 It does say: STATUS : COMMLOST so I don't think you're talking to the UPS. Quote Link to comment
spinbot Posted August 13, 2010 Share Posted August 13, 2010 For some reason, there was a delay of multiple hours with the email. I just got up and all the test I did came through about 3 or 4 hours after I did them. Not sure if you recall, but my computer has an issue with keeping the time correct, so it is constantly adjusting the time ( here's an example from the syslog ): Aug 13 06:45:14 Tower ntpd[1446]: time reset +1.679075 s Aug 13 06:46:15 Tower ntpd[1446]: synchronized to 208.69.56.110, stratum 2 Aug 13 06:51:14 Tower ntpd[1446]: synchronized to 209.114.111.1, stratum 2 Aug 13 06:53:40 Tower ntpd[1446]: synchronized to 149.20.68.17, stratum 2 Aug 13 07:01:58 Tower ntpd[1446]: time reset +1.698346 s Aug 13 07:02:18 Tower ntpd[1446]: synchronized to 208.69.56.110, stratum 2 Aug 13 07:06:28 Tower ntpd[1446]: synchronized to 149.20.68.17, stratum 2 Not sure if that has anything to do with it or not. I shutdown the server and re-started it and got this, when running the UPS Status: Error contacting host localhost port 3551: Connection refused I shut it down again and changed USB ports and it does now come up with status as ONLINE APC : 001,036,0900 DATE : Thu Aug 12 23:37:05 EDT 2010 HOSTNAME : Tower RELEASE : 3.14.3 VERSION : 3.14.3 (20 January 2008) slackware UPSNAME : Tower CABLE : Custom Cable Smart MODEL : Back-UPS ES 550 UPSMODE : Stand Alone STARTTIME: Thu Aug 12 23:37:03 EDT 2010 STATUS : ONLINE LINEV : 120.0 Volts LOADPCT : 28.0 Percent Load Capacity BCHARGE : 100.0 Percent TIMELEFT : 17.5 Minutes MBATTCHG : 5 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds SENSE : High LOTRANS : 092.0 Volts HITRANS : 139.0 Volts ALARMDEL : Always BATTV : 13.5 Volts LASTXFER : Low line voltage NUMXFERS : 0 TONBATT : 0 seconds CUMONBATT: 0 seconds XOFFBATT : N/A STATFLAG : 0x07000008 Status Flag MANDATE : 2008-08-04 SERIALNO : 3B1802X07111 BATTDATE : 2000-00-00 NOMINV : 115 Volts NOMBATTV : 12.0 Volts FIRMWARE : 843.K1 .D USB FW:K1 APCMODEL : Back-UPS ES 550 END APC : Thu Aug 12 23:38:02 EDT 2010 I tested out that test command you gave me, however I got the same result as before ( nothing came through email ). I pulled the power from the wall and the UPS did at least execute the shutdown command when it hit 3 minutes remaining. In the past, i got an email when power went out and when it was restored. I don't think I ever tested to see if after the UPS shutdown the server, as it would have hit the 3 minute minimum remaining time, if when power was restored to the UPS, should the server start up on its own. I did try this test just now and the server remained off. syslog-2010-08-13.txt Quote Link to comment
squirrellydw Posted August 13, 2010 Share Posted August 13, 2010 1. How do I make unmenu start when I start unraid? I know I have to add something to my go script but not sure what or where? Quote Link to comment
chanders Posted August 13, 2010 Share Posted August 13, 2010 To start the UnMENU server each time you reboot, add /boot/unmenu/uu near the bottom of your go script from http://www.lime-technology.com/wiki/index.php?title=UnRAID_Add_Ons#UnMENU Quote Link to comment
c234rmf Posted August 14, 2010 Share Posted August 14, 2010 what is the trick to make uumenu automaticaly run the package again at reboot? I have selected the ups package for automatic re run but it does not work. thanks (yes my unmenu restarts automaticaly at reboot) Quote Link to comment
Joe L. Posted August 14, 2010 Author Share Posted August 14, 2010 what is the trick to make uumenu automaticaly run the package again at reboot? I have selected the ups package for automatic re run but it does not work. thanks (yes my unmenu restarts automaticaly at reboot) When you select your very first unmenu package to be re-installed on re-boot it will add a line to the bottom of your config/go script. That line will look like this: cd /boot/packages && find . -name '*.auto_install' -type f -print | sort | xargs -n1 sh -c Make sure it is on a line by itself and that you did not clobber it when you added your line to start unmenu. Joe L. Quote Link to comment
gfjardim Posted August 14, 2010 Share Posted August 14, 2010 I don't think I ever tested to see if after the UPS shutdown the server, as it would have hit the 3 minute minimum remaining time, if when power was restored to the UPS, should the server start up on its own. I did try this test just now and the server remained off. I had this problem too, and in my case the apc daemon doesn't create a necessary flag file, in /etc/apcupsd/powerfail. When the killpower command is invoked, the deamon verify the existence of this file as a safety measure, and if it doesn't exist the command is aborted. Solved this with this line: PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/ \/sbin\/poweroff/ echo \"1\">\/etc\/apcupsd\/powerfail; \/etc\/apcupsd\/apccontrol killpower;\/sbin\/poweroff/" /etc/rc.d/rc.6 The original one replaced was: PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/ \/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower;\/sbin\/poweroff/" /etc/rc.d/rc.6 It enforces the rc.6 runtime script to create the flag file before invoking the killpower command. Quote Link to comment
Joe L. Posted August 14, 2010 Author Share Posted August 14, 2010 I don't think I ever tested to see if after the UPS shutdown the server, as it would have hit the 3 minute minimum remaining time, if when power was restored to the UPS, should the server start up on its own. I did try this test just now and the server remained off. I had this problem too, and in my case the apc daemon doesn't create a necessary flag file, in /etc/apcupsd/powerfail. When the killpower command is invoked, the deamon verify the existence of this file as a safety measure, and if it doesn't exist the command is aborted. Solved this with this line: PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/ \/sbin\/poweroff/ echo \"1\">\/etc\/apcupsd\/powerfail; \/etc\/apcupsd\/apccontrol killpower;\/sbin\/poweroff/" /etc/rc.d/rc.6 The original one replaced was: PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/ \/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower;\/sbin\/poweroff/" /etc/rc.d/rc.6 It enforces the rc.6 runtime script to create the flag file before invoking the killpower command. I'll verify your results and add your improved line... (It really cannot hurt anything as we are powering down and it will be gone shortly anyways) Many thanks, from myself and everybody else who uses this package. I can't say I've ever noticed it. My server does re-start itself, and my UPS does shut itself down. Which version of apcupsd are you using? Joe L. Quote Link to comment
spinbot Posted August 15, 2010 Share Posted August 15, 2010 I'm think I am using 3.14.3, as when I check the package manager is shows "Currently Installed. Will be automatically Re-Installed upon Re-Boot." , however the 3.14.8 also gives a message that it is "Installed, Not Downloaded" I'm using the UnMenu script editor and I have two similar files listed: /boot/packages/apcupsd-unmenu-package.conf PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6 /boot/packages/apcupsd3-unmenu-package.conf PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6 I am assuming one of these is the files I need to edit, however how do I know which one .....or does it matter... just edit both with: PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/ \/sbin\/poweroff/ echo \"1\">\/etc\/apcupsd\/powerfail; \/etc\/apcupsd\/apccontrol killpower;\/sbin\/poweroff/" /etc/rc.d/rc.6 Quote Link to comment
Joe L. Posted August 15, 2010 Author Share Posted August 15, 2010 I'm think I am using 3.14.3, as when I check the package manager is shows "Currently Installed. Will be automatically Re-Installed upon Re-Boot." , however the 3.14.8 also gives a message that it is "Installed, Not Downloaded" I'm using the UnMenu script editor and I have two similar files listed: /boot/packages/apcupsd-unmenu-package.conf PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6 /boot/packages/apcupsd3-unmenu-package.conf PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6 I am assuming one of these is the files I need to edit, however how do I know which one .....or does it matter... just edit both with: PACKAGE_INSTALLATION [ "${vUPS_KILL-YES}" != "NO" ] && sed -i -e "s/ \/sbin\/poweroff/ echo \"1\">\/etc\/apcupsd\/powerfail; \/etc\/apcupsd\/apccontrol killpower;\/sbin\/poweroff/" /etc/rc.d/rc.6 Also add a line #AUTO_UPDATE = NO somewhere in the file you edit. That way it will not be swapped out when you run the update script to check for unMENU updates. Quote Link to comment
gfjardim Posted August 15, 2010 Share Posted August 15, 2010 I'm using the 3.14.18, edited the apcupsd3-unmenu-package.conf file. Quote Link to comment
c234rmf Posted August 16, 2010 Share Posted August 16, 2010 When you select your very first unmenu package to be re-installed on re-boot it will add a line to the bottom of your config/go script. That line will look like this: cd /boot/packages && find . -name '*.auto_install' -type f -print | sort | xargs -n1 sh -c Make sure it is on a line by itself and that you did not clobber it when you added your line to start unmenu. Joe L. Thanks - i never saw that in my go file. I have added it. Based upon the fact that it should be "at the bottom" I assume it should come after the invocation of unmenu? I use cd /boot/unmenu ./uu thanks Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.