Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

UPS support yet?

Featured Replies

Also, how do you specify more than one e-mail addressee in the mail.sh file?

 

 

  • Replies 239
  • Views 82.7k
  • Created
  • Last Reply

Also, how do you specify more than one e-mail addressee in the mail.sh file?

 

 

I never tried it, but I would try pitting them together separated only by a single comma.

 

The mail.sh command I wrote does not have the addressee in it at all.  It is in a ".forward" file you need to put into place under /root

 

I'd try

[email protected],[email protected]

 

See if it works...  It might, it might not... depends on your e-mail service provider.    It was never written for more than one addressee.

 

Joe L.

Sorry if seems like a simple question, but how does one make a .forward file?

 

My gut says "use notepad" and drag and drop it.

 

The file would just contain one entry and that is my email address I want it to send to?

 

EDIT: Well, I tried that, but you can create a file called .forward ( as windows thinks its an extension and want a filename to go before it ).

 

I feel like those annoying clients I have calling my work that don't know what a monitor is or what their modem is  :)

Sorry if seems like a simple question, but how does one make a .forward file?

 

My gut says "use notepad" and drag and drop it.

 

The file would just contain one entry and that is my email address I want it to send to?

 

EDIT: Well, I tried that, but you can create a file called .forward ( as windows thinks its an extension and want a filename to go before it ).

 

I feel like those annoying clients I have calling my work that don't know what a monitor is or what their modem is  :)

The monitor is that big thing they are staring at for hours...  :)

 

Try

echo "[email protected]" >/root/.forward

You'll need to do that every time you reboot, so you'll want to add it to your "go" script.

If followed the above directions, but I must have got something wrong.  To recap, I have done:

 

One note, my email provider I don't use normally, however the one I've configured for sending from doesn't require anything special ( it doesn't require authentication or secure password authentication ).  The only restriction is you cannot relay using it from another ISP, however at this time, I am connected to the Internet through them, so that is a none issue also)

 

1.  I've put my nc and mail.sh in a /boot/custom/bin

 

2.  I've executed these 4 commands:

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

 

3. I've edited the mail.sh as follows:

# Define the following three values to setup this script

 

# The name of your SMTP server

sSmtpServer="smtp.teksavvy.com"

 

# Your domain name

sDomain="www.teksavvy.com"

 

# The "from" email address

sMailFrom="[email protected]"

 

addressee=""

subject="Message from unRAID server"

 

PATH=$PATH:/boot/custom/bin:/boot

 

(there is more to the mail.sh, but I didn't touch anything below this line, so I didn't post it)

 

 

4.  I've executed this command:

/boot/packages/mail.auto_install

 

5.  I've created the .forward

echo "[email protected]" >/root/.forward

 

6.  I've added the .forward command to my go script (using the editor in unmenu)

 

#!/bin/bash

# Start the Management Utility

/usr/local/sbin/emhttp &

cd /boot/packages && find . -name '*.auto_install' -type f -print | sort | xargs -n1 sh -c

 

# This is used to send email notifications to me

echo "[email protected]" >/root/.forward

 

# This will auto-load unmenu

/boot/unmenu/uu

 

 

7.  I've rebooted my server

 

8.  I've yanked the USB cable a few times and I've pulled the UPS power cord from the wall.    My syslog confirms the server is communicating with the UPS

Ex.: 

Oct 12 07:49:27 Tower apcupsd[1433]: Power failure.

Oct 12 07:49:33 Tower apcupsd[1433]: Running on UPS batteries.

Oct 12 07:50:13 Tower apcupsd[1433]: Mains returned. No longer on UPS batteries.

Oct 12 07:50:13 Tower apcupsd[1433]: Power is back. UPS running on mains.

 

 

Can anyone tell what I've either missed or done wrong?

 

Side question:  I added unmenu to my go script (as per the line in it above), however there is something not exactly right with it as I get messages on my console (even thought I am not logged in at it ) as well as everytime I access something in unmenu, the syslog puts the same line (as appears on the console) of:

