How to run script from root as another user (with user PATH)
Posted
by
Sandra
on Server Fault
See other posts from Server Fault
or by Sandra
Published on 2012-11-02T02:07:08Z
Indexed on
2012/11/02
5:08 UTC
Read the original article
Hit count: 123
I would like to have these commands run as the ss
user from root
mkdir bin
cp -r /opt/gitolite .
gitolite/install -ln
gitolite setup -pk ss.pub
mkdir -p .gitolite/hooks/common
ln -s /opt/pre-receive .gitolite/hooks/common/
so everything is executed in /home/ss
. The 4th line requires $HOME/bin
as you can see from the 3rd line.
The only way I can get it to work is by adding su -c "command" ss
to each line, which is not a nice hack.
This is an extension to my previous question, where I wasn't precise enough.
Question
How do I run all these commands as a script in a practical way?
© Server Fault or respective owner