*New 11.4 series Release:
2020-07-03: XigmaNAS 11.4.0.4.7633 - released!

*New 12.1 series Release:
2020-04-17: XigmaNAS 12.1.0.4.7542 - released


We really need "Your" help on XigmaNAS https://translations.launchpad.net/xigmanas translations. Please help today!

Producing and hosting XigmaNAS costs money. Please consider donating for our project so that we can continue to offer you the best.
We need your support! eg: PAYPAL

newbie question, email code for script

XigmaNAS Scripts and shell tips
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

newbie question, email code for script

#1

Post by fizzgig656 »

hi i found a script im playing with, god knows if it will work!!!. but one line is;

mutt -s "** IP ALERT ** - New Dynamic IP!" $MAILTO <<< $IP

can i change this to use the inbult mailer? im guessing butt wont work!?

the whole script is.
#!/bin/bash
## VARIABLES
IP=`links http://whatismyipaddress.com | awk '/Your IP address is/ { print $5 }'`
SCRIPTSHOME=/scripts
MAILTO=user@example.com

## MAIN SCRIPT
clear
echo "*****************************"
echo "** Dynamic DNS IP Notifier **"
echo "*****************************"
echo -n "Current detected IP address: $IP"
echo ""
if [ ! -f "$SCRIPTSHOME/ips.log" ]; then
echo "ips.log NOT found. Creating file."
touch $SCRIPTSHOME/ips.log
else
echo "Sanity checks passed. Continuing."
fi
echo -n "Checking if this is a new IP"
if [ "`cat $SCRIPTSHOME/ips.log`" != $IP ]; then
echo "...IP HAS CHANGED!"
echo $IP > $SCRIPTSHOME/ips.log
echo -n "Emailing the current IP"
mutt -s "** IP ALERT ** - New Dynamic IP!" $MAILTO <<< $IP
echo "...DONE"
else
echo "...IP HAS NOT CHANGED!"
fi
echo ""
echo "...Exiting"
exit 0
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

Re: newbie question, email code for script

#2

Post by fizzgig656 »

i know i could use dynDNS and others, but im a cheapskate :). its only for infrequent use.
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

Re: newbie question, email code for script

#3

Post by fizzgig656 »

Ignore me, trying to remake the wheel? ill try to use one of the free DNS services. is no-ip ok?
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

fsbruva
Advanced User
Advanced User
Posts: 378
Joined: 21 Sep 2012 14:50
Status: Offline

Re: newbie question, email code for script

#4

Post by fsbruva »

The primary issue you will experience is: mutt is not included in Nas4Free. The system email client included an configured in the system tab (and used for the other email notifications - S.M.A.R.T.) is msmtp. Go take a look in the zfs status script in the other helpful scripts post - I am sure it will have the needed syntax for using msmtp to write an email.

Out of curiousity - why do you want an email when your IP address changes? Oh, are you trying to get the dynamic dns to work? Why can't you use dynDNS? I have two free hosts with them.

fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

Re: newbie question, email code for script

#5

Post by fizzgig656 »

Hi thanks for the info. I was being a div. I'm wanting to access my nas over the internet, but I'm not going to use it much and don't want to pay for a ddns. I was happy to just use the emailed ip. But I see there are a few free dynamic dns services. Dyndns don't seem to do free ones. And good ones to use?
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5116
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: newbie question, email code for script

#6

Post by raulfg3 »

no-ip= http://www.no-ip.com/
zapto=no-ip
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

Re: newbie question, email code for script

#7

Post by fizzgig656 »

raulfg3 wrote:no-ip= http://www.no-ip.com/
zapto=no-ip
ok cheers, do you have to reactivate every month?
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

fsbruva
Advanced User
Advanced User
Posts: 378
Joined: 21 Sep 2012 14:50
Status: Offline

Re: newbie question, email code for script

#8

Post by fsbruva »

What do you mean re-activate? You mean re-associate your ip with your url? The Dynamic DNS service on NAS4Free will periodically check what its public IP is, and then update the record with no-ip automatically.

fsbruva
Advanced User
Advanced User
Posts: 378
Joined: 21 Sep 2012 14:50
Status: Offline

Re: newbie question, email code for script

#9

Post by fsbruva »

From Dyndns:
Try a free 14 day trial of DynDNS Pro - a great opportunity for users to test out one of our most popular services. You may keep one hostname free of charge for trying Pro.
Don't be fooled, you can get a free one.

fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

Re: newbie question, email code for script

#10

Post by fizzgig656 »

fsbruva wrote:From Dyndns:
Try a free 14 day trial of DynDNS Pro - a great opportunity for users to test out one of our most popular services. You may keep one hostname free of charge for trying Pro.
Don't be fooled, you can get a free one.
sounds good, with a try?
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

fsbruva
Advanced User
Advanced User
Posts: 378
Joined: 21 Sep 2012 14:50
Status: Offline

Re: newbie question, email code for script

#11

Post by fsbruva »

It's what I use. Dead simple.

fizzgig656
Advanced User
Advanced User
Posts: 155
Joined: 05 Dec 2012 16:10
Location: england
Status: Offline

Re: newbie question, email code for script

#12

Post by fizzgig656 »

yep, one more little tick off the "to do" list, thanks all, just setup my dyndns and im connected via name.

cheers all for your help - again! :)
10.2.0.2 - Prester (revision 1814) embedded x64 no swap + extended webgui, on atom D2700MUD 1x4gb ram, 1x mini sata controllers, 4 HDD in a icydock 4bay caddy run 2x 500gb mirror and 2x1tb mirror. Using CIFS/SMB, SSH, DLNA/UPnP, dynamic DNS, Webserver (owncloud) and BitTorrent for home use.

Pauk
NewUser
NewUser
Posts: 2
Joined: 21 Oct 2012 21:56
Status: Offline

Re: newbie question, email code for script

#13

Post by Pauk »

You may want to check out dynu.com because they offer dynamic DNS for both third level(e.g. *.dynu.com) as well as top level domain names(*.com, *.net etc) for free.
I have been using them for the past year or so and it has worked flawlessly. The IP updates are very quick and in my case I need a separate IP update for an alias of my main domain name which their client software supports.

Post Reply

Return to “Scripts and shell tips”