Well it's clunky, but it works. I'm probably unduly proud of it, because this is my first attempt at a `structured' sh script. Anything before that was just a simple list of commands, which could just as easily be typed into a terminal. Of course, they have saved me the trouble of typing those same lines over and over again.

My main reason for writing it was to perform a few basic actions as root, without getting hassled for a password every time. Not really an issue in DSL, at least not from the live CD.

You don't necessarily need to have the referenced apps installed, but it might come in handy for automating other things you'd like to automate, whether they require root privs or not. That's why I'm posting it here. Oh, and because I'm unduly proud of it. ;-)

Code Sample

#!/bin/sh

echo Starting r00t_l00p...

# This script adds some super-user functionality to regular# old Wendy Whitebread accounts.## What it does is check for certain directory names in /tmp,# then acts on whatever it finds there. So other programs, and# the user, can communicate with it via `mkdir' or a launcher# button that runs a simple `mikdir /tmp/r00t/foo' command.

mkdir -p /tmp/r00t/runchmod -R 777 /tmp/r00tsleep 11rm -rf /tmp/r00t/run## If the `run' folder exists, this indicates that a r00t script# has just been started, and other instances should quit now.## Avoids multiple instances piling up from one login to the next.

while :do if [ -x /tmp/r00t/run ] then echo Ending r00t_l00p. exit 0 # What did I just say?

/etc/acpi/hibernate.sh # # Requires the addition of an `&' in # /etc/acpi/hibernate.sh # # Here, on the last line; # . /etc/acpi/resume.sh & # # Otherwise, the hibernate script will just sit there # and wait, long after it's finished its work, and so # will r00t_l00p; waiting for hibernate.sh to exit.

Probably insecure as hell, because it does rely on a world-writable directory to take instructions, but that's fine with me because the only remote file access I've got going is FTP, and even that is usually turned off [does come in handy though, for transferring files between a Mac, PC and my currently favourite Linux box]. Besides, it's all sitting behind a router.

However, since this is a laptop, I do want to be sure the FTP daemon's really, truly and completely shut down when I head out to an internet cafe or something.

Blah, foo, bar, etc [and please excuse another long post],

Patrick.

--------------Q: What is the difference between a joke, and a lie?A: A lie tends to obscure the truth, while a joke often reveals it.

But maybe I should rephrase my original statement; I don't want to make sure anything is properly shut down, or properly launched. I want something else to do it for me.

But now it can report, accurrately, whether the thing's running or not, instead of just counting on the daemon being properly configured, and launching when it's told to launch [always has so far, but still...]. I have enough faith in killall -s 9 not to worry about that, but in most cases [probably every case] that's really overdoing it.

Thanks again,

Patrick.

--------------Q: What is the difference between a joke, and a lie?A: A lie tends to obscure the truth, while a joke often reveals it.

Just a quick revision, in case anyone finds this useful. When I first wrote it, I thought the `-x' test was short for `exists' btw... Kind of lucked out though, because directories also tend to be executable.

And thanks again to Humpty, for the note on ps -e | grep [foo] .

Code Sample

#!/bin/sh

echo Starting r00t_l00p...

# This script adds some super-user functionality to regular# old Wendy Whitebread accounts.## What it does is check for certain directory names in /tmp,# then acts on whatever it finds there. So other programs, and# the user, can communicate with it via `mkdir' or a launcher# button that runs a simple `mkdir /tmp/r00t/foo' command.

mkdir -p /tmp/r00t/runchmod -R 777 /tmp/r00tsleep 11rm -rf /tmp/r00t/run## If the `run' folder exists, this indicates that a r00t script# has just been started, and other instances should quit now.## Avoids multiple instances piling up from one login to the next.

while :dosleep 2 if [ -d /tmp/r00t/run ] then echo Ending r00t_l00p. exit 0 # What did I just say?

/etc/acpi/hibernate.sh # # Requires the addition of an `&' in # /etc/acpi/hibernate.sh # # Here, on the last line; # . /etc/acpi/resume.sh & # # Otherwise, the hibernate script will just sit there # and wait, long after it's finished its work. And so # will r00t_l00p; waiting for hibernate.sh to exit.

The progresion from `stop' to `force-stop' to `killall -s 9' gets a bit convoluted, but as far as I know it's never progressed past the basic `stop'. Well, not in normal use anyway. I did launch GProFTPD [a graphical configuration tool for the daemon] to test it.

BTW, does anyone know how to make grep match only whole words, and ignore word fragments like the `proftpd' in `gproftpd'? I've messed with some of its command-line options, but haven't guesed right yet.

Thanks,

Patrick.

--------------Q: What is the difference between a joke, and a lie?A: A lie tends to obscure the truth, while a joke often reveals it.