LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-13-2006, 04:05 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Rep: Reputation: 56
Dynamic IP and cron job


Hi folks,

Ubuntu-6.06.1-LAMP-server-amd64

I have a script.php which is used to update the IP address of my domain on registrar's website. I keep it on /etc/. The IP address of the server only changes on connection. Please advise how to create a "cron job" which will run the script after booting to update the IP address.

Is /etc/ the right directory for holding the script?

TIA

B.R.
satimis

Last edited by satimis; 12-13-2006 at 04:06 AM.
 
Old 12-13-2006, 05:46 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
cron is not the right tool for an on-boot event, just add it to /etc/rc.local

/etc/ is not the right place, no. try /usr/local/bin/
 
Old 12-13-2006, 05:54 AM   #3
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi acid_kewpie,

Tks for your advice.

Quote:
/etc/ is not the right place, no. try /usr/local/bin/
I'll put it /usr/local/bin/script.php
and make it excutable

Quote:
cron is not the right tool for an on-boot event, just add it to /etc/rc.local
$ cat /etc/rc.local
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
It is an empty file. Shall I put the line "/etc/rc.local/script.php" above "exit 0"?

TIA


B.R.
satimis
 
Old 12-13-2006, 05:58 AM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by satimis
$ cat /etc/rc.local
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
It is an empty file. Shall I put the line "/etc/rc.local/script.php" above "exit 0"?
Yes, that would work.
 
Old 12-13-2006, 08:26 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi trickykid and acid_kewpie,


Pls shed me some light on editing the script;

Script;
Code:
....
.... 
////////////////////////////////<-------- EDIT USER VARIABLES HERE --------> ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

$Bypass = "0";

$username = "username";
$password = "password";

$Adminemail = "you@yourdomain.com";
$Sendmail = "/path/to/sendmail -t -i";

$IPlogfile = "/full/server/path/to/updatednsIP.log";
$Logfile = "/full/server/path/to/updatedns.log";
acid_kewpie
$Log1 = "1";
$Email1 = 1;

$Log2 = "1";
$Email2 = 1;

$Log3 = "1";
$Email3 = "1";

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////<--------- END USER VARIABLES --------> /////////////////////////////////////
....
......

I suppose I have to change following items;

$username = "username";
$password = "password";

$Adminemail = "you@yourdomain.com";
$Sendmail = "/path/to/sendmail -t -i";

Now my problem is I'm running "postfix". How to change it? Tks.


2)
System Requirements: Linux, (PHP 3, PHP 4 >= 4.0.0)
//* and the ability to run crontabs


$ dpkg -l | grep php
Code:
ii  libapache2-mod-php5                              5.1.2-1ubuntu3.4              server-side, HTML-embedded scripting languag
ii  php-pear                                         5.1.2-1ubuntu3.4              PEAR - PHP Extension and Application Reposit
ii  php5                                             5.1.2-1ubuntu3.4              server-side, HTML-embedded scripting languag
ii  php5-cli                                         5.1.2-1ubuntu3.4              command-line interpreter for the php5 script
ii  php5-common                                      5.1.2-1ubuntu3.4              Common files for packages built from the php
ii  php5-curl                                        5.1.2-1ubuntu3.4              CURL module for php5
ii  php5-dev                                         5.1.2-1ubuntu3.4              Files for PHP5 module development
ii  php5-gd                                          5.1.2-1ubuntu3.4              GD module for php5
ii  php5-imap                                        5.1.2-1              IMAP module for php5
ii  php5-ldap                                        5.1.2-1ubuntu3.4              LDAP module for php5
ii  php5-mcrypt                                      5.1.2-1              MCrypt module for php5
ii  php5-mhash                                       5.1.2-1ubuntu3.4              MHASH module for php5
ii  php5-mysql                                       5.1.2-1ubuntu3.4              MySQL module for php5
ii  php5-mysqli                                      5.1.2-1ubuntu3.4              MySQL Improved module for php5
ii  php5-pspell                                      5.1.2-1              pspell module for php5
ii  php5-snmp                                        5.1.2-1ubuntu3.4              SNMP module for php5
ii  php5-sqlite                                      5.1.2-1ubuntu3.4              SQLite module for php5
ii  php5-xmlrpc                                      5.1.2-1ubuntu3.4              XML-RPC module for php5
ii  php5-xsl                                         5.1.2-1ubuntu3.4              XSL module for php5
Can php5 work alone? The script needs "(PHP 3, PHP 4 >= 4.0.0)" to run. Whether it requires both PHP3 and PHP4?

