Inclussion to init.d assistance


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Inclussion to init.d assistance
# 1  
Old 10-11-2002
Inclussion to init.d assistance

Hi all,

Am trying to have an email sent on start up advising that the system has been reset.
During the week the system reset itself and no email was received, below is an extract of the file /etc/init.d/sendmail . And I'm stumped to understand why the email wasn't sent.

Can anyone see why things didn't go to plan as I'd thought they would?

Code:
#
# SendMail startup/shutdown script.
#
case $1 in
    start)
        set -- `who -r`
        if [ "$9" = "S" ]               # run only during boot time
        then
            if [ -x /usr/lib/sendmail ]
            then
                if [ ! -f /etc/sendmail.pid ]
                then
                        touch /etc/sendmail.pid
                fi

                /bin/su root -c "/usr/lib/sendmail -bd -q1h" 2> /dev/null

                # *******************************************************
                # Addition Included by C.Young (----) - 07/11/2002.
                # - Advise ---- Operations via eMail that the system
                #   has been restarted.
                # - eMail sent to ---- Operations Mgr and Staff.
                # *******************************************************

                /bin/su root -c "mail -s'* EVEREST HAS BEEN REBOOTED *' \
                                 ops@????.com,dhoey@????.com.au   \
                                 < /---_stats/admin/reboot.notice "

            fi
        fi
        ;;

    stop)
        if [ -x /bin/ps -a -x /bin/kill ]
        then
            #
            # su root to set luid (required for systems with SECLUID set)
            #
            pid=`su root -c "ps -e" \
                | sed -n -e '/ sendmail$/s/^ *\([1-9][0-9]*\) .*$/\1/p'`

            if [ -n "$pid" ]
            then
                kill $pid
            fi
        fi
        ;;

    *)
        echo "Usage: $0 {start|stop}" >&2
        ;;
esac

# 2  
Old 10-11-2002
DOH !!

Just noticed that the email address ops@????.com was not complete ... missing the .au on the end.
# 3  
Old 10-11-2002
Well, I've rebooted the server and sadly waited in vain - no email.

Can anyone suggest why this isn't happening?
# 4  
Old 10-11-2002
Restore the system startup script to its original state. Create your own little script in init.d to send a mail message at reboot time. Link it into rc2.d and give it a high S number so that it is the last thing to run.
# 5  
Old 10-11-2002
Thanks Perderabo, will try it when I come back into work tomorrow.
# 6  
Old 10-12-2002
Forgot to set the script in init.d .

Set it up in /etc/rc2.d directly (S99xATIN#1 - sticks out like a sore thumb) and works a treat.

Still learning, but why include it into /etc/init.d and link it to the /etc/rc2.d directory - what are the benifits of doing that?
# 7  
Old 10-12-2002
Most of the init scripts will have two links: a S.... to start up and a K.... to shut down the service. By copying a new script to, say, init.d/sendmail, you update both the startup and shutdown script at the same time. All you can do the update without knowing at which run level the service starts. Someone might have disabled sendmail by removing the S and K links, but you can still update the script because it's still in init.d. And if someone did that, (remove the S and K links), because the script still exists in init.d, it can be easily re-enabled. Mostly though, it's a standard of sorts and you shouldn't break a standard with a good reason.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

init-script failing because of /etc/rc.d/init.d/functions

I encountered a problem on one of our database servers. OS: CentOS 5.5 final Kernel: 2.6.18-238.5.1.el5.028stab085.2 (OpenVZ kernel) We wrote some DB-Start/Stop-scripts ("/db2/admin/scripts_dba/start_services.ksh" and ".../stop_services.ksh") to start the database instances. (Database... (1 Reply)
Discussion started by: bakunin
1 Replies

2. Solaris

What is the diffe b/w init s and init S

i did my research in finding the answer but couldn't find right one. Please give your inputs. (6 Replies)
Discussion started by: ranumala
6 Replies

3. UNIX for Advanced & Expert Users

Problem on init 0, execution is the same with init 6

Hi, I am experiencing a weird thing on my SUNFIRE machine with Solaris 9 OS. When I do init 0 to shutdown the machine to go to ok prompt, what it did was shutdown and reboot like an init 6 command do. I did check the corresponding rc scripts that were involved with init 0 and compared with rc... (2 Replies)
Discussion started by: Yenthanh
2 Replies

4. Solaris

/etc/rc2.d vs /etc/init.d

Hi, Can somebody please tell me the difference between the files in /etc/rc2.d and those in /etc/init.d? I am asking because on one system, I got a sysedge file S99.sysedge under /etc/rc2.d and it has a soft link to the /etc/init.d/sysedge. It would be my understanding that the one under... (6 Replies)
Discussion started by: Pouchie1
6 Replies

5. Red Hat

Difference between 'init s' and 'init 1'

What is the difference between 'init s' and 'init 1'. I know that both will work to change the current run level to single user mode. Is there any difference in those two commands? (5 Replies)
Discussion started by: praveen_b744
5 Replies

6. Linux

How to I change init levels after typing init 1

Dear all, I typed in init 1 on my redhat box as root and according to wikipedia (http://en.wikipedia.org/wiki/Runlevel): 1 Single-User Mode Does not configure network interfaces, start daemons, or allow non-root logins So now I can't connect back to it. How do I change the init back to 3?... (8 Replies)
Discussion started by: z1dane
8 Replies

7. UNIX for Dummies Questions & Answers

About init

I know if a parent process exits before its child, the last one becomes orphan for a while and then is added to the children of Init process. I'd like to know deeper 1 how the orphan becomes init process, 2 how init knows that from a some point on it has another child. Thank you in advance. (2 Replies)
Discussion started by: Puntino
2 Replies

8. Solaris

different between /sbin/init and /usr/sbin/init

root@test09 # ls -al /sbin/init -r-xr-xr-x 1 root sys 550000 Jun 29 2002 /sbin/init root@test09 # ls -al /usr/sbin/init -r-xr-xr-x 1 root sys 37100 Jun 29 2002 /usr/sbin/init (2 Replies)
Discussion started by: userking
2 Replies

9. UNIX for Advanced & Expert Users

Init 6 & Init 0 problem

Hi Expert, I have encountered some problem with my SUN system. Everytime when i issue command #init 6 OR #init 0 it just logout and prompt for login again instead of rebooting the server when run init 6 and system shutdown when run init 0.. I can only reboot the system using reboot ... Was... (6 Replies)
Discussion started by: sc2005
6 Replies

10. UNIX for Dummies Questions & Answers

init.d

I have written a daemon and want to make sure that it starts up again after the machine is re-started so I can quit manually doing it. Problem is I'm having difficulty understanding what to do with the init.d Any help would be appreciated! (1 Reply)
Discussion started by: BC_Kevin
1 Replies
Login or Register to Ask a Question