|
2007-08-15
, 09:00
|
|
Posts: 91 |
Thanked: 25 times |
Joined on Mar 2007
@ Marlow, Bucks
|
#2
|
|
2007-08-15
, 11:37
|
Posts: 2,152 |
Thanked: 1,490 times |
Joined on Jan 2006
@ Czech Republic
|
#3
|
Here's a suggestion:
Write a script to start OpenVPN with the config file you want, call it vpn, and place it in your path. Then, once you are root, you can simply type vpn to start up OpenVPN with your chosen config file.
#!/bin/sh # use gainroot to become root and relaunch itself if [ `id -u` != 0 ] ; then #if not already root, call itself as root TTY=`tty` [ "$TTY" = "not a tty" ] && unset TTY exec sudo gainroot <<EOF if [ -z "$TTY" ] ; then exec $0 $* ; else exec <$TTY $0 $* ; fi EOF exit $? fi # real script follows
|
2007-08-16
, 06:10
|
Posts: 3 |
Thanked: 0 times |
Joined on Aug 2007
|
#4
|
|
2007-08-16
, 07:01
|
Posts: 2,152 |
Thanked: 1,490 times |
Joined on Jan 2006
@ Czech Republic
|
#5
|
I was wondering if it was possible to externalize the header to gain root access and then include it somehow, or better create a standalone script that establishes root access and exec that at the start of any script needing root acccess...but seeing as this gains root first, then relaunches itself....that may not be possible because of the recursive nature.?
#!/bin/sh # use gainroot to become root and relaunch itself if [ `id -u` != 0 ] ; then #if not already root, call itself as root exec sudo gainroot <<EOF exec $0 $* EOF exit $? fi # real script follows
#!/bin/sh if [ `id -u` != 0 ] ; then exec sudo gainroot <<E exec $0 $* E ; fi
#!/bin/sh [ `id -u` != 0 ] && exec sudo gainroot <<E exec $0 $* E
The Following User Says Thank You to fanoush For This Useful Post: | ||
|
2007-08-16
, 22:58
|
Posts: 3 |
Thanked: 0 times |
Joined on Aug 2007
|
#6
|
All I am trying to do is create an alias that will launch openvpn. Can't do this from the /home/user/.profile because openvpn needs root access.
I have tried editing the /root/.profile and also the /etc/.profile but still no luck. Could anyone point me in the right direction for setting up aliases that will be available within the gainroot environment?
clark