TIA

B.R.
satimis
 
Old 12-13-2006, 09:20 AM   #6
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi trickykid and acid_kewpie,

Performed following tests:

1)
/usr/local/bin/updated.php
Code:
.....
......
$Bypass = "0";

$username = "changeip.com login satimis";
$password = "changeip.com login xxxxxxx";

$Adminemail = "satimis@satimis.freeddns.com";
$Sendmail = "/etc/postfix -t -i";

$IPlogfile = "/var/log/updatedns/updatednsIP.log";
$Logfile = "/var/log/updatedns/updatedns.log";

$Log1 = "1";
$Email1 = 1;

$Log2 = "1";
$Email2 = 1;

$Log3 = "1";
$Email3 = "1";
....
.....
Rebooted PC. IP address on "https://www.changeip.com/" did not update.


2)
/usr/local/bin/updated.php
Code:
.....
......
$Bypass = "0";

$username = "satimis";
$password = "xxxxxxx";

$Adminemail = "satimis@satimis.freeddns.com";
$Sendmail = "/etc/postfix -t -i";

$IPlogfile = "/var/log/updatedns/updatednsIP.log";
$Logfile = "/var/log/updatedns/updatedns.log";

$Log1 = "1";
$Email1 = 1;

$Log2 = "1";
$Email2 = 1;

$Log3 = "1";
$Email3 = "1";
....
.....
Rebooted PC. IP address on "https://www.changeip.com/" did not update.

Remark: run
# chmod +c /usr/local/bin/update.php
after editing the file

/var/log/updatedns/updatedns.log
is an empty file.

Should this script.php must be run with cron?

Tks

B.R.
satimis
 
Old 12-13-2006, 09:27 AM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
The script.php

$ cat /usr/local/bin/update.php

<?
//* Package: changeip.com Auto IP updater
//* Version 1.1
//* System Requirements: Linux, (PHP 3, PHP 4 >= 4.0.0)
//* and the ability to run crontabs
//* File: update.php
//* Author: Don Jobes - webmaster@internet-demon.com
//* Last Modified: 01.21.2002
//*
//* YOU CAN REDISTRIBUTE THIS SOFTWARE. You can modify it for
//* your own personal use provided that this header remains intact.
//*
//* This software is provided as is, without a warranty of any kind.
//* Neither Don Jobes nor Internet-Demon.com take responsibility for
//* any damages suffered as a result of using or modifying this software.
//* In no event will Don Jobes or Internet-Demon.com be held liable
//* for any lost revenue, profit, data, or punitive damages, however
//* caused and regardless of theory of liability, arising out of the use
//* of or inability to use this software, even if Don Jobes and/or
//* Internet-Demon.com has been advised of the possibility of such
//* damages.
//*
//* Donations are not necessary but welcomed through Paypal
//* djobes@internet-demon.com
//*
//* Entire contents � Copyright 2001-2002 Internet-Demon.com.
//* All rights reserved.
//*
//*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////BRIEF OVERVIEW PLEASE READ //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*
//*
//* This script will update your dynamic ip address by the use of a cron job. There are two ways this script can
//* be used.
//*
//* 1. No Router, This is if your PC Running Linux is connected directly to your ISP. Using this setup option will
//* allow you to set the cron job to run every few minutes. Only when your IP changes an update will be sent.
//*
//* NOTE: IF YOUR CRON JOB IS SET TO EVERY FEW MINUTES SET YOUR EMAIL OPTIONS TO "0" Or you will fill the log file
//* along with your email box.
//*
//*
//* 2. Router, This is if your PC Running Linux is connected to a router. for example, a LINKSYS. When using a router
//* your IP address on your linux PC would not be the true IP assigned by your ISP. The IP would be assigned by the
//* router and would more than likely be 192.168.1.* If you have this type of connection you will have to USE the
//* bypass feature and send out updates whether you need them or not.
//*
//* NOTE: If you are on a CABLE MODEM or DSL your IP almost never changes. So you should not set your cron job to run
//* every few minutes. More like once every few hours is sufficaint. Some will find that two to three times
//* a day will work fine. After a week or so you will find that you can tailor the cron for a longer duration
//* between updates.
//*
//* IF YOUR CRON JOB IS SET TO EVERY FEW MINUTES SET YOUR EMAIL OPTIONS TO "0" Or you will fill the log file
//* along with your email box.
//*
//*
//*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////CHECK YOUR CHANGEIP.COM SETTINGS ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*
//*
//* 1. Make Changes to your domains so that ALL Options update on SET 1. The first column of check boxes.
//*
//*
//*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// SETUP INSTRUCTIONS ///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*
//* 1. Edit the variables below in this file to match your server and your needs.
//* 2. Upload update.php and updatedns.log to your root web.
//* 3. chmod updatedns.log to 666
//* 3. Create a cron job to execute update.php. See the following example.
//*
//* Telnet into your server create a new cronjob. The following would
//* run every night at 12:59pm. Depending on your needs you will have
//* to modify the run time variables.
//*
//* 59 23 * * * wget -q http://www.yoursite.com/update.php
//*
//* minute (0-59)
//* hour (0-23)
//* day of the month (1-31)
//* month of the year (1-12)
//* day of the week (0-6 with 0=Sunday)
//*
//* NOTE: A cron can also be setup using WEBMIN if you have it installed. This is easyier for most.
//*
//*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// SETUP OPTION DESCRIPTIONS DO NOT EDIT THESE HERE //////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*
//*
//* $username = "changeip.com login username";
//* $password = "changeip.com login password";
//*
//* $Adminemail = "you@yourdomain.com";
//* $Sendmail = "/path/to/sendmail -t -i";
//*
//* $Logfile = "/full/server/path/to/updatedns.log";
//*
//*
////////////////////////////////////////// IF USING A ROUTER ////////////////////////////////////////////////
//*
//* $Bypass = "0"; SET TO "1" if you are behind a router and your PC is assigned an IP by your router.
//* $Log3 = "0"; No log file output
//* $Log3 = "1"; Appends a new line to the log file when a update is sent to changeip.com
//*
//*
//*
////////////////////////////////////// NO ROUTER, DIRECT CONNECTION /////////////////////////////////////////
//*
//*
//*
//* $Log1 = "0"; No log file output
//* $Log1 = "1"; Appends a new line to the log file ONLY when a update is sent to changeip.com
//* $Log2 = "0"; No log file output
//* $Log2 = "1"; Appends a new line to the log file even when there is no update sent to changeip.com
//* $Email1 = "0"; No Email Will be sent
//* $Email1 = "1"; Sends an email to the address specified. when a update is sent to changeip.com
//* $Email2 = "0"; No Email Will be sent
//* $Email2 = "1"; Sends an email to the address specified. when a update is sent to changeip.com
//*
//* $IPfile = "/full/server/path/to/updatednsIP.log"; <--- This is not an option if using direct connect
//* $Logfile = "/full/server/path/to/updatedns.log";
//*
//*
//*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////<-------- EDIT USER VARIABLES HERE --------> ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

$Bypass = "0";

$username = "username";
$password = "password";

$Adminemail = "you@yourdomain.com";
$Sendmail = "/path/to/sendmail -t -i";

$IPlogfile = "/full/server/path/to/updatednsIP.log";
$Logfile = "/full/server/path/to/updatedns.log";

$Log1 = "1";
$Email1 = 1;

$Log2 = "1";
$Email2 = 1;

