You are not logged in.
Hello:
In order to overcome (ie: eventually diagnose and maybe solve) a shutdown problem I have with my Sun Ultra 24 rig, I am currently shutting down with a script instead of the Xfce shutdown button (which calls the shutdown helper executable):
groucho@devuan:~$ cat /usr/bin/magicdown.sh
#!/bin/sh
# Shutdown system without the use of shutdownhelper
#
for i in s u o; do echo $i | sudo tee /proc/sysrq-trigger; sleep 6; done # halt
groucho@devuan:~$
In order to make it as easy to use as possible and also see what's going on, I launch it in terminal via a *.desktop file:
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=shutdown
Comment=Shuts down system bypassing shutdown helper
Exec=xfce4-terminal -x sudo /usr/bin/magicdown.sh
Icon=/usr/share/icons/gnome/32x32/actions/gnome-shutdown.png
Terminal=false
Path=
StartupNotify=false
GenericName=Shutdown
What I get on the terminal screen goes by too fast but with a video taken with a cell phone I could get a glimpse:
s
u
sudo: unable to open log file: /var/log/sudo.log: read only file system
o
I have a properly configured sudoers.d file that allows me to use the executable script:
[root@devuan groucho]# visudo -c
/etc/sudoers: parsed OK
/etc/sudoers.d/README: parsed OK
/etc/sudoers.d/user_dmesg: parsed OK
/etc/sudoers.d/user_linssid: parsed OK
/etc/sudoers.d/user_modprobe: parsed OK
/etc/sudoers.d/user_rescan: parsed OK
/etc/sudoers.d/user_shutdown: parsed OK
/etc/sudoers.d/user_updatedb: parsed OK
[root@devuan groucho]#
[root@devuan groucho]# cat /etc/sudoers.d/user_shutdown
groucho ALL= NOPASSWD: /sbin/halt, /sbin/shutdown, /sbin/reboot, /usr/bin/magicdown.sh
[root@devuan groucho]#
What I don't understand is not being able to open sudo.log as root.
Is there something wrong with the script?
Thanks in advance.
A.
Offline
Observation: you haven't set a path in the script.
2nd guess: trying to write a log during shutdown might not work.
Regards, Rolf
Offline
Hello:
Observation: you haven't set a path ...
No, that's not it.
It seems the path is set in the environment variables.
groucho@devuan:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
groucho@devuan:~$
I can run the script directly from the prompt with or without sudo.
With sudo it executes directly (because sudoers) without, it asks me for the PW twice.
... trying to write a log during shutdown might not work.
Seems that's it. =-)
From https://it.toolbox.com/question/file-sy … ode-061114
The filesystem will usually go into read-only while the system is running if ...
... an emergency read-only remount is requested via Alt+SysRq+U.
So it is normal that sudo cannot write to it's log file after U is called.
Thanks for your input.
Best,
A.
Offline
rolfie wrote:Observation: you haven't set a path ...
No, that's not it.
It seems the path is set in the environment variables.groucho@devuan:~$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games groucho@devuan:~$
Unfortunately, that won't work. This is the path valid in your home only. Starting a shell requires setting path in the shell script or to use the full path to any command. Example from one of my scripts:
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:
Rolf
Offline
Hello:
... that won't work. This is the path valid in your home only.
I understand (from my old DOS days) the importance and need for setting the PATH variable in a script.
But my *.bat days are long gone and I have no bash skills worth mentioning.
Starting a shell requires setting path in the shell script or to use the full path to any command.
Undoubtedly, it is best practise to do so.
But this script works and has the same result whether I add the line you suggested to it or not.
I expect it is so because it (the needed PATH) is already set elsewhere:
groucho@devuan:~$ printenv | grep -i path
GLADE_CATALOG_PATH=:
GLADE_MODULE_PATH=:
GLADE_PIXMAP_PATH=:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
groucho@devuan:~$
In any case, I will start adding the PATH to every script I attempt to write.
Thanks for your input.
A.
Offline