startup-script not as root (google cloud compute, ubuntu 14.04 VM)
Asked Answered
M

2

7

The default of the startup script is to run as root, I need to run the startup script as a specific user (the one used to create the image for the instance). I've tried all possible variations of su, etc, but when specifying that way, execution fails with no output. I might just be missing something stupid, but any help would be appreciated. Thanks.

Martinsen answered 6/8, 2015 at 3:9 Comment(1)
S
6

For anyone else having problem and looking for a solution.. I had the same issue. I created another script /opt/c2d/startup-script-user and called it from the default start script using su like this:

su - nonrootuser -c '/opt/c2d/startup-script-user.sh'
Squier answered 20/12, 2015 at 17:55 Comment(2)
You have to add new user nonrootuser before use it: useradd nonrootuserAeroscope
nonrootuser could be your main userUvula
S
0

i am trying to run selenium scraping scripts using start script. when i run the script as noon root user it will work fine. When i trigger it from start script it will not allow the chrome to crate webDriver due to which chrome is crahsed so what i found the solutions is:

first convert the root user to noon root user using su - user_name then run the .sh file for executing the scripts.

echo "converting root user to non_root user"
su - Mehar -c 'cd /home/mehar/rfq_scraper_app && ls -la && ./start_django_server.sh' || echo "Failed to start Django server"
echo "Script execution is ended"
Sheridansherie answered 19/3 at 11:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.