Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 539
MikeN Avatar asked Aug 06 '15 03:08

MikeN


People also ask

What does startup script do when you configuring an instance?

A startup script is a file that contains commands that run when a virtual machine (VM) instance boots. Compute Engine provides support for running startup scripts on Linux VMs and Windows VMs.


1 Answers

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'
like image 117
mumshad Avatar answered Oct 10 '22 05:10

mumshad