LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 08-29-2016, 06:44 PM   #16
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177

I'm back. I marked this as NOT SOLVED because apparently systemd cannot insure that a certain unit runs ahead of all others (see http://www.linuxquestions.org/questi...st-4175588181/). So, I've modified my existing and working /etc/init.d/rc.local script as follows to attempt to give me a shutdown:
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
# Short-Description: Run /etc/rc.local and /etc/rc.local_shutdown if they exist
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
        if [ -x /etc/rc.local ]; then
                [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
                /etc/rc.local
                ES=$?
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
}

do_stop() {
        if [ -x /etc/rc.local_shutdown ]; then
                [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local_shutdown)"
                /etc/rc.local_shutdown
                ES=$?
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        do_stop
        ;;
    stop|status)
        # No-op
        exit 0
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
What I did was add the "# Default-Stop: 0 6", and the do_stop() function. I then did:

$ updaterc.d -f rc.local remove
$ updaterc.d rc.local defaults

which did link the /etc/init.d/rc.local script to /etc/rc6.0/K01rc.local. The startup script still runs, but the rc.local_shutdown does not run.

Any idea why?

Last edited by mfoley; 08-29-2016 at 09:01 PM.
 
Old 08-29-2016, 09:23 PM   #17
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
more info. Actually, it appears that /etc/init.d is ignored. Modifying the /etc/init.d/rc.local script seems to have no effect, even putting debugging `echo` statments in there don't show anywhere even running by hand. Running by hand gives:
Code:
$ /etc/init.d/rc.local start
[ ok ] Starting rc.local (via systemctl): rc.local.service.
No echo statements appear and it says "via systemctl" and is using the rc.local.service. Somehow, the system seems to intercept the running of /etc/init.d script and passes control to systemd?!?!

Things were simpler in the olden days.
 
Old 08-31-2016, 01:28 AM   #18
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by mfoley View Post
it says "via systemctl" and is using the rc.local.service. Somehow, the system seems to intercept the running of /etc/init.d script and passes control to systemd?!?!
part of the transition process from init system to init system.

(on archlinux, which has been systemd for years, you don't get this)
 
Old 09-01-2016, 10:13 AM   #19
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Normally, I don't care what distros choose for various things as long as it works, doesn't get in my way, and lets me do what I need to do. I came up with a need to run a particular script first at shutdown, before any other shutdown processing. Apparently, systemd does not let me do that -- or at least I cannot figure it out, nor can about a dozen unix experts on this and other such sites. I did some research on what systemd brings to linux which I've posted here: http://www.linuxquestions.org/questi...ml#post5599000. In my opinion, it solves no real problems and, worse, it reverses the traditional "small independent modules" philosophy of Unix and creates a monolithic program of tightly coupled interdependencies that control many aspects of the OS normally done by individual daemons, thus making things 'systemd' difficult to impossible for lowly sysadmins to debug. In short, it Windows-izes Linux.

In any case, since systemd in not capable of doing the one simple thing I need, whereas sysvinit and Upstart could, I will do what I normally do with new programs that don't give me the features of what they replace and are more difficult to use: I will not use systemd. I've tested my needed shutdown script using the so call "old" init systems, and it works perfectly.

I've removed systemd from my Ubuntu 16.04, and it mostly works. Unfortunately, I get no login screen. I've posted a question about that http://www.linuxquestions.org/questi...-a-4175588444/. If Ubuntu 16.04 is so tightly coupled with systemd that it will not run without it, I will be changing distros.

Last edited by mfoley; 09-01-2016 at 10:19 AM.
 
Old 09-01-2016, 12:10 PM   #20
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by mfoley View Post
I cannot figure it out, nor can about a dozen unix experts on this and other such sites.
i wouldn't be so sure about that.
maybe those "experts" just couldn't be bothered to do your work?
also, in this thread 2 people tried to help you (sic) solving it with systemd, and 2 others (me, too) basically tried to clarify whether you are going about this the right way.

Last edited by ondoho; 09-01-2016 at 12:14 PM.
 
  


Reply

Tags
script, shutdown



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
Start-Up Script & Shutdown/Kill Script needed guggilamsandeep Red Hat 1 05-11-2011 08:58 AM
shutdown script CrashedAgain Linux - Software 5 04-08-2008 05:16 PM
script shutdown djaac Programming 2 01-24-2007 07:01 AM
script at the shutdown dominant SUSE / openSUSE 4 10-15-2005 07:43 AM
shutdown script Zolan Linux - Newbie 2 10-16-2004 09:02 PM

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

All times are GMT -5. The time now is 09:53 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