$Log3 = "1";
$Email3 = "1";

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////<--------- END USER VARIABLES --------> /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING//////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

$UPDATEURL = "https://www.changeip.com/dynamic/dns/update.asp?u=$username&p=$password&cmd=update&set=1&offline=0";


if ($REMOTE_ADDR == "") $Boxaddress = "Server address Unknown";
else $Boxaddress = $REMOTE_ADDR;

$tdate = date("h:i:s");
$datecode = date("m-d-Y");

if($Bypass == "0"){


if (file_exists($IPlogfile)){

$file=file("$IPlogfile","r");
foreach($file as $line){
list($Lastip,$blank) = split("\:",chop($line));
if($Lastip != $REMOTE_ADDR){


header("location: $UPDATEURL");

$createFile = fopen("$IPlogfile", "w");
fwrite($createFile,"$REMOTE_ADDR:\r\n");
fclose($createFile);

if($Log1 == "1"){
$filelog = fopen("$Logfile", "a");
flock($filelog, 2);
fputs($filelog,"DNS Update set 1, Current IP: $REMOTE_ADDR, Previous IP: $Lastip, Date: $datecode, Time: $tdate. Update Successful\r\n");
flock($filelog, 3);
fclose($filelog);
}

if($Email1=="1"){

$to = "$Adminemail";
$subject = "IP Auto update Report";
$body ="Hello, $username\r\n\r\nYour IP address has changed and an update request was sent to changeip.com.\r\n\r\n Current IP: $REMOTE_ADDR\r\n Previous IP: $Lastip\r\n Time: $tdate\r\n Date: $datecode\r\n\r\nChangeip.com IP Auto Updater by Djobes@Internet-demon.com";

$mailer = popen($Sendmail,"w") or die ("error writing");
fwrite ($mailer,"Subject: $subject\nFrom: \"Changeip-AutoUpdater\" $Adminemail\nTo: $to\n\n$body");
pclose($mailer);
}

}
}
}


else
{
header("location: $UPDATEURL");

$createFile = fopen("$IPlogfile", "w");
fwrite($createFile,"$REMOTE_ADDR:\r\n");
fclose($createFile);

if($Log1 == "1"){
$filelog = fopen("$Logfile", "a");
flock($filelog, 2);
fputs($filelog,"DNS Update set 1, Current IP: $REMOTE_ADDR, Previous IP: Unknown, Date: $datecode, Time: $tdate. Update Successful\r\n");
flock($filelog, 3);
fclose($filelog);
}

if($Email1=="1"){

$to = "$Adminemail";
$subject = "IP Auto update Report";
$body ="Hello, $username\r\n\r\nYour IP address has changed and an update request was sent to changeip.com.\r\n\r\n Current IP: $REMOTE_ADDR\r\n Previous IP: Either this is the first time you run this script or you deleted the updatednsip.log. This is normal\r\n Time: $tdate\r\n Date: $datecode\r\n\r\nChangeip.com IP Auto Updater by Djobes@Internet-demon.com";

$mailer = popen($Sendmail,"w") or die ("error writing");
fwrite ($mailer,"Subject: $subject\nFrom: \"Changeip-AutoUpdater\" $Adminemail\nTo: $to\n\n$body");
pclose($mailer);
}
}



if($Lastip == $REMOTE_ADDR){

if($Log2 == "1"){
$filelog = fopen("$Logfile", "a");
flock($filelog, 2);
fputs($filelog,"DNS Update set 1, Current IP: $REMOTE_ADDR, Previous IP: $REMOTE_ADDR, Date: $datecode, Time: $tdate. No Update Required\r\n");
flock($filelog, 3);
fclose($filelog);
}

if($Email2=="1"){

$to = "$Adminemail";
$subject = "IP Auto update Report";
$body ="Hello, $username\r\n\r\nYour IP address did not change since the last update.\r\nThere was no need to send a update request to changeip.com\r\n\r\n Current IP: $REMOTE_ADDR\r\n Previous IP: $Lastip\r\n Time: $tdate\r\n Date: $datecode\r\n\r\nChangeip.com IP Auto Updater by Djobes@Internet-demon.com";

$mailer = popen($Sendmail,"w") or die ("error writing");
fwrite ($mailer,"Subject: $subject\nFrom: \"Changeip-AutoUpdater\" $Adminemail\nTo: $to\n\n$body");
pclose($mailer);
}
}
}

