sim_tcr
Posts: 360
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore

startup script (/etc/init.d) help.

Tue Jan 01, 2013 7:13 am

Hello,
I use noip2 (version 2.1.9) agent on raspbian wheezy. Every time my system reboots I have to start noip2 manually. Right now I start noip by using command,

Code: Select all

sudo noip2
I would like to get noip2 start automatically on boot.
Can some one please provide a script which I can put in my /etc/init.d directory so that when my system is booting, noip comes up automatically and when system is shutdown or reboot, noip shutdown gracefully.

Thanks in advance,
Simon Mandy

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am

Re: startup script (/etc/init.d) help.

Tue Jan 01, 2013 7:27 am

I think it's just adding them to here

http://www.raspberrypi.org/phpBB3/viewt ... al#p247079
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

User avatar
LetHopeItsSnowing
Posts: 357
Joined: Sat May 26, 2012 6:40 am
Location: UK

Re: startup script (/etc/init.d) help.

Tue Jan 01, 2013 8:28 am

See this blog post, its exactly what your looking for.
http://www.stuffaboutcode.com/2012/06/r ... rt-up.html
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"

sim_tcr
Posts: 360
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore

Re: startup script (/etc/init.d) help.

Tue Jan 01, 2013 9:28 am

LetHopeItsSnowing wrote:See this blog post, its exactly what your looking for.
http://www.stuffaboutcode.com/2012/06/r ... rt-up.html
Thank you.

I created the /etc/init.d/noip with below content. Made the script executable.

Code: Select all

 #! /bin/sh
# /etc/init.d/noip


# If you want a command to always run, put it here


# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting noip"
    # run application you want to start
    /usr/local/bin/noip2
    ;;
  stop)
    echo "Stopping noip"
    # kill application you want to stop
    killall noip2
    ;;
  *)
    echo "Usage: /etc/init.d/noip {start|stop}"
    exit 1
    ;;
esac


exit 0
When I did,

Code: Select all

sudo update-rc.d NameOfYourScript defaults
I got below errors,

Code: Select all

pi@raspisimon ~ $ sudo update-rc.d noip defaults
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'noip' missing LSB tags and overrides
insserv: script ups-monitor: service ups-monitor already provided!
insserv: There is a loop between service minidlna and noip if stopped
insserv:  loop involving service noip at depth 2
insserv:  loop involving service minidlna at depth 1
insserv: Stopping noip depends on minidlna and therefore on system facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
And after reboot noip did not come up too. How to fix it?

I tried adding my command to start noip (sudo noip2) to /etc/rc.local and then rebooted the system. This time noip started automatically.
Is noip starting after I login to machine or it starts when system reboots and before I login?

efflandt
Posts: 359
Joined: Mon Dec 03, 2012 2:47 am
Location: Elgin, IL USA

Re: startup script (/etc/init.d) help.

Tue Jan 01, 2013 11:01 am

Anything you put in /etc/rc.local runs after the other init scripts, whether you login or not. And sudo is NOT needed, because anything in rc.local runs as root anyway.

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm

Re: startup script (/etc/init.d) help.

Tue Jan 01, 2013 11:07 am

Just do what the error message tells you to, add LSB tags to the beginning of the init file. Something like this should work:

Code: Select all

### BEGIN INIT INFO
# Provides:          noip2
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

sim_tcr
Posts: 360
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore

Re: startup script (/etc/init.d) help.

Tue Jan 01, 2013 11:29 am

azeam wrote:Just do what the error message tells you to, add LSB tags to the beginning of the init file. Something like this should work:

Code: Select all

### BEGIN INIT INFO
# Provides:          noip2
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
That fixed it. I am set now. I removed sudo noip2 from /etc/rc.local and added above entry to the beginning of /etc/init.d/noip and did sudo update-rc.d noip default I saw below message,

Code: Select all

pi@raspisimon ~ $ sudo update-rc.d noip defaults
update-rc.d: using dependency based boot sequencing
insserv: script ups-monitor: service ups-monitor already provided!
Rebooted the machine and noip came up automatically.
Thanks to all who replied.

Return to “General discussion”