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

Notices


Reply
  Search this Thread
Old 09-08-2023, 09:21 AM   #1
mistfire
Member
 
Registered: Jun 2021
Posts: 45

Rep: Reputation: Disabled
Exclamation run interactive scripts on shutdown


How to run interactive yesno dialog when slackware is shutting down. The dialog works but unable to interact the dialog using keyboard. Is there any workaround for allowing keyboard input when dialog is shown during system shutdown?
 
Old 09-08-2023, 09:31 AM   #2
drumz
Member
 
Registered: Apr 2005
Location: Oklahoma, USA
Distribution: Slackware
Posts: 907

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
What are you actually trying to accomplish? In almost all cases when a user wants the computer to shut down, he really wants it to shut down with asking again and again.
 
Old 09-08-2023, 10:53 AM   #3
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 677
Blog Entries: 1

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Quote:
Originally Posted by mistfire View Post
How to run interactive yesno dialog when slackware is shutting down. The dialog works but unable to interact the dialog using keyboard. Is there any workaround for allowing keyboard input when dialog is shown during system shutdown?
The "best" way to have what you want is to call your script from /etc/rc.d/rc.6 in line 79-80.
I dont know what you want to do... but in my case I have some scripts running during shutdown-restart from there and working very good. one of them is eliloconfig which running IF kernel was upgraded in the current session by slackpkg and I forgot to run eliloconfig and keybord works fine in dialog mode...

Note that when sysvinit-scripts rebuild or upgrade from Pat you have to keep your mind to not overwrite rc.6... or you must do it, then edit it again to place your script command in line 79-80...
But as I said idk what you want to do exactly...maybe this risking solution its not good for you.

Last edited by rizitis; 09-08-2023 at 10:56 AM. Reason: fix typos
 
1 members found this post helpful.
Old 09-08-2023, 11:14 AM   #4
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 934

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
Another option would be in /etc/rc.d/rc.local_shutdown
 
2 members found this post helpful.
Old 09-08-2023, 11:47 AM   #5
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 677
Blog Entries: 1

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Quote:
Originally Posted by Paulo2 View Post
Another option would be in /etc/rc.d/rc.local_shutdown
Is it sure that keyboard will work properly to finish yesno dialog questions and commands when script is called from rc.local? I think no but dependents what exactly the user want to do...
I think rc.local_shutdown is the best option to stop daemons and services during shutdowns.
 
Old 09-08-2023, 01:46 PM   #6
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 934

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
Quote:
Originally Posted by rizitis View Post
Is it sure that keyboard will work properly to finish yesno dialog questions and commands when script is called from rc.local? I think no but dependents what exactly the user want to do...
I think rc.local_shutdown is the best option to stop daemons and services during shutdowns.
I think it's a matter of try the proposed options
 
1 members found this post helpful.
Old 09-08-2023, 02:12 PM   #7
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 934

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
In a -current VirtualBox vm, this is the result using /etc/rc.d/rc.local_shutdown

/etc/rc.d/rc.local_shutdown
Code:
#!/bin/bash
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

echo '$USER:' >/tmp/local_shutdown
echo $USER >>/tmp/local_shutdown
echo -e '\n$PATH:' >>/tmp/local_shutdown
echo $PATH >> /tmp/local_shutdown
echo -e '\nset:' >>/tmp/local_shutdown
set >>/tmp/local_shutdown
echo -e '\nenv:' >>/tmp/local_shutdown
env >>/tmp/local_shutdown
dialog --textbox /tmp/local_shutdown 0 0
dialog --yesno foobar 0 0
/tmp/local_shutdown
Code:
$USER:


$PATH:
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

set:
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist:complete_fullquote:extquote:force_fignore:globasciiranges:globskipdots:hostcomplete:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=([0]="0")
BASH_LOADABLES_PATH=/usr/local/lib/bash:/usr/lib/bash:/opt/local/lib/bash:/usr/pkg/lib/bash:/opt/pkg/lib/bash:.
BASH_SOURCE=([0]="/etc/rc.d/rc.local_shutdown")
BASH_VERSINFO=([0]="5" [1]="2" [2]="15" [3]="1" [4]="release" [5]="x86_64-slackware-linux-gnu")
BASH_VERSION='5.2.15(1)-release'
BOOT_IMAGE=generic
CONSOLE=/dev/console
DIRSTACK=()
EUID=0
GROUPS=()
HOME=/
HOSTNAME=current.bfw
HOSTTYPE=x86_64
IFS=$' \t\n'
INIT_VERSION=sysvinit-3.08
MACHTYPE=x86_64-slackware-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
PIPESTATUS=([0]="0")
PPID=1382
PREVLEVEL=3
PS4='+ '
PWD=/
RUNLEVEL=0
SHELL=/bin/sh
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=3
TERM=linux
UID=0
_='\nset:'

