[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: to run a "interactive" scritp before shutting down the system




On Dec 7, 2006, at 4:51 AM, Godofredo Fdez. Requena wrote:

El Jueves 07 Diciembre 2006 11:51, Grzegorz escribió:
did you consider creating init script, which would be executed at
switching to runlevels 0 (poweroff) and 6 (reboot)???
see `man update-rc.d` and /etc/init.d/skeleton (sample script)
kde has graphical manager to init scripts: ksysv

OK, I have already tested this option but it has two "problems":
	
1.- I only want that a "specific user" of the system runs the script, if I put this script in runlevel0 every user of the system should "talk with the
	script".

Check the environment for what user is calling the script, from inside the script, and die if it's not the "authorized" user.

if [ `/usr/bin/whoami` != "bob" ] ; then
echo This program must be run as user *bob*!
exit 1
fi


2.- The script have to be executed by "this specific user" not by "root" to
	avoid security problems.

sudo could handle this.

--
Nate Duehr
nate@natetech.com





Reply to: