LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 01-25-2017, 06:12 PM   #1
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
init.d kill script help please


Hi

I am on MX distro that does not use systemd but still on traditional init

I have read
https://www.behnke.io/fedora-17-on-a...t-on-shutdown/

and attempted to modify it for MX so it reads

Quote:
#! /bin/bash

### BEGIN INIT INFO
# Provides: haltusbpower
# Required-Start:
# Required-Stop:
# Default-Start: 0
# Default-Stop: 5 6
# Short-Description: Halt USB Powersave mode
# Description: A script to halt usb power control.
### END INIT INFO


# Bus list for the runtime power management module.
buslist="usb"

# See how we were called.
case "$1" in
start)
echo "USB bug fix active"
#no-op on startup
;;
stop)
echo "Turning off USB Power Control"
for bus in $buslist; do
for i in /sys/bus/$bus/devices/*/power/control; do
echo on > $i
done
done
;;
*)
echo "Usage: /etc/init.d/haltusbpower {start|stop}"
exit 1
;;
esac
exit 0
in various attempts of using either chkconfig or update-rc.d or insserv
I got various errors including the reason for the current start stop script stuff above

Code:
chkconfig --add haltusbpower
insserv: warning: current start runlevel(s) (0) of script `haltusbpower' overrides LSB defaults (S).
insserv: warning: current stop runlevel(s) (5 6) of script `haltusbpower' overrides LSB defaults (0 6).
haltusbpower              0:on   1:off  2:off  3:off  4:off  5:off  6:off
In particular I thought I should be using 0 for the default stop but when I did
I still do not get a sym link to rc0.d as a kill script

so far they are are all start scripts

Code:
ls -al /etc/rc0.d/ | grep usb
lrwxrwxrwx   1 root root    22 Jan 26 07:56 S01haltusbpower -> ../init.d/haltusbpower
in running as root powers sysv-rc-conf
I have a check against run level 0

if at haltusbpower I press the symbol to start or stop the service
I get the respective echo message....suggesting the start or stop service is working correctly.....manually

#####################################
what I don't have is the correct script to act on shut down as a kill script

any suggestions?

in some attempts insserv has shown sym links

/etc/init.d/.depend.start and its .stop both show haltusbpower

I was expecting to see it only in .depend.stop

thanks for reading

Last edited by aus9; 01-25-2017 at 06:17 PM.
 
Old 01-26-2017, 12:07 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You might want to look at other /etc/init.d scripts on your MX for how they do it (not all init scripts are done the same way on different distros and/or even major releases of distros).

One thing that stands out to me in what you posted:
# Default-Start: 0
# Default-Stop: 5 6

Since 0 is shutdown and 6 is reboot I'd think you'd want to do the stop in those run levels.

You'd likely want to do the start in run levels 2,3,4,5.

If you modify your setting in init script changing those 2 lines and rerun chkconfig commands does it make the links?

By the way you CAN simply do your own links with "ln -s" specifying source and target.

Last edited by MensaWater; 01-27-2017 at 08:49 AM.
 
Old 01-26-2017, 04:55 PM   #3
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Original Poster
Rep: Reputation: Disabled
MensaWater

yes I looked at the halt script which had only this header
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 0

runlevel 0 me thinks is the shutdown as per
https://wiki.debian.org/RunLevel

but I see you are saying that the script for the normal user who starts a graphical boot up should have that script start up.

interestingly to me, I modified my header to read

# chkconfig: 0 99 1

### BEGIN INIT INFO
# Provides: haltusbpower
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 0

then with root powers
Code:
chkconfig --add haltusbpower
insserv: warning: current start runlevel(s) (5) of script `haltusbpower' overrides LSB defaults (empty).
insserv: warning: current stop runlevel(s) (0 6) of script `haltusbpower' overrides LSB defaults (0).
haltusbpower              0:off  1:off  2:off  3:off  4:off  5:on   6:off
then changed header to read
Quote:
# chkconfig: 0 99 1

### BEGIN INIT INFO
# Provides: haltusbpower
# Required-Start:
# Required-Stop:
# Default-Start: 5
# Default-Stop: 0 6
then as already root
Code:
chkconfig --add haltusbpower
haltusbpower              0:off  1:off  2:off  3:off  4:off  5:on   6:off
the dot files /etc/init.d/ .depend.start and .depend.stop show haltusbpower is in there

and

the sym links in /etc...rc5.d..rc6.d..rc0.d are there.

I can't mark this as solved at the moment as it was for another MX user, and that user will need to see if it works

but many thanks for now

Last edited by aus9; 01-26-2017 at 05:16 PM.
 
1 members found this post helpful.
Old 01-26-2017, 05:23 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
I think you need remove the links that were previously installed. You can do that by running the following:
Code:
# update-rc.d haltusbpower remove
# update-rc.d haltusbpower defaults
I don't have checkconfig installed to try but I guess --del serves the same purpose.
 
Old 01-27-2017, 08:54 AM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by aus9 View Post
runlevel 0 me thinks is the shutdown as per
https://wiki.debian.org/RunLevel
Yes sorry, I misspoke, 0 is indeed shutdown and I've edited my original post. Glad you caught that I was saying both of those meant it was going down so should be the "stop" levels in your init scripts. Single user by the way is run level 1 - usually a lot less is started in run level 1 as the reason you're doing that run level is to fix things which is why I suggested you could do run levels 2,3,4 & 5 for the start. Doing the start in just one of those run levels is fine.
 
Old 01-27-2017, 05:13 PM   #6
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Original Poster
Rep: Reputation: Disabled
member has solved it by editting the halt script and following the advice as shown here

http://askubuntu.com/questions/13214.../394980#394980
 
  


Reply

Tags
init.d chkconfig insserv



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone kill INIT process? u4u Linux - General 2 09-15-2014 05:42 PM
Kernel panic - not syncing: Attempted to kill init, Pid: 1, comm: init Not tainted 2. morriset Linux - Kernel 3 07-02-2011 08:04 AM
/sbin/init: Kernel panic - not syncing: Attempted to kill init! jalejo08 Linux - Kernel 7 07-02-2009 01:16 PM
Attempted to kill init? netnamnetviet Linux - Server 2 03-16-2009 10:43 AM
kill init! Treat84 Linux - Software 1 08-04-2003 03:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 02:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration