It's time to enjoy winter holidays. However, teachers will be working for another two weeks. I'd like to use the computers in the lab when I am at home. I need to create an automatic job to do this work. The job works on Linux systems (Fedora 12 and Redhat EL 5) with pppoe, sendmail, cron. Here is the steps.
1. create an ADSL account, name it as adsl
2. make a new file adsl.up
,
$vi adsl.up
commands in the file as
ifup adsl ifconfig ppp0 | mail -s IPaddress [email protected]
the 1st line is to connect ADSL with adsl
profile
the 2nd line is to get the ADSL (ppp0) connection infomation and to email you
A more complicated commands, with if-then, which could avoid to email nothing or to run mail
wrong if the connection is not successful.
ifup adsl PPPSTATUS='ifconfig ppp0' if $PPPSTATUS then ifconfig ppp0 | mail -s IPaddress [email protected] fi
3. change it mode to allow it executable
$chmod +x adsl.up
4. add the following line to the end of /etc/crontab
file:
00 21 * * * user PATH/adsl.up
this line means the machine will run adsl.up
at 21:00 everyday.
5. for saving the time of online, make a disconnecting file adsl.down
and make it executable
ifdown adsl
add the following line to the end of /etc/crontab
file:
00 01 * * * user PATH/adsl.down
this line means the machine will run adsl.down
at 01:00 everyday.
Ok, it's alright, but the sendmail
configuration need detail
1. edit /etc/mail/sendmail.mc
$vi /etc/mail/sendmail.mc
find the following line
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
and change 127.0.0.1 to 0.0.0.0, 0.0.0.0 means to find the domain on the internet.
2. Senmail SMTP authorizing
$vi /etc/mail/sendmail.mc
find the lines
dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)dnl dnl define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)dnl
delete the dnl
in the begining of the lines, since dnl
means comment this line in sendmail configuration file. Deleting it can make the line work.
3. add adequate nameservers
$vi /etc/resolv.conf
add 8.8.8.8 and 8.8.4.4 as your nameservers
; generated by /sbin/dhclient-script nameserver 8.8.8.8 nameserver 8.8.4.4
4. restart the sendmail service
$service sendmail restart
Finally, it works. I can use the lab computers in the winter holidays.