How to conform to update-rc.d with LSB standard?

Posted by user34881 on Server Fault See other posts from Server Fault or by user34881
Published on 2010-02-15T16:10:17Z Indexed on 2012/12/19 17:04 UTC
Read the original article Hit count: 284

Filed under:
|
|
|

This is a migrated question from stackoverflow, as I was told, this is the place for it to be. http://stackoverflow.com/questions/2263567/how-to-conform-to-update-rc-d-with-lsb-standard

I have set up a simple script to back up some directories. While I haven't had any problems setting up the functionality, I'm stuck with adding the script to rcX.d dir's using update-rc.d.

My script:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          backup
# Required-Start:    backup
# Required-Stop:     
# Should-Stop:       
# Default-Start:     0 6
# Default-Stop:      
# Description:       Backs up some dirs
### END INIT INFO

check_mounted() {
    # Check if HD is mounted
}

do_backup() {
 if check_mounted; then
  # Some rsync statements.
 fi
}

case "$1" in
  start)
 do_backup
 ;;
  restart|reload|force-reload)
 echo "Error: argument '$1' not supported" >&2
 exit 3
 ;;
  stop|"")
 # No-op
 ;;
  *)
 echo "Usage: backup [start]" >&2
 exit 3
 ;;
esac

:

Using update-rc.d backup start 10 0 6 . I get the following warnings and errors:

update-rc.d: warning: backup start runlevel arguments (none) do not match LSB Default-Start values (0 6)
update-rc.d: warning: backup stop runlevel arguments (0 6.) do not match LSB Default-Stop values (none)
update-rc.d: error: start|stop arguments not terminated by "."

The syntax I try to use is the following:

update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .

Google wasn't that helpful at finding a solution. How can I correctly set up a script and add it via update-rc.d?

I'm using Ubuntu 9.10.

UPDATE

Using update-rc.d backup start 10 0 6 . stop 10 0 . the error disappears. The warnings about default values persists:

update-rc.d: warning: backup start runlevel arguments (none) do not match LSB Default-Start values (0 6)
update-rc.d: warning: backup stop runlevel arguments (0 6 0 6) do not match LSB Default-Stop values (none)

It even is added to the appropiate rcX-dirs but it still does not get executed...

© Server Fault or respective owner

Related posts about ubuntu

Related posts about shell