July 27, 200817 yr Great, thanks for the quick reply. I do have one last question. Can someone either point to their shutdown script if it's already been posted (that shuts down cleanly) or post one if it's not been posted? I'm not good with linux scripts. Thanks again ... gotta love the product and the community!
July 27, 200817 yr I believe this is the latest revision of powerdown: http://lime-technology.com/wiki/index.php?title=Powerdown_script
August 3, 200817 yr My email notifications don't seem to be working. For the install, I: Updated apcupsd.config Updated apccontrol to ponit to the new powerdown script Changed SYSADMIN from root to my email address in the email script files (changeme, commfailure, commok, onbattery, and offbattery) Installed nc and the mail script Modified rc.6 to include the killpower directive for the UPS If I run one of the email script files like changeme, it works and I receive the email. But when simulate a power failure by unplugging the UPS from the wall, I don't receive any emails. Overall, apcupsd works, the powerdown script is invoked, and the machines shuts down gracefully, but it seems like apccontrol is not calling the email scripts. Did I miss a configuration option?
August 21, 200817 yr Ok guys, I'm a linux n00b. I can't seem to figure out how to install this and get it working. Please bear with me. This is what I have figured out thus far. I downloaded apcupsd-3.14.3-i486-1kjz.tgz and through a windows machine created a folder on the flash drive called apcupsd and put the file in there. I downloaded PuTTY and connected to the server. This is where I am stuck I tried typing installpkg apcupsd-3.14.3-i486-1kjz.tgz and it says package does not end in .tgz. I figured (from windows experience) that I would have to navigate to the flash drive, but when I type in dir I get samba and mdcmd. Is there any place to find some instructions on step by step installing packages onto unraid or what am I doing wrong? I'm assuming that I put the file in the wrong place. The folder I created is right beside the config folder on the flash drive. Thanks.
August 21, 200817 yr you would type installpkg /boot/(folder you put the tgz file in)/thenameofthe.tgz So judging from your message the command would be installpkg /boot/apcupsd/apcupsd-3.14.3-i486-1kjz.tgz >> I'm assuming that I put the file in the wrong place. The folder I created is right beside the config folder on the flash drive. We recommend something such as /boot/custom/usr/share/packages To alleviate complicating things you could just use what you have right now.
August 21, 200817 yr Ok guys, I'm a linux n00b. I can't seem to figure out how to install this and get it working. Please bear with me. This is what I have figured out thus far. I downloaded apcupsd-3.14.3-i486-1kjz.tgz and through a windows machine created a folder on the flash drive called apcupsd and put the file in there. I downloaded PuTTY and connected to the server. This is where I am stuck I tried typing installpkg apcupsd-3.14.3-i486-1kjz.tgz and it says package does not end in .tgz. I figured (from windows experience) that I would have to navigate to the flash drive, but when I type in dir I get samba and mdcmd. Is there any place to find some instructions on step by step installing packages onto unraid or what am I doing wrong? I'm assuming that I put the file in the wrong place. The folder I created is right beside the config folder on the flash drive. Thanks. You are doing fine. The flash drive is at "/boot" on the unraid server. If you created a folder there named apcupsd, it will be at /boot/apcupsd You can "cd" there by typing cd /boot/apcupsd Most of us are adopting a folder structure that has /boot/packages We can put all the installable packages in that folder. The "dir" equivalent in Linux is "ls" although as you discovered, the "dir" command alias was created for newbies like yourself. To get a long listing, use "ls -l" To rename a folder, or a file, linux uses the "mv" command. So to rename the apcupsd folder you created you can type mv /boot/apcupsd /boot/packages or cd /boot mv apcupsd packages Then, you can type installpkg /boot/packages/apcupsd-3.14.3-i486-1kjz.tgz or cd /boot/packages installpkg apcupsd-3.14.3-i486-1kjz.tgz You still need to configue it, so you are not done, but getting there. Since these steps need to be performed every time you reboot your server, it is easier to create a script to do it for you. I created a shell script file named "S120-apcupsd-package-install" It is invoked by a line added to the /boot/config/go script. It is a text file with this as contents: [pre]#! /bin/bash # Install APC UPS driver module cd /boot/packages installpkg apcupsd-3.14.3-i486-1kjz.tgz sed -i -e "s/^DEVICE \/dev\/ttyS0/#DEVICE \/dev\/ttyS0/" /etc/apcupsd/apcupsd.conf sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol /sbin/apcupsd #Now, put into place the shutdown script replacement echo "/sbin/powerdown" >/etc/apcupsd/doshutdown echo "exit 99" >>/etc/apcupsd/doshutdown chmod 755 /etc/apcupsd/doshutdown sed -i -e "/\/sbin\/poweroff/i[ -f \/etc\/apcupsd\/powerfail ] \&\& \/etc\/apcupsd\/apccontrol killpower" /etc/rc.d/rc.6 [/pre] To work properly, the "powerdown" script needs to be installed to perform a clean shutdown of the unRAID array. If you have been following some of the other threads in this forum, you will know some of this is evolving, and we are working towards the best place for the scripts to properly shut down the unRAID array on any event. (power fail, "ctl-Alt-Delete", or power button.) Let us know how you do. Once you log in via putty, type "mc" to invoke midnight commander... a combined file browser and editor. It will make it easier for you to edit the files needed. You can even use the "mouse" to move the cursor. Joe L.
August 22, 200817 yr Thanks guys! You gave me a good start. One more question, in order to configure the settings for the apcupsd file do I need to edit a file inside the tgz? I ran installpkg and it told me it was executing the install script but I don't see any addition files created on the flash drive. For adding the script to the go script, if I create that in notepad, what should I use as the extension. Or will notepad even be able to create that? Edit: Err can't even figure out how to edit the go file. (Previous questions still stand) I think I might be getting a bit over my head with this. I might just wait for this to be implemented or an easier way of doing this. If I reboot the server the install I just did gets erased correct?
August 22, 200817 yr Thanks guys! You gave me a good start. One more question, in order to configure the settings for the apcupsd file do I need to edit a file inside the tgz? I ran installpkg and it told me it was executing the install script but I don't see any addition files created on the flash drive. You are correct, it does not add any files to the flash drive. The files are added to the in-memory file system. Take a look at the /etc/apcupsd folder. Plenty of files added there. You do not need to edit any files in the .tgz You do need to edit some, or create a script that edits some once they are in place in /etc/apcupsd. For adding the script to the go script, if I create that in notepad, what should I use as the extension. Or will notepad even be able to create that? Edit: Err can't even figure out how to edit the go file. (Previous questions still stand) Use the editor built into midnight commander. invoke midnight-commander by typing mc at the linux command prompt after logging in via putty. "extensions" is a ms-dos concept. In unix/linux there are a few conventions, but there is no need for any specific extension on a shell script, or any program for that matter. So, no extension is needed. I think I might be getting a bit over my head with this. I might just wait for this to be implemented or an easier way of doing this. If I reboot the server the install I just did gets erased correct? Yes, the files installed in the in-memory file system are all gone when you reboot. Those added to the flash drive still remain.
September 28, 200817 yr Which APC models work with this? If they run the PowerChute software and have a USB port will they work? Like this model: http://www.staples.com/office/supplies/p16_UPS-Backup-Systems_156772_Business_Supplies_10051_true_SEARCH It's on sale and I can get it for $99, but only tonight. Will it work with these scripts?
September 28, 200817 yr Which APC models work with this? If they run the PowerChute software and have a USB port will they work? Like this model: http://www.staples.com/office/supplies/p16_UPS-Backup-Systems_156772_Business_Supplies_10051_true_SEARCH It's on sale and I can get it for $99, but only tonight. Will it work with these scripts? I can't guarantee it, but I really think it would work. I'm using a relatively cheap BackUPS-350 or something like that and it works. I think if it's APC and has USB, you're probably safe.
September 28, 200817 yr Thanks musicmann. That's what I was thinking. The deal was about to expire, so I went ahead and ordered it so I guess I'll find out.
September 28, 200817 yr Hi, This was all working great for me (for a while). Using unMenu I was able to see all of the correct status information after installing a new UPS. This worked great for a few days. Yesterday, I checked status and nothing. I look in my syslog and see these two red lines -- Sep 28 10:07:31 Tower apcupsd[4830]: apcupsd FATAL ERROR in linux-usb.c at line 609 Cannot find UPS device -- For a link to detailed USB trouble shooting information, please see . Sep 28 10:07:31 Tower apcupsd[4830]: apcupsd error shutdown completed The only thing I have changed recently was to add these commands to my go script in support of unmenu sys info page 31 -- installpkg /boot/custom/usr/share/packages/pciutils-2.2.10-i486-1.tgz installpkg /boot/custom/usr/share/packages/lsof-4.78-i486-1.tgz Has anybody had this problem or have a suggestion? It's funny, I've run without the UPS for so long without stressing over the risks, but now that I've had one for a few weeks, I can't stand to not have it protecting my system. Attached is my syslog in case it helps -- thanks!
September 28, 200817 yr The error seems to have occurred soon after you added your swap partition and apparently did an "init-q" to re-read the inittab file. I'm guessing the USB controller was not yet initialized, or got confused by the reboot. It looks like the apc power daemon was unable to find the UPS, so it gave up. I'd say, try a reboot from the management console, and perhaps add a sleep after you add the swap space. Joe L.
October 2, 200817 yr Sorry to keep asking so many questions, but I don't know anything Linux. I was following Joe L.'s post on page 3 about installing the package, invoking apcupsd, and checking the status, but something isn't right and this is what I get: Linux 2.6.24.4-unRAID. root@Tower1:~# cd /boot/packages root@Tower1:/boot/packages# ls apcupsd-3.14.3-i486-1kjz.tgz* root@Tower1:/boot/packages# installpkg apcupsd-3.14.3-i486-1kjz.tgz Installing package apcupsd-3.14.3-i486-1kjz... PACKAGE DESCRIPTION: apcupsd: apcupsd - A daemon for controlling APC UPS devices apcupsd: apcupsd: Apcupsd can be used for power management and controlling most of apcupsd: APC's UPS models on Unix and Windows machines. Apcupsd works with apcupsd: most of APC's Smart-UPS models as well as most simple signalling apcupsd: models such as Back-UPS and BackUPS-Office. apcupsd: apcupsd: Requires: gd, libjpeg, libpng, ncurses apcupsd: Homepage: http://www.apcupsd.org/ apcupsd: apcupsd: Packaged by Ken Zalewski ([email protected]) Executing install script for apcupsd-3.14.3-i486-1kjz... root@Tower1:/boot/packages# cd root@Tower1:~# /sbin/apcupsd root@Tower1:~# ps -ef | grep apcups root 2482 2332 0 21:24 pts/0 00:00:00 grep apcups root@Tower1:~# apcaccess status Error contacting host localhost port 3551: Connection refused root@Tower1:~# Installing the package seemed to go fine, but I'm not sure if the resulting output from invoking apcupsd is normal or not and obviously checking the status failed. Why? Before listing the above steps in his post, Joe L. mentions commenting out #DEVICE /dev/ttyS0 in apcupsd.conf. I didn't understand why he was saying to do that.
October 2, 200817 yr Installing the package seemed to go fine, but I'm not sure if the resulting output from invoking apcupsd is normal or not and obviously checking the status failed. Why? Before listing the above steps in his post, Joe L. mentions commenting out #DEVICE /dev/ttyS0 in apcupsd.conf. I didn't understand why he was saying to do that. Installing the package DOES NOT configure it for your hardware. Specifically, the default hardware configuration it is supplied with assumes the cable to the UPS is connected to the serial port of the server. (all older APC UPS's are serial devices, not USB) If you have a USB cord between your UPS and your unRAID server, the default configuration file in the installed package will not work. Below is the contents of the script I run every time my server is rebooted. My script assumes that the "powerdown" command has been installed, and adds a file to the default apcupsd configuration that will invoke it to cleanly shut the server down. If that is not done, apcupsd will simply call the normal poweroff command and not cleanly shut down the unraid server. (not a good thing) So, you see there are 7 steps to getting this to work. 1. Install the powerdown command. (required for clean shutdown of unRAID on extended power failures) 2. Install a "mail" command, so you can get alerted when power fails. (optional) 3. installpkg the apcupsd package. (required) 4. configure the apcupsd package to use the USB connection (required) 5. configure the apcupsd package to send mail rather than write to all the attached terminals when something happens. (optional) 6. start the apcupsd daemon program running (required) 7. configure the apcupsd program to use the powerdown command (required) [pre] #! /bin/bash # Install APC UPS driver module cd /boot/packages installpkg apcupsd-3.14.3-i486-1kjz.tgz sed -i -e "s/^DEVICE \/dev\/ttyS0/#DEVICE \/dev\/ttyS0/" /etc/apcupsd/apcupsd.conf sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol /sbin/apcupsd #Now, put into place the shutdown script replacement echo "/sbin/powerdown" >/etc/apcupsd/doshutdown echo "exit 99" >>/etc/apcupsd/doshutdown chmod 755 /etc/apcupsd/doshutdown [/pre]
October 2, 200817 yr OK, I just tried your script and when I run it I see the apc package install, but when I run apcaccess status, I get the same error.
October 2, 200817 yr Instead of sed commands, wouldn't it be easier, to create your customized config file for apcuspd, save it to the flash, and copy it to /etc/apcupsd/apcupsd.conf on each boot before launching /sbin/apcupsd? Sometimes, if your favorite tool is a hammer, everything looks like a nail
October 2, 200817 yr RockDawg, Did you edit /etc/apcupsd/apcupsd.conf to comment out that referenced line before running /sbin/apcupsd? There are some also configurations like cable type and the various time variables that can be changed in this file, as well. Like BubbaQ suggests, you can copy the edited config file to the flash and set up your go script to overwrite the standard file with the edited one each reboot.
October 2, 200817 yr Instead of sed commands, wouldn't it be easier, to create your customized config file for apcuspd, save it to the flash, and copy it to /etc/apcupsd/apcupsd.conf on each boot before launching /sbin/apcupsd? Sometimes, if your favorite tool is a hammer, everything looks like a nail 6 of one, half dozen of another... if I had to change anything much more, I would have done as you said. The two lines of "sed" were easy, you should see some complicated "sed" scripts... did you know it had labels and "goto" If you ever get a chance, look at the bdiff command on an some versions of linux... nothing but a huge "sed" script. Or, if you have really strong stomach, check out this slightly more complicated "sed" script: http://www.npcguild.org/~ksb/hack/math.sed By comparison, I'm quite sane. Joe L.
October 2, 200817 yr RockDawg, Did you edit /etc/apcupsd/apcupsd.conf to comment out that referenced line before running /sbin/apcupsd? There are some also configurations like cable type and the various time variables that can be changed in this file, as well. Like BubbaQ suggests, you can copy the edited config file to the flash and set up your go script to overwrite the standard file with the edited one each reboot. I thought the # was what commented it out. That line in my file already had the pound symbol in front of it.
October 2, 200817 yr RockDawg, Did you edit /etc/apcupsd/apcupsd.conf to comment out that referenced line before running /sbin/apcupsd? There are some also configurations like cable type and the various time variables that can be changed in this file, as well. Like BubbaQ suggests, you can copy the edited config file to the flash and set up your go script to overwrite the standard file with the edited one each reboot. I thought the # was what commented it out. That line in my file already had the pound symbol in front of it. Mine was not commented out. Where did you get your apcupsd package file from? Mine looks like this (you can tell I downloaded it last July 3rd) -rwxr-xr-x 1 root root 2603927 Jul 3 12:58 apcupsd-3.14.3-i486-1kjz.tgz*
October 2, 200817 yr I downloaded it from the link in planetscott's post in this thread. It's here: http://www.linuxpackages.net/pkg_details.php?id=12025 Mine looks like this: -rwxr-xr-x 1 root root 2603927 Oct 1 16:49 apcupsd-3.14.3-i486-1kjz.tgz*
October 2, 200817 yr My version seems like it's set to default to USB. I notice there's a setting for cable type and it defaults to SMART. Not sure which mine is. It's a USB on one end and an RJ-45 on the other. I'd try setting it to USb, but I'm not sure how to set the script to copy the edited file over. Also, I'm not sure how some of the other lines in my current script (copied from Joe L.'s) might affect it.
Archived
This topic is now archived and is closed to further replies.