I have a startup script linked from /etc/init.d to /etc/rc3.d. When the system boots root starts the script and owns the processes. How can I have the script started as a different user?
When using su I need to pass the script to the su command..
for example..
script1.sh:
su nonroot "script2.sh"
script2.sh
touch nonrootfile
Is there a way I can run script2.sh without calling it from script1.sh? The startup script is a few hundred lines and I don't see how I could pass that to the su command unless I update every line which starts a process with "su nonroot".
I was hoping for a one liner at the top of the script..
SCRIPT=/some/path/to/file.ksh
su - someuser <<-END
if [ -f $SCRIPT ]
then
. /home/someuser.env
$SCRIPT
else
print "error: $SCRIPT does not exist"
fi
exit 0
END
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.