I created a script to add a bunch of packages and update the system on a fresh install. Here's the relevant part of my init.d script that is giving me trouble:

# Provides:          update
# Required-Start:    $local_fs $syslog $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       Update my system

. /lib/lsb/init-functions

case "$1" in
    log_daemon_msg "Starting update"

    apt-get --assume-yes update &&
    apt-get --assume-yes dist-upgrade

    log_end_msg $?
    echo "Usage: $0 start" >&2
    exit 2

exit 0

I made the script executable and registered it with sudo update-rc.d update defaults. When I check on it after a reboot with sudo service update status, I get all of the package repositories failing to resolve:

W: Failed to fetch http://.../Release.gpg  Temporary failure resolving '...'
W: Some index files failed to download. They have been ignored, or old ones used instead.

and the init.d script ends here with code=exited. However, adding a sleep 10 to the script before running the apt commands fixes my issue. I would have thought that adding $network to my # Required-Start list would have fixed this issue by itself. Is there a better way of dealing with this issue?

I'm running this on Raspian Jessie 2016-03-18 if that makes a difference, but I have a feeling it doesn't.


adding one or two more services to start after the network service as part of the requirement before running your update service should add more productive delay rather than adding a sleep 10 in your script.

  • Thanks for the idea, but that still seems like a workaround to me. Since sleep doesn't actually use any resources while it's running, this would achieve about the same thing while adding complexity. – ubomb May 23 '16 at 14:29
  • sleep is sensible way to do it if you don't have anymore service awaiting to get started. you can try to adjust your waiting time to a lower value as the problem is clearly on network initialization stage. – RDCortez May 24 '16 at 1:01
  • Right, but I'm wondering why it isn't already waiting for the network initialization since it has the # Required-Start: $network directive. – ubomb May 24 '16 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.