env:
SHELL=/bin/sh
RUNLEVEL=0
PWD=/
HOME=/
TERM=linux
INIT_VERSION=sysvinit-3.08
SHLVL=3
BOOT_IMAGE=generic
CONSOLE=/dev/console
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
PREVLEVEL=3
_=/usr/bin/env
 
1 members found this post helpful.
Old 09-08-2023, 03:56 PM   #8
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 677
Blog Entries: 1

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Ok first thank you for the lesson

Second and of topic, I move it to /etc/rc.d/rc.local and after I removed
Code:
dialog --textbox /tmp/local_shutdown 0 0
dialog --yesno foobar 0 0
then I redirect it to
Code:
echo '$USER:' > /etc/sys
etc...
I test it in init4 with gdm and np found.
The interesting this way for me is that, I know what kernel I m running generic or huge in current session.
Code:
cat /etc/sys | grep BOOT
And a lot of other useful infos can be tracked this way easy if needed...
Thank you!
 
Old 09-09-2023, 07:28 AM   #9
mistfire
Member
 
Registered: Jun 2021
Posts: 45

Original Poster
Rep: Reputation: Disabled
Hello I have some observations.

When I logged into command line without launching desktop environment and run reboot/poweroff (even loginctl reboot/poweroff) the interactive script works. Both dialog works and the keyboard input works. However when reboot/poweroff was launched from desktop environment. The dialog works but the keyboard does not work to select option on the dialog.
 
Old 09-09-2023, 08:23 AM   #10
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 934

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
I didn't try, but Xfce has an option to run scripts at shutdown.
Settings Manager > Session and Startup > Application Startup > on shutdown
 
Old 09-09-2023, 09:13 AM   #11
0XBF
Member
 
Registered: Nov 2018
Distribution: Slackware
Posts: 781

Rep: Reputation: 895Reputation: 895Reputation: 895Reputation: 895Reputation: 895Reputation: 895Reputation: 895
I appended this test script to the end of my '/etc/rc.d/rc.local_shutdown' script...
Code:
dialog --title "Shutdown Question" \
--backtitle "rc.6 wants to ask you questions..." \
--yesno "Are you sure you want to shutdown?" 6 38
reply=$?
case $reply in
   0) echo "Okay lets shutdown";;
   1) echo "Haha, we're still running rc.6 baby!";;
   255) echo "[ESC] key pressed, but we're still running rc.6!";;
esac
and it does what its expected to do: print a yesno dialog box and wait for the user's input, triggered when rc.6 hooks rc.local_shutdown.

It works with restart & shutdown from plasma, xfce, gnome, and tty1. I'm not sure why you would get any different.
(Tested on Slackware 15.0)

Last edited by 0XBF; 09-09-2023 at 09:28 AM. Reason: Added install type
 
2 members found this post helpful.
Old 09-09-2023, 06:27 PM   #12
mistfire
Member
 
Registered: Jun 2021
Posts: 45

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by 0XBF View Post
I appended this test script to the end of my '/etc/rc.d/rc.local_shutdown' script...
Code:
dialog --title "Shutdown Question" \
--backtitle "rc.6 wants to ask you questions..." \
--yesno "Are you sure you want to shutdown?" 6 38
reply=$?
case $reply in
   0) echo "Okay lets shutdown";;
   1) echo "Haha, we're still running rc.6 baby!";;
   255) echo "[ESC] key pressed, but we're still running rc.6!";;
esac
and it does what its expected to do: print a yesno dialog box and wait for the user's input, triggered when rc.6 hooks rc.local_shutdown.

It works with restart & shutdown from plasma, xfce, gnome, and tty1. I'm not sure why you would get any different.
(Tested on Slackware 15.0)
What is the terminal? Is it /dev/console or /dev/tty?
 
  


Reply



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
emacs lisp: naming convention for interactive/non-interactive function pairs hydraMax Programming 6 05-31-2013 12:01 AM
[SOLVED] Of interactive and non-interactive shells. stf92 Linux - Newbie 1 10-05-2011 12:37 PM
Interactive and non-interactive shells? Tim356 Linux - Newbie 7 11-05-2008 10:32 PM
BASH - How to open an interactive script from a non interactive script..... OldGaf Programming 4 06-29-2008 04:34 PM
interactive and non-interactive shell linuxjamil Programming 3 09-03-2006 08:42 PM

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

All times are GMT -5. The time now is 11:43 AM.

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