Oct 12 08:14:48 Tower unmenu[1582]: ls: cannot access /boot/custom/etc/rc.d/*: No such file or directory

 

Thanks!

 

EDIT: Syslog attached

The last line about /boot/custom/bin/rc.d/ has to do with the  Third Party Boot Flash Plugin Architecture.  Take a look at the page there and you will see a lot of information.  I and a lot of other older members use this structure for adding custom stuff to our unRAID server.

 

I have all of 2-3 lines in my go script and that gets everything I have installed up and running.  Do some searching on the forum and you will find some scripts that help with the Third Party Boot Flash Plugin Architecture.

I see the page you are talking about:

http://lime-technology.com/wiki/index.php?title=Third_Party_Boot_Flash_Plugin_Architecture

 

I understand the need for a common file/folder structure so all the guys that create applications that depend on other applications know were to find them.

 

I think my server is just trying to list the contents in this folder:

/boot/custom/etc/rc.d/*

 

The only folder I presently have under "custom" is "bin" ( as that was the suggested one to use to put "mail.sh" and "nc" into )

 

Being new to linux , I try to follow any suggested directions to the letter , so I am not sure where I've gone wrong ( none of the applications I have installed have asked me to create and put files into the /boot/custom/etc/rc.d/  folder.

 

I suspect my problem causing this is the line I put in to launch unmenu  ( as i didn't follow any wiki , I just figured the line I put in the go script would be the same line I type in when I am sitting at the tower prompt ).   

 

All this being said, I still don't know what is wrong  :)    .... unmenu does load , its my email notification system that isn't working.

 

 

When I get home and to my server I will post the entire contents of my /boot/custom folder and my go script so that you can look through it.  It might be a little overwhelming at first but I think you will get the drift of what it is trying to accomplish.

 

Sorry, I can't help with the UPS mailing thing, I have u-notify setup on my machine and it gives me a status of my array but nothing more.  Having messages sent for UPS activation would be nice I guess but I know it works correctly when the power goes out so that is really all I care about.

I see the page you are talking about:

http://lime-technology.com/wiki/index.php?title=Third_Party_Boot_Flash_Plugin_Architecture

 

I understand the need for a common file/folder structure so all the guys that create applications that depend on other applications know were to find them.

 

I think my server is just trying to list the contents in this folder:

/boot/custom/etc/rc.d/*

 

The only folder I presently have under "custom" is "bin" ( as that was the suggested one to use to put "mail.sh" and "nc" into )

 

Being new to linux , I try to follow any suggested directions to the letter , so I am not sure where I've gone wrong ( none of the applications I have installed have asked me to create and put files into the /boot/custom/etc/rc.d/  folder.

 

I suspect my problem causing this is the line I put in to launch unmenu  ( as i didn't follow any wiki , I just figured the line I put in the go script would be the same line I type in when I am sitting at the tower prompt ).   

 

All this being said, I still don't know what is wrong  :)    .... unmenu does load , its my email notification system that isn't working.

 

 

You can ignore the warning message about the missing directory... it is logged to the syslog, and sent to the standard error output, which at the time unMENU is being started is sent to the system console.

 

Before you can go much further in figuring out what is happening with the mail, you need to know first what to expect it to send (and when), and second, you need to confirm your e-mail is set up for any message to get off the server.

 

To test that, you can simply cut and paste this line at a command prompt.

echo "This message is being sent from my unRAID server" | mail -s "Testing the shell mail program" root

 

When I do this, I get:

root@Tower:/boot/custom/bin# echo "This message is being sent from my unRAID server" | mail -s "Testing the shell mail program" root

220 somewhere.mail.rr.com ESMTP Welcome to Road Runner.  WARNING: *** FOR AUTHORIZED USE ONLY! ***

250-somewhere.mail.rr.com

250-HELP

250-VRFY

250-XREMOTEQUEUE

250-ETRN

250-PIPELINING

250-DSN

250-8BITMIME

250 SIZE 30996480

250 Sender <[email protected]> Ok

250 Recipient <[email protected]> Ok

354 Ok Send data ending with <CRLF>.<CRLF>

250 Message received: [email protected]

221 somewhere.mail.rr.com ESMTP server closing connection

 

On my gmail account, I get the message as sent.  (My personal e-mail ID has been edited out of the above transcript)

 

If I did not have ".forward" file in place with my correct e-mail, it would have resulted in the mail being sent to "root" at my e-mail provider, who would probably ignore it as junk mail.  (The line in the transcript would have shown "Recipient <root>" instead of "Recpient <[email protected]>")

 

Assuming that works, then the real issue is the messages are not being sent by apcupsd.

 

Looking at the package file for unmenu, I think I can see why.

 

This line in the the apcupsd-unmenu-package.conf file (in your /boot/packages folder)

PACKAGE_INSTALLATION sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol

needs to be changed to

PACKAGE_INSTALLATION sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert' root\"/" /etc/apcupsd/apccontrol

Notice I added a "space" followed by the addressee "root" just before the "\"/" near the end of the line.   

Without an addressee, the apc control program would invoke mail without any recipient.  This is not valid, although at least one mail script did accept a missing recipient and send mail to the root user. (It was not the script I wrote, and did not follow any unix standard working that way, but regardless... it was what misled people to think it was working properly)

 

Since you already have the .auto_install file in place, you can fix the individual files, or just fix the apcupsd-unmenu-package.conf file (or install the new one attached to ths post), then remove the apcupsd-3.14.3-i486-1kjz.tgz.auto_install and apcupsd-3.14.3-i486-1kjz.tgz.manual_install files, and then use the package manager to re-install both.

 

With the new .auto_install (or .manual_install) file in place, the /etc/apcupsd/apccontrol file will be properly edited to have a recipient for the mail command.  

(I'm actually editing a line usually intended for the "wall" (write to all logged in on the server) command.  since we have no logged in users, it was of little use the way it was supplied)

 

You can test this, without un-plugging the server UPS, by simulating a message to apccontrol.  To do this type:

/etc/apcupsd/apccontrol commok

 

A test e-mail message (actually two messages) will be sent stating that communications with the UPS have resumed.

 

Thank you for helping me find the omission in the unMENU apcupsd .conf file.   An updated .conf file is attached to this post.  With luck, as long as your e-mail is configured, it will get things working.   (All I can assume is most people are happy to have the UPS functional and did not miss the e-mail.  I know that in my case, when I lose power I never expected to see any mail because my cable modem looses power and I have no internet connectivity anyway.)

 

Joe L.

I'm going to tackle this one piece/error at a time.

 

 

I ran the email test and got this back:

 

root@Tower:~# echo "This message is being sent from my unRAID server" | mail -s "Testing the shell mail program" root

: command not found 2:

: command not found 5:

: command not found 8:

: command not found 11:

: command not found 14:

'usr/bin/mail: line 30: syntax error near unexpected token `in

'usr/bin/mail: line 30: `       case "$1" in

 

The part that stands out as a possible error is that an earlier instruction told me to put mail.sh and nc into this folder:

\\Tower\flash\custom\bin

 

It looks like something is looking for "mail" in usr/bin/ folder.

 

===================================================

Problem 2:  I'm not sure what start this, but I've rebooted my server a little while ago to add 3 used drives.   They are all preclearing right now.  I ran the command you suggested above.    UnMenu stopped working for some reason, so I tried to start it up again and I got this:

root@Tower:/boot/unmenu# uu

root@Tower:/boot/unmenu# unmenu[18542]: awk: ./unmenu.awk:256: fatal: can't open two way socket `/inet/tcp/8080/0/0' for input/output (No such file or directory)

 

I think my computer is cursed!  I don't like it using words like FATAL :)

 

 

I'm going to tackle this one piece/error at a time.

 

 

I ran the email test and got this back:

 

root@Tower:~# echo "This message is being sent from my unRAID server" | mail -s "Testing the shell mail program" root

: command not found 2:

: command not found 5:

: command not found 8:

: command not found 11:

: command not found 14:

'usr/bin/mail: line 30: syntax error near unexpected token `in

'usr/bin/mail: line 30: `       case "$1" in

 

OK, you used an editor that did not properly put ONLY newline characters at the ends of lines when you edited mail.sh.  It is probably corrupted with the trailing carriage-returns, or, you are missing a quote mark, since it is attempting to find "2" as a command, "5" as a command, "8" as a command, and "11" as a command, etc.

The part that stands out as a possible error is that an earlier instruction told me to put mail.sh and nc into this folder:

\\Tower\flash\custom\bin

 

It looks like something is looking for "mail" in usr/bin/ folder.

Yes, installing mail each time will require you to copy it to where mail is normally expected to be found.

===================================================

Problem 2:  I'm not sure what start this, but I've rebooted my server a little while ago to add 3 used drives.   They are all preclearing right now.  I ran the command you suggested above.    UnMenu stopped working for some reason, so I tried to start it up again and I got this:

root@Tower:/boot/unmenu# uu

root@Tower:/boot/unmenu# unmenu[18542]: awk: ./unmenu.awk:256: fatal: can't open two way socket `/inet/tcp/8080/0/0' for input/output (No such file or directory)

 

I think my computer is cursed!  I don't like it using words like FATAL :)

In this case, you probably already added a line to start the unMENU process.  Only one process at a time can open the port, so when you attempted to invoke unMENU a second time, you got a fatal error.  If it is already running, don't try to start it again.  ;D  You can ignore the error.

 

Until you can get mail running with the single line test I gave you, forget about getting any mail sent from the server.  Go back

 

Joe L.

 

 

 

I deleted the mail.sh and put a new copy in.  I edited it this time using the editor in UnMenu.  The resulting mail.sh file looks like this:

 

 

# Define the following three values to setup this script

 

# The name of your SMTP server

sSmtpServer="smtp.teksavvy.com"

 

# Your domain name

sDomain="www.teksavvy.com"

 

# The "from" email address

sMailFrom="[email protected]"

 

addressee=""

subject="message from unRAID server"

 

PATH=$PATH:/boot/custom/bin:/boot

# process the arguments

if [ $# = 0 ]

then

echo "Usage: mail -s 'subject' address [address]"

exit 2

fi

 

set -- "$@"

while true

do

if [ "$#" = 0 ]

then

break

fi

case "$1" in

-s)  shift

    subject="$1"

;;

*)

    add=$1

    if [ "$add" = "root" ]

    then

# check to see if a forwarding file is in place

if [ -f /root/.forward ]

then

forward_to=`cat /root/.forward`

if [ "$forward_to" != "" ]

then

    add=$forward_to

fi

fi

    fi

    addressee="$addressee $add"

;;

esac

shift

done

#echo "subject=" $subject

if [ "$addressee" = "" ]

then

echo "No addressee given."

echo "Usage: mail -s 'subject' address [address]"

exit 2

fi

 

# look up the ip address given the machine name

ip_addr=`net lookup $sSmtpServer 2>/dev/null`

if [ $? = 0 ]

then

 

# Build the echo string

sEcho="ehlo $sDomain\r\nmail from:$sMailFrom\r\n"

 

# Add each recipient to the RCPT list

for i in $addressee

do

sEcho+="RCPT TO:"$i"\r\n"

done

 

# Message header

sEcho+="data\r\nFrom:$sMailFrom\r\nTo:"

 

# Add each recipient to the message header

for i in $addressee

do

sEcho+=$i";"

done

 

sEcho+="\r\n"

 

# Message Subject

sEcho+="Subject:$subject\r\n\r\n"

 

sEcho+=`sed "s/$/\\r\\n/"` # this reads from stdin for the message body

 

# End the message

sEcho+="\r\n.\r\n"

sEcho+="QUIT\r\n"

# Send the message we just built

 

echo -e $sEcho|nc -i 1 -q 1 $ip_addr 25

 

# Use the following line for debug

#echo -e $sEcho|nc -w 1 -q 2 -i 1 -vv $ip_addr 25

else

echo "unable to determine IP address of $sSmtpServer" 1>&2

exit 2

fi

 

 

Sorry, but I don't follow your comment "Yes, installing mail each time will require you to copy it to where mail is normally expected to be found."

 

My mail is being installed automatically ( to the best of my knowledge ) with the package:  mail.auto_install

 

I edited my go file ( although I am wondering if I did that correctly, so i may have to delete it and re-edit it with UnMenu's editor ) and I added this line to it:

# This is used to send email notifications to me

echo "[email protected]" >/root/.forward

 

Do I need to move the mail.sh and nu to a different folder instead of \\Tower\flash\custom\bin ?  Should I put them in \\Tower\flash\usr\bin or do I need to change something elsewhere that may be looking in the wrong place for the file(s) ?

 

Once I change the mail.sh file and the go file , to make the changes active now, so I need to reboot the server ( only asking because I am pre-clearing 2 drives and can't reboot ).

 

Joe .. you must have kids as you have so much patience with all the questions we ask.  Just so you know, I , and I am sure many others, appreciate all the help! :) 

 

 

 

 

I deleted the mail.sh and put a new copy in.   I edited it this time using the editor in UnMenu.   The resulting mail.sh file looks like this:

 

<snip>

</snip>

Ok, now what happens when you use the one line test?

Sorry, but I don't follow your comment "Yes, installing mail each time will require you to copy it to where mail is normally expected to be found."

 

My mail is being installed automatically ( to the best of my knowledge ) with the package:  mail.auto_install

Probably is, as long as the mail.sh file is currently in /boot/custom/bin

I edited my go file ( although I am wondering if I did that correctly, so i may have to delete it and re-edit it with UnMenu's editor ) and I added this line to it:

# This is used to send email notifications to me

echo "[email protected]" >/root/.forward

 

Do I need to move the mail.sh and nu to a different folder instead of \\Tower\flash\custom\bin ?  Should I put them in \\Tower\flash\usr\bin or do I need to change something elsewhere that may be looking in the wrong place for the file(s) ?

 

Once I change the mail.sh file and the go file , to make the changes active now, so I need to reboot the server ( only asking because I am pre-clearing 2 drives and can't reboot ).

 

Joe .. you must have kids as you have so much patience with all the questions we ask.   Just so you know, I , and I am sure many others, appreciate all the help! :) 

No, never had any kids...

 

You do not need to reboot to test any of these changes... This is NOT windows... you almost never need to reboot Linux. (unless loading a new Kernel)

 

Try sending the test message once more, using the one line I gave previously.

 

Joe L.

My mind has been Window's Washed for decades unfortunately.    I'm learning... slowly :)

 

I've re-ran the one liner and I still seem to get the same results:

 

root@Tower:/boot/custom/bin# echo "This message is being sent from my unRAID server" | mail -s "Testing the shell mail program" root

: command not found 2:

: command not found 5:

: command not found 8:

: command not found 11:

: command not found 14:

'usr/bin/mail: line 30: syntax error near unexpected token `in

'usr/bin/mail: line 30: `      case "$1" in

root@Tower:/boot/custom/bin#

 

See attached below my /boot/custom directory and all the contents inside it.

 

It will probably be a bit of an over load right this second but it will give you an idea of how I (and some of the other members) have set up my server.

 

If you have any questions let me know

Understanding how one program interacts with others is complicated.  As much as people complain about Windows, I can click on "install" and it does all the behind the scenes work for me.

 

In linux, I try to follow steps given EXACTLY  :)

 

I've used UnMenu to automatically install some applications as well as set the system to start them each time I reboot.

 

If you look at this post:

http://lime-technology.com/forum/index.php?topic=1528.msg40214#msg40214

 

I have done exactly what is there.

 

I'm not sure I am comfortable enough with knowing how applications are launched to start moving files around from the default folders they landed in.

 

With mail.sh and nu , I made the directory myself and I moved them into and I edited them.    If I have put them in the wrong spot, can you direct me on how to remove all the other components ( do I just delete the bin folder contents and then go into packages and delete the files from in there )?

 

And I thought this was going to be an easy feature to add to the APC UPS .   I haven't even got as far as figuring out if the APC software is working correctly and will properly shut my machine down should the UPS almost run out of juice during a power outage  :)    My main PC , router, switch and DSL modem are back up by another UPS, so I will at least get the notification should the power go out ( when I finally get things working )  :)

Understanding how one program interacts with others is complicated.  As much as people complain about Windows, I can click on "install" and it does all the behind the scenes work for me.

And in windows you know nothing of how anything interacts with each other... or what it breaks...

In linux, I try to follow steps given EXACTLY  :)

 

I've used UnMenu to automatically install some applications as well as set the system to start them each time I reboot.

 

If you look at this post:

http://lime-technology.com/forum/index.php?topic=1528.msg40214#msg40214

 

I have done exactly what is there.

I wrote that post, so you probably have it correct.  To check what else is happening, I need to ask you to show me the output of a few commands.

 

Please show me the output of the following commands:

ls -l /boot/custom/bin

 

also the output of

net lookup smtp.teksavvy.com

 

and

cat -v /boot/custom/bin/mail.sh

 

and

cat -v /boot/config/go

 

and lastly

/boot/custom/bin/nc -?

 

I'm not sure I am comfortable enough with knowing how applications are launched to start moving files around from the default folders they landed in.

 

With mail.sh and nu , I made the directory myself and I moved them into and I edited them.    If I have put them in the wrong spot, can you direct me on how to remove all the other components ( do I just delete the bin folder contents and then go into packages and delete the files from in there )?

It is as easy as that... to remove the scripts and directory, just type

rm /boot/custom/bin/mail.sh

rm /boot/custom/bin/nc

rmdir /boot/custom

 

To make the directory type

mkdir -p /boot/custom/bin

 

To move the files from /boot to the /boot/custom/bin directory type

mv /boot/mail.sh /boot/custom/bin/mail.sh

mv /boot/nc /boot/custom/bin/nc

[/b]The commands are almost identical to those used in DOS, other than they used "del" and unix uses "rm", and dos uses "move" and linux uses "mv"

Think of shell scripts as equivalent to batch files in DOS, they just invoke commands in turn.  We can even have them show us what they are doing as they do it, by invoking them in a special way...

 

Windows tends to have huge programs that do one thing poorly, Linux has a ton of smaller programs that each do one thing very well.  Those small programs can have their inputs and outputs interconnected through pipes to do very complicated tasks.  Linux has a ton of flexibility...

 

But first, before you take on learning all of linux,  let me see the output of the five commands I asked about.  That will help me to see what you have done. 

 

We'll get you working... or I'll give you a completely different mail program to install.  (I've been wanting to do a plug-in page just for mail in unMENU for a while... but wanted to make it universal, regardless of how you sent the mail outward.  I've got a method I currently use, but it needs a page of its own in unMENU for the parameter setup rather than editing a shell script. )

 

By the way, I took the exact script you pasted above in red, copied it fro your post, put it in a file named mailtest.sh on my server and ran it unchanged...  Your mail host complained about it would not forward mail on behalf of gmail. But it worked otherwise.  You just need to get to that point.

It looked like this talking to your mail server...

root@Tower:~# echo "this is a test" | mailtest.sh -s "testing" root

220 smtp.teksavvy.com ESMTP Internet Mail Server v1.0; Mon, 12 Oct 2009 22:28:53 -0400

250-smtp.teksavvy.com Hello www.teksavvy.com [111.222.255.255], pleased to meet you.

250-ENHANCEDSTATUSCODES

250-SIZE 20971520

250-EXPN

250-ETRN

250-ATRN

250-DSN

250-CHECKPOINT

250-8BITMIME

250 HELP

250 2.1.0 <[email protected]>... Sender ok

550 5.7.1 <[email protected]>... we do not relay <[email protected]>

503 5.5.1 Incorrect command sequence

500 5.5.1 Command unrecognized: "From:[email protected]"

500 5.5.1 Command unrecognized: "To:[email protected];"

500 5.5.1 Command unrecognized: "Subject:testing"

500 5.5.1 Command unrecognized: ""

500 5.5.1 Command unrecognized: "this is a test"

500 5.5.1 Command unrecognized: "."

221 2.0.0 smtp.teksavvy.com closing connection

In the interim, to see if you have the UPS connected, on the "System Info" page in unMENU there is a "UPS Status" button. If things are working you'll get a status page from your UPS when you press it.  Or, if you want to type the command it uses at the linux command prompt, type

/sbin/apcaccess status

And I thought this was going to be an easy feature to add to the APC UPS .   I haven't even got as far as figuring out if the APC software is working correctly and will properly shut my machine down should the UPS almost run out of juice during a power outage  :)    My main PC , router, switch and DSL modem are back up by another UPS, so I will at least get the notification should the power go out ( when I finally get things working )  :)

 

Let me know what happens when you click on the UPS Status button.

 

And... as I said, when I lose power I lose my cable modem connection too, so I get no outbound mail at all at that time.  No matter what I do.... even if I were to power my router and cable modem from the UPS, odds are the cable system would be out anyway as they lose power on the telephone poles.  Having a working mail command is not needed for the UPS shutdown to occur...  not at all.

 

Joe L.

Remember a few posts ago I said:

If I did not have ".forward" file in place with my correct e-mail, it would have resulted in the mail being sent to "root" at my e-mail provider, who would probably ignore it as junk mail.

I was wrong...  They don't "ignore it"  They don't even bother to read it, because the in-box is full and the message was not delivered... I can only imagine the huge amount of root's unread mail at rr.com.

 

This Message was undeliverable due to the following reason:

The user(s) account is temporarily over quota.

< root @ mail.rr.com >

 

Who needs to know of critical system errors... not roadrunner's system administrators... They have thousands of customers to call in when it stops working...  >:(

Here's the info you need for troubleshooting:

 

root@Tower:~# ls -l /boot/custom/bin

total 24

-rwxrwxrwx 1 root root  1877 Oct 12 17:23 mail.sh*

-rwxrwxrwx 1 root root 18596 Aug 17  2007 nc*

 

root@Tower:~# net lookup smtp.teksavvy.com

65.39.196.238

 

root@Tower:~# cat -v /boot/custom/bin/mail.sh

# Define the following three values to setup this script

 

# The name of your SMTP server

sSmtpServer="smtp.teksavvy.com"

 

# Your domain name

sDomain="www.teksavvy.com"

 

# The "from" email address

sMailFrom="[email protected]"

 

addressee=""

subject="message from unRAID server"

 

PATH=$PATH:/boot/custom/bin:/boot

# process the arguments

if [ $# = 0 ]

then

        echo "Usage: mail -s 'subject' address [address]"

        exit 2

fi

 

set -- "$@"

while true

do

        if [ "$#" = 0 ]

        then

                break

        fi

        case "$1" in

        -s)  shift

            subject="$1"

        ;;

        *)

            add=$1

            if [ "$add" = "root" ]

            then

                # check to see if a forwarding file is in place

                if [ -f /root/.forward ]

                then

                        forward_to=`cat /root/.forward`

                        if [ "$forward_to" != "" ]

                        then

                            add=$forward_to

                        fi

                fi

            fi

            addressee="$addressee $add"

        ;;

        esac

        shift

done

#echo "subject=" $subject

if [ "$addressee" = "" ]

then

        echo "No addressee given."

        echo "Usage: mail -s 'subject' address [address]"

        exit 2

fi

 

# look up the ip address given the machine name

ip_addr=`net lookup $sSmtpServer 2>/dev/null`

if [ $? = 0 ]

then

 

        # Build the echo string

        sEcho="ehlo $sDomain\r\nmail from:$sMailFrom\r\n"

 

        # Add each recipient to the RCPT list

        for i in $addressee

        do

                sEcho+="RCPT TO:"$i"\r\n"

        done

 

        # Message header

        sEcho+="data\r\nFrom:$sMailFrom\r\nTo:"

 

        # Add each recipient to the message header

        for i in $addressee

        do

                sEcho+=$i";"

        done

 

        sEcho+="\r\n"

 

        # Message Subject

        sEcho+="Subject:$subject\r\n\r\n"

 

        sEcho+=`sed "s/$/\\r\\n/"` # this reads from stdin for the message body

 

        # End the message

        sEcho+="\r\n.\r\n"

        sEcho+="QUIT\r\n"

        # Send the message we just built

 

        echo -e $sEcho|nc -i 1 -q 1 $ip_addr 25

 

        # Use the following line for debug

        #echo -e $sEcho|nc -w 1 -q 2 -i 1 -vv $ip_addr 25

else

        echo "unable to determine IP address of $sSmtpServer" 1>&2

        exit 2

fi

 

 

root@Tower:~# cat -v /boot/config/go

#!/bin/bash^M

# Start the Management Utility^M

/usr/local/sbin/emhttp &^M

cd /boot/packages && find . -name '*.auto_install' -type f -print | sort | xargs -n1 sh -c ^M

^M

# This is used to send email notifications to me^M

echo "[email protected]" >/root/.forward^M

# This will auto-load unmenu^M

 

(not that I removed the command for unmenu as I thought I messed it up, BUT I put it back in eventhough the above command doesn't show it for some reason).

Attached here is my go file when being viewed through UnMenu's script editor:

 

#!/bin/bash

# Start the Management Utility

/usr/local/sbin/emhttp &

cd /boot/packages && find . -name '*.auto_install' -type f -print | sort | xargs -n1 sh -c

 

# This is used to send email notifications to me

echo "[email protected]" >/root/.forward

# This will auto-load unmenu

/boot/unmenu/uu

 

 

root@Tower:~# /boot/custom/bin/nc -?

/boot/custom/bin/nc: invalid option -- ?

nc -h for help

 

 

The UPS has always showed up in UnMenu.  Here is the output:

 

UPS Status

 

(from /sbin/apcaccess status)

 

APC      : 001,036,0906

DATE    : Tue Oct 13 18:30:48 GMT+5 2009

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: Mon Oct 12 15:09:11 GMT+5 2009

STATUS  : ONLINE

LINEV    : 121.0 Volts

LOADPCT  :  42.0 Percent Load Capacity

BCHARGE  : 100.0 Percent

TIMELEFT :  12.4 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  : Tue Oct 13 18:31:49 GMT+5 2009

 

 

I'll let you evaluate the output above before I change anything.  If I should move the files around , as per below, let me know and I will and I can re-run all the commands below to gather more info.

 

It is as easy as that... to remove the scripts and directory, just type

rm /boot/custom/bin/mail.sh

rm /boot/custom/bin/nc

rmdir /boot/custom

 

To make the directory type

mkdir -p /boot/custom/bin

 

To move the files from /boot to the /boot/custom/bin directory type

mv /boot/mail.sh /boot/custom/bin/mail.sh

mv /boot/nc /boot/custom/bin/nc

 

 

*********UPDATE***********

 

Don't reply to the above before reading this.

 

I rebooted my server ( as I wanted to test the UPS shutdown script ).   I plugged my server into the wall directly and plugged a lamp into the UPS to drain it.   So.. if the UPS sends the right message to the server, it will shut it down properly.  If it doesn't, then nothing will happen.

 

BUT BUT BUT

 

I got my email notification:

 

Subject: Tower Power Failure !!!

 

Tower Power Failure !!!

 

APC : 001,037,0948

DATE : Tue Oct 13 18:48:24 GMT+5 2009

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: Tue Oct 13 18:48:12 GMT+5 2009

STATUS : ONBATT

LINEV : 000.0 Volts

LOADPCT : 30.0 Percent Load Capacity

BCHARGE : 098.0 Percent

TIMELEFT : 16.0 Minutes

MBATTCHG : 5 Percent

MINTIMEL : 3 Minutes

MAXTIME : 0 Seconds

SENSE : High

LOTRANS : 092.0 Volts

HITRANS : 139.0 Volts

ALARMDEL : Always

BATTV : 11.9 Volts

LASTXFER : Low line voltage

NUMXFERS : 1

XONBATT : Tue Oct 13 18:48:18 GMT+5 2009

TONBATT : 7 seconds

CUMONBATT: 7 seconds

XOFFBATT : N/A

STATFLAG : 0x07060010 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 : Tue Oct 13 18:48:25 GMT+5 2009

 

So... for whatever reason, rebooting it seemed to start everything up. 

 

 

EDIT:  SUCCESS!  At 3 minutes power remaining on the UPS the powerdown script launched.    Now I feel confident my data/array is safe in the event of a power outage.

 

Next.....getting my parity drive tomorrow , preclearing it and then setting it up, cache_directory and then my cache drive.

 

 

 

  • 5 weeks later...

Hi !

I'm looking to bye  this APC Back-UPS CS BK650EI its 400W.

 

But  one question

 

When my Server are in sleep mode and then power are gone, will the UPS wake the server up and do a clean powerdown ?

 

//Peter

If your BIOS has an option to wake up on a serial event and you enable it, and you are using the serial interface for the UPS, then the message from the UPS that power is out SHOULD wake up the system.

If your BIOS has an option to wake up on a serial event and you enable it, and you are using the serial interface for the UPS, then the message from the UPS that power is out SHOULD wake up the system.

 

OK, I need to check that , but I think it is something about USB wake up , need to check,

 

Waht do you think about above UPS ? i have 6disc is it OK with 400w ? I have a PSU in my PC at 650w

I can tell you what I have and that is working:

http://www.apc.com/resource/include/techspec_index.cfm?base_sku=BE550G-CN

 

Took some help from the guys in here, but its doing its job.    I sends the shut down command if my UPS reaches 5% or 3 minutes remaining.  I've also got it so that it emails me if I lose power and when power is restored (unless you have Internet / Router / Switch on a UPS also, this part might be a waste of time ).

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.