Default-Start contains no runlevels, aborting

47,926

Solution 1

At the top of your /usr/local/bin/haltusbpower.sh script add something like this:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          haltusbpower
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Halts USB power...
### END INIT INFO

Solution 2

I had the same error message but it included a message about missing LSB tags and overrides.

I looked in htop and had multiple processes tailing the log from when I tested the service using /usr/local/bin/./MyService.sh start and /usr/local/bin/./MyService.sh stop. Once I killed these processes it was successful.

The start and stop test command was taken from http://www.jcgonzalez.com/ubuntu-16-java-service-wrapper-example

Share:
47,926

Related videos on Youtube

Volz
Author by

Volz

Updated on September 18, 2022

Comments

  • Volz
    Volz over 1 year

    I'm trying to check if this solution would help me with auto restarting after shutdown.

    But command sudo systemctl enable haltusbpower.service is followed by error:

    Synchronizing state of haltusbpower.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable haltusbpower update-rc.d: error: haltusbpower Default-Start contains no runlevels, aborting.

    My /usr/lib/systemd/system/haltusbpower.service file:

    [Unit]
    Description=haltusbpower
    Before=shutdown.target
    DefaultDependencies=no
    
    [Service]
    ExecStart=/usr/local/bin/haltusbpower.sh
    Type=oneshot
    RemainAfterExit=yes
    
    [Install]
    WantedBy=shutdown.target
    

    My /usr/local/bin/haltusbpower.sh script:

    #!/bin/bash
    for i in /sys/bus/usb/devices/*/power/control;
            do echo on > $i
    done
    

    It has execute option:

    karol@karol:~$ ls -l /usr/local/bin/haltusbpower.sh
    -rwxr-xr-x 1 root root 88 kwi 27 13:03 /usr/local/bin/haltusbpow
    

    Why enabling haltusbpower doesn't work? And what followed error means? I don't understand where to look for errors.

    • Andrew Wilkins
      Andrew Wilkins over 5 years
      I found my answer in this forum thread Long story short I had my old System V (service) file in my /etc/init.d directory so the system was trying to resolve the legacy code as well
  • Bugs Buggy
    Bugs Buggy over 5 years
    Can you add some explanation to this?
  • Emdadul Sawon
    Emdadul Sawon about 5 years
    "haltusbpower" should be replace with your service name.
  • eapo
    eapo about 2 years
    @BugsBuggy here is the official manual for LSBInitScripts: wiki.debian.org/LSBInitScripts