if($Bypass == "1"){

header("location: $UPDATEURL");

if($Log3 == "1"){
$filelog = fopen("$Logfile", "a");
flock($filelog, 2);
fputs($filelog,"DNS Update set 1, Current IP: $REMOTE_ADDR, Date: $datecode, Time: $tdate. Update Successful\r\n");
flock($filelog, 3);
fclose($filelog);
}

if($Email3=="1"){

$to = "$Adminemail";
$subject = "IP Auto update Report";
$body ="Hello, $username\r\n\r\nYour IP has been updated,\r\n\r\n Current IP: $REMOTE_ADDR\r\n Time: $tdate\r\n Date: $datecode\r\n\r\nChangeip.com IP Auto Updater by Djobes@Internet-demon.com";

$mailer = popen($Sendmail,"w") or die ("error writing");
fwrite ($mailer,"Subject: $subject\nFrom: \"Changeip-AutoUpdater\" $Adminemail\nTo: $to\n\n$body");
pclose($mailer);
}
}




?>s
 
Old 12-13-2006, 12:01 PM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
First of all, edit the file and then attempt to run it from the command line to see if it runs properly. Also when running a php file from the command, you may need to specify this on the command:

shell prompt> php /usr/local/bin/update.php

And as for sendmail command, you can have postfix and still have sendmail on your system to use to send mail, it will just use the running postfix MTA process to send thru, not sendmail since it's not running.
 
Old 12-13-2006, 05:24 PM   #9
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi trickykid,

Quote:
First of all, edit the file and then attempt to run it from the command line to see if it runs properly. Also when running a php file from the command, you may need to specify this on the command:

shell prompt> php /usr/local/bin/update.php
Edited /usr/local/bin/update.php
Code:
.......
.....
////////////////////////////////<-------- EDIT USER VARIABLES HERE --------> //////////////////////$///////////////////////////////////////////////////////////////////////////////////////////////////$
$Bypass = "0";

$username = "satimis";
$password = "xxxxxxx";

$Adminemail = "satimis@satimis.freeddns.com";
#$Sendmail = "/path/to/sendmail -t -i";
$Postfix = "/etc/init.d/postfix restart";

$IPlogfile = "/var/log/updatedns/updatednsIP.log";
$Logfile = "/var/log/updatedns/updatedns.log";

$Log1 = "1";
$Email1 = 1;

$Log2 = "1";
$Email2 = 1;

$Log3 = "1";
$Email3 = "1";

///////////////////////////////////////////////////////////////////////////////////////////////////$////////////////////////////////<--------- END USER VARIABLES --------> ///////////////////////////$
...
.....
$ sudo php /usr/local/bin/update.php
Code:
Warning: file() expects parameter 2 to be long, string given in /usr/local/bin/update.php on line 183

Warning: Invalid argument supplied for foreach() in /usr/local/bin/update.php on line 184

