0

I'm writing a script which automates the install of a mailserver, however some of my code has to be compiled from source because it is not in repositories. I have no problem with this, however, I have no idea what the best and most safe way is from a script that is being run as root. I know I have to make a non-privileged user for building, but which on of the following is the recommended way to do it?

1

su -c "command" - builduser
su -c "othercommand" - builduser

2

sudo -u builduser command
sudo -u builduser othercommand

3

su -c "externalscriptwithcommands.sh" - builduser

Ideally, I would like to continue my script as root after this has executed; I feel like option 3 is probably the most ideal, but I would like your input on this.

Peter van Arkel
  • 519
  • 1
  • 5
  • 14
  • 1
    Look at the answer on [link](http://stackoverflow.com/questions/14335825/execute-single-command-in-shell-script-without-sudo). As you want to continue as superuser, method 2 should be the best way. – user1978011 Jan 15 '13 at 16:42
  • Also, one option I did not consider is building SRPM-packages which can be installed as usual in the script. Thanks for your input :) – Peter van Arkel Jan 16 '13 at 08:41

0 Answers0