rc0.d & rc6.d script not running in Amazon EC2( it does curl connection)
Asked Answered
F

0

6

I have fired an EC2 instance in Amazon WebServices. Also I have created a service in /etc/init.d folder it is called shutdownSocketServer I want it to get called on shutdown and reboot.

I have added it to chkconfig -add, and I have checked it is defined with

sudo chkconfig --list | grep shutdownSocketServer
shutdownSocketServer    0:on    1:off   2:off   3:off   4:off   5:off   6:on

The script is :

#!/bin/bash                                                                      
# chkconfig: 06 001 001
# description: Foo server

. /etc/init.d/functions
sudo touch /var/lock/subsys/shutdownSocketServer

start(){
    EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
    echo "$EC2_INSTANCE_ID"

    curl "http://mywebservice.com/Server/functions/SocketUpdater.php?   estado=shutdown&instance_id=$EC2_INSTANCE_ID"
}

stop(){
    echo "stopping"
}

### main logic ###
case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    status)
        status
    ;;
    restart|reload|condrestart)
        stop
        start
    ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac 
exit 0

So my problem is I think that network is not accesible when EC2 is shutting down. How can avoid that? How can I check it?

Fleury answered 17/7, 2014 at 11:5 Comment(1)
Your stop function just says "Stopping", so why does the network availability mater?Tashia

© 2022 - 2024 — McMap. All rights reserved.