writing a script running firestarter automatically with kppp without root priviliges
I've installed firestarter under slackware 9.0 and am running kde 3.1 and kppp. now firestarter needs to be started AFTER the connection is up and running, which can be done in kppp. however in order to run firestarter I need root priviligies, and kppp can only execute user commands for the main user.
I was wondering if there is someway in which I can right an automatic script that will allow me to execute a 'su' command, pass it my root password and then run 'firestarter -s'. At the moment I have to start firestarter manually each time I connect using a shell console, su and then run the command. for obvious reasons I would like to start this automatically, but I don't know whether, or how, I can run su (with my password) and execute firestarter all from an automated script - all with only user priviligies for final execution of the script in kppp
Any and all help gratefully recieved, I'm sure there must be way but I don't understand about shell scripting. can anyone help me out?
I had exactly the same problem, but in Mandrake. My directories will probably be different than yours (hopefully not the commands), and here is what I did(please mind the typos):
# cd /usr/sbin (or wherever your firestarter bin is)
# vim firekiller
Hit [Esc] then [i] to insert the following(note the backward '):
kill -HUP `ps -C firestarter -o pid =`
Now, hit [Esc] then [Z] then [Z] to save. Now,
# chmod +x firekiller
which creates a script to kill firestarter after hanging up on kppd.
Assuming you have the SUDO command and its config file sudoers is in /etc...
# cd /etc
Hit [Esc] then [i] to include the following lines in the file:
#User Alias specification
User_Alias FIREUSERS = yourusernamehere1, username2here
#Cmnd Alias specification
Cmnd_Alias FIRESTART = /usr/sbin/firestarter -start
Cmnd_Alias FIREKILL = /usr/sbin/firekiller
FIREUSERS ALL = NOPASSWD: FIRESTART, FIREKILL
Hit [Esc] then [Z] then [Z] to save. If there is a typo, follow
its instructions and correct it. Try visudo again if unsure.
The NOPASSWD lets FIREUSERS group users execute only
FIRESTART and FIREKILL without a password.
In kppp, configure your execute settings in your dialing
profile to :( (I dont know the exact titles, but the order is right.)
[When Connected]: sudo /usr/sbin/firestarter -start
[After Disconnect]: sudo /usr/sbin/firekiller
Save your profile, and give it a shot. Let me know if you run into problems. Keep in mind, I'm a newbie myself, and have only been on Linux about a week now...j.p.b.
Any Xperienced Linux gurus out there let me know if ive goofed..
kill -HUP `ps -C firestarter -o pid=`
is the correct line (i had an extra space in there)
anymore problems and let me know... ill be in canada for a few days though so dont excpect an instant reply
wow! thanks for the mini-tutorial, I'm having some more serious probs with my linux box at the moment, but as soon as that's fixed (should be by tonight) I'll have a go with your instructions,
many, many thanks dude, I'll let you know how I get on! :)
|All times are GMT -5. The time now is 06:13 PM.|