Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-11-29 10:37:58

Devuan
Member
Registered: 2018-01-10
Posts: 27

Problem with shutdown script

Hello:

I shut down my Devuan Beowulf system with a script called from a launcher which I set up within the panel of my Xfce desktop:

This is the script:

#!/bin/sh
# added to shutdown directly - no shutdown helper 
PATH=/sbin:/bin:/usr/sbin:/usr/bin:
#
sync && sudo ethtool -s eth0 wol d && sudo rmmod -s -v e1000e && sudo shutdown -h now

This was put in place to troubleshoot a series of e1000e driver issues I have.

This is the launcher command line:

xfce4-terminal -x sudo /usr/bin/shutdown.sh

This has been working perfectly well for the longest time.
Some time ago I set up Pihole in an autostarted Vbox virtual machine but although it seems to start up properly it does not shutdown gracefully.

ie:

sudo shutdown -h now

... takes effect before the virtual machine has completely shut down.

So the idea is to send the virtual machine the shutdown command, wait 5s and then execute the shutdown script.
Simple if not elegant.

As VBox gives members of the [c]vboxusers[/c] group permission to start and shutdown a virtual machine, I cannot add the shutdown command to the original shutdown script (see above) called from the launcher because this script needs [c]sudo[/c] to run.
ie: the VBox virtual machines belong to [c]vmusers[/c] and not to [c]root[/c].

So I add the virtual machine shutdown script + a 5s sleep to the launcher command line.

ie:

vboxmanage controlvm "madmax ascii" poweroff && sleep 5s && sudo /usr/bin/shutdown.sh

Works properly executed from an open terminal but not when using the launcher.

ie:

xfce4-terminal -x vboxmanage controlvm "madmax ascii" poweroff && sleep 5s && /usr/bin/shutdown.sh 

Seems that adding ...

vboxmanage controlvm "madmax ascii" poweroff && sleep 5s

... has the effect of only shutting down the virtual machine, the rest of the command line does not have any effect.

Cannot figure out what I'm doing wrong.

Any ideas?

Thanks in advance.

D.

Last edited by Devuan (2021-11-29 10:38:19)

Offline

#2 2021-11-29 23:19:44

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: Problem with shutdown script

You probably have to wrap the command for the launcher:

sh -c 'vboxmanage controlvm "madmax ascii" poweroff && sleep 5s && sudo /usr/bin/shutdown.sh'

for the terminal

xfce4-terminal -x sh -c 'vboxmanage controlvm "madmax ascii" poweroff && sleep 5s && /usr/bin/shutdown.sh'

Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#3 2021-11-30 14:32:11

Devuan
Member
Registered: 2018-01-10
Posts: 27

Re: Problem with shutdown script

Hello:

Misko_2083 wrote:

... wrap the command for the launcher:

sh -c 'vboxmanage controlvm "madmax ascii" poweroff && sleep 5s && sudo /usr/bin/shutdown.sh'

Quite so.  =^)

I replaced

sleep 5s

with

wait

Much better as the command waits until all pending background jobs are completed.
Which could end up being more/less than an arbitrary length of time or vary for any reason.

Thank you very much for your input.

Best,

D.

Offline

Board footer

Powered by FluxBB