$ cat /usr/local/bin/update.php
Code:
.....
..........
        if($Bypass == "0"){


                if (file_exists($IPlogfile)){

                        $file=file("$IPlogfile","r");		(line 183)
                        foreach($file as $line){			(line 184)
                        list($Lastip,$blank) = split("\:",chop($line));
                                if($Lastip != $REMOTE_ADDR){


                        header("location: $UPDATEURL");

                        $createFile = fopen("$IPlogfile", "w");
                        fwrite($createFile,"$REMOTE_ADDR:\r\n");
                        fclose($createFile);

                if($Log1 == "1"){
....
......
# cat /var/log/updatedns/updatedns.log
Code:
DNS Update set 1, Current IP: , Previous IP: Unknown, Date: 12-14-2006, Time: 06:47:39. Update Successful
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 06:47:39. No Update Required
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 06:51:54. No Update Required
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 07:01:54. No Update Required
# cat /var/log/updatedns/updatednsIP.log
only a ":" (colon) there

Logon "changeip.com" site. Found IP address not updated.

Quote:
And as for sendmail command, you can have postfix and still have sendmail on your system to use to send mail, it will just use the running postfix MTA process to send thru, not sendmail since it's not running.
Changed as;
Code:
#$Sendmail = "/path/to/sendmail -t -i";
$Postfix = "/etc/init.d/postfix restart";

B.R.
satimis

Last edited by satimis; 12-13-2006 at 05:30 PM.
 
Old 12-13-2006, 05:49 PM   #10
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by satimis
Changed as;
Code:
#$Sendmail = "/path/to/sendmail -t -i";
$Postfix = "/etc/init.d/postfix restart";
$Postfix = "/etc/init.d/postfix restart";

That's not going to work. The code isn't restarting sendmail, you're using the sendmail command to send a message, not restarting it. You can most likely leave this line the way it is already, just make sure sendmail is installed, don't have to run as your MTA.
 
Old 12-13-2006, 06:28 PM   #11
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi trickykid,

Quote:
$Postfix = "/etc/init.d/postfix restart";

That's not going to work. The code isn't restarting sendmail, you're using the sendmail command to send a message, not restarting it. You can most likely leave this line the way it is already, just make sure sendmail is installed, don't have to run as your MTA.
Code:
$Adminemail = "satimis@satimis.freeddns.com";
$Sendmail = "/etc/init.d/sendmail -t -i";
#$Postfix = "/etc/init.d/postfix restart";
$ sudo apt-get install sendmail
Code:
................
.......................

*** *** *** WARNING *** WARNING *** WARNING *** WARNING *** *** ***

Everything you need to support STARTTLS (encrypted mail transmission
and user authentication via certificates) is installed and configured
but *IS* not being used.

To enable sendmail to use STARTTLS, you need to:
1) Add this line to /etc/mail/sendmail.mc and optionally
   to /etc/mail/submit.mc:
  include(`/etc/mail/tls/starttls.m4')dnl
2) Run sendmailconfig
3) Restart sendmail


Updating /etc/hosts.allow, adding "sendmail: all".

Please edit /etc/hosts.allow and check the rules location to
make sure your security measures have not been overridden -
it is common to move the sendmail:all line to the *end* of
the file, so your more selective rules take precedence.
Checking {sendmail,submit}.mc and related databases...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/Makefile...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Writing configuration to /etc/mail/sendmail.conf.
Writing /etc/cron.d/sendmail.
Disabling HOST statistics file(/var/lib/sendmail/host_status).
Creating /etc/mail/sendmail.cf...
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()*** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()

Creating /etc/mail/submit.cf...
Informational: confCR_FILE file empty: /etc/mail/relay-domains
Warning: confCT_FILE source file not found: /etc/mail/trusted-users
 it was created
Informational: confCT_FILE file empty: /etc/mail/trusted-users
Warning: confCW_FILE source file not found: /etc/mail/local-host-names
 it was created
Warning: access_db source file not found: /etc/mail/access
 it was created$ sudo apt-get install sendmail
Updating /etc/mail/access...
Linking /etc/aliases to /etc/mail/aliases
Updating /etc/mail/aliases...
/etc/mail/aliases: 1 aliases, longest 7 bytes, 11 bytes total

Warning: 3 database(s) sources
        were not found, (but were created)
        please investigate.

Warning: These messages were issued while creating sendmail.cf
        make sure they are benign before starting sendmail!

Errors in generating sendmail.cf
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()*** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()

Starting Mail Transport Agent: sendmail.

Setting up rmail (8.13.5-3ubuntu1.1) ...
Setting up sensible-mda (8.13.5-3ubuntu1.1) ...
Setting up sendmail (8.13.5-3ubuntu1.1) ...
$ sudo php /usr/local/bin/update.php
Code:
Warning: file() expects parameter 2 to be long, string given in /usr/local/bin/update.php on line 183

Warning: Invalid argument supplied for foreach() in /usr/local/bin/update.php on line 184
Invalid command <-t>
Usage: /etc/init.d/sendmail <command>
        Where <command> is one of the following
          start|stop|restart|restart-if-running
          reload-if-running|reload|force-reload
          newaliases|hoststat|purgestat|mailstats|mailq|runq|control
          status|debug|clean
$ sudo find / -name sendmail
Code:
/var/lib/sendmail
/var/run/sendmail
/home/satimis/Desktop/Webmin/webmin-1.300/sendmail
/home/satimis/Desktop/Webmin/webmin-1.300/caldera/sendmail
/home/satimis/Desktop/Webmin/webmin-1.300/mscstyle3/sendmail
/home/satimis/Desktop/Webmin/webmin-1.300/blue-theme/sendmail
/etc/network/if-up.d/sendmail
/etc/network/if-down.d/sendmail
/etc/alternatives/sendmail
/etc/logrotate.d/sendmail
/etc/cron.daily/sendmail
/etc/init.d/sendmail
/etc/dhcp3/dhclient-exit-hooks.d/sendmail
/etc/logcheck/ignore.d.workstation/sendmail
/etc/logcheck/ignore.d.server/sendmail
/etc/logcheck/ignore.d.paranoid/sendmail
/etc/logcheck/violations.ignore.d/sendmail
/etc/cron.d/sendmail
/etc/ppp/ip-down.d/sendmail
/etc/ppp/ip-up.d/sendmail
/etc/resolvconf/update-libc.d/sendmail
/etc/webmin/sendmail
/usr/share/doc/sendmail
/usr/share/bug/sendmail
/usr/share/sendmail
/usr/share/sendmail/examples/dhcp3/dhclient-exit-hooks.d/sendmail
/usr/share/sendmail/examples/ppp/ip-down.d/sendmail
/usr/share/sendmail/examples/ppp/ip-up.d/sendmail
/usr/share/sendmail/examples/logcheck/ignore.d.workstation/sendmail
/usr/share/sendmail/examples/logcheck/ignore.d.paranoid/sendmail
/usr/share/sendmail/examples/logcheck/ignore.d.server/sendmail
/usr/share/sendmail/examples/logcheck/violations.ignore.d/sendmail
/usr/share/sendmail/examples/network/if-down.d/sendmail
/usr/share/sendmail/examples/network/if-up.d/sendmail
/usr/share/sendmail/examples/resolvconf/update-libc.d/sendmail
/usr/share/sendmail/sendmail
/usr/lib/sm.bin/sendmail
/usr/lib/sendmail
/usr/sbin/sendmail
/usr/local/webmin/sendmail
/usr/local/webmin/caldera/sendmail
/usr/local/webmin/mscstyle3/sendmail
/usr/local/webmin/blue-theme/sendmail
Which should be the right path for "sendmail"

Shall I run "/etc/init.d/sendmail start/restart"?

$ cat /var/log/updatedns/updatedns.log
Code:
DNS Update set 1, Current IP: , Previous IP: Unknown, Date: 12-14-2006, Time: 06:47:39. Update Successful
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 06:47:39. No Update Required
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 06:51:54. No Update Required
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 07:01:54. No Update Required
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 08:11:17. No Update Required
DNS Update set 1, Current IP: , Previous IP: , Date: 12-14-2006, Time: 08:19:37. No Update Required
IP address on "changeip.com" site not updated.

Tks.


B.R.
satimis
 
Old 12-13-2006, 09:14 PM   #12
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
No, if you use Postfix as your MTA, keep it running. Do not start sendmail. You're not paying attention. Sendmail is an MTA yes, but you can also use the sendmail command as a way to just send an email from the command line.

/usr/sbin/sendmail is most likely the path you will use in the script. And remove that /etc/init.d in your config path for the sendmail command. This script most likely has nothing to do with restarting of ANY services or daemons on your system. It's only going to report your new IP, not run services for you or restart them.
 
Old 12-13-2006, 09:16 PM   #13
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by "satimis
IP address on "changeip.com" site not updated.
And stop checking this, until you get the script to actually run properly, you don't need to report this in each of your posts. And secondly, you most likely need to make sure that your IP is actually changing, which I doubt since most DHCP addresses are in 24 hour increments and that's if it does change.
 
Old 12-13-2006, 10:07 PM   #14
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi trickykid,

Quote:
No, if you use Postfix as your MTA, keep it running. Do not start sendmail. You're not paying attention. Sendmail is an MTA yes, but you can also use the sendmail command as a way to just send an email from the command line.
I did not start Sendmail after its installation. Neither I rebooted the server.


Later the server was turned off a while. (This server is for test only)

After freshly starting the server, I found Sendmail replacing Postfix

$ sudo /etc/init.d/sendmail status
Code:
MSP: is run via cron (20m)
MTA: 5263 /usr/sbin/sendmail-mta -Am -L sm-mta -bd -q10m
UID        PID  PPID  C STIME TTY          TIME CMD
root      5263     1  0 11:23 ?        00:00:00 sendmail: MTA: accepting connections
Daemon Status: (process 5263) Accepting connections

Current number of children: 0
QueueDir free disk space (in blocks): 72639568
Load average: 0
Child Process 5781 Status: console socket child

QUE: Same as MTA
$ sudo /etc/init.d/postfix status
No printout

$ sudo /etc/init.d/sendmail stop
Code:
Stopping Mail Transport Agent: sendmail.
$ sudo /etc/init.d/postfix start
No printout

Quote:
/usr/sbin/sendmail is most likely the path you will use in the script. And remove that /etc/init.d in your config path for the sendmail command. This script most likely has nothing to do with restarting of ANY services or daemons on your system. It's only going to report your new IP, not run services for you or restart them.
Edited /usr/local/bin/update.php

$ cat /usr/local/bin/update.php | grep sendmail
Code:
//* $Sendmail = "/path/to/sendmail -t -i";
$Sendmail = "/usr/sbin/sendmail -t -i";
$ sudo php /usr/local/bin/update.php
Code:
Warning: file() expects parameter 2 to be long, string given in /usr/local/bin/update.php on line 183

Warning: Invalid argument supplied for foreach() in /usr/local/bin/update.php on line 184
Failed with the same warning as before.


$ sudo /etc/init.d/sendmail start
Code:
Starting Mail Transport Agent: sendmail.
$ sudo php /usr/local/bin/update.php
Code:
Warning: file() expects parameter 2 to be long, string given in /usr/local/bin/update.php on line 183

Warning: Invalid argument supplied for foreach() in /usr/local/bin/update.php on line 184
Still failed with the same warning.

Remark:
Code:
 -t     Read  message  for recipients.  To:, Cc:, and Bcc: lines will be
              scanned for recipient addresses.  The Bcc: line will be  deleted
              before transmission.


-i     Ignore dots alone on lines by themselves in  incoming  messages.
              This should be set if you are reading data from a file.

Please advise how to get "postfix" back. It seems "sendmail" and "postfix" can't co-exsiting. TIA




B.R.
satimis
 
Old 12-13-2006, 10:11 PM   #15
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi trickykid,

Quote:
you most likely need to make sure that your IP is actually changing, which I doubt since most DHCP addresses are in 24 hour increments and that's if it does change.
I'll run cron to update the script on 24 hour base as well .

Since this server is for testing. It is not important to me. Tks for your advice.


B.R.
satimis
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job Thulemanden Linux - General 1 11-06-2006 11:40 AM
cron job somsahi Linux - Software 2 10-24-2006 05:40 AM
cron job? dr_zayus69 Linux - Newbie 14 12-01-2004 06:16 PM
cron job sanjith11 Linux - General 5 07-14-2004 01:06 PM
usin AWK in cron job to send dynamic ip via email digihlp Programming 2 12-10-2003 08:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration