slo
Posts: 2
Joined: Sat May 21, 2016 11:08 pm

Run command at startup as different user

Sat May 21, 2016 11:24 pm

I am running Jessie Lite Raspbian with no GUI.
I have installed Google "Cups Connector" to use with google cloud print. It works good but...

The trouble I am having is having the program start on boot.
The install instructions had me create a user gcp and group gcp, and gcp owns all the program files.

The way I have to get it to run is with the following command:

Code: Select all

sudo -H -u gcp /opt/gcp_cups_connector/gcp-cups-connector -config-filename /etc/gcp_cups_connector/gcp-cups-connector.config.json
How can I have this run on startup? Note the second part of the command needs to point to a config file.

I found some dated instructions that do not work, but recommend editing /etc/rc.local file to include the following:

Code: Select all

su --login --command /opt/gcp_cups_connector/gcp-cups-connector -config-filename /etc/gcp_cups_connector/gcp-cups-connector.config.json pi &
As I said, that doesn't work. It has wrong user, wrong file location, and does not point to the config file.
So, how do I get the correct command to run at boot?

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Run command at startup as different user

Sun May 22, 2016 3:38 am

A print server should be run at startup from systemd (systemctl) as a service.

Systemd has a learning curve. Start with the basics (and a google search) on how to setup a server, what config files to create, and how to enable it.

post here is you have questions as you proceed
marcus
:ugeek:

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Run command at startup as different user

Sun May 22, 2016 10:36 am

On Google's Github pages
https://github.com/google/cups-connecto ... ly-on-Boot

You'll find different ways of running the daemon.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

slo
Posts: 2
Joined: Sat May 21, 2016 11:08 pm

Re: Run command at startup as different user

Sun May 22, 2016 10:51 am

Thanks Google's wiki very confusing. Didn't realize Raspbian uses systemd.

Use first option not third on this page: https://github.com/google/cups-connecto ... ly-on-Boot

broe23
Posts: 903
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Run command at startup as different user

Sun May 22, 2016 4:47 pm

Using a Headless server is not the issue. It is setting up Google Print Server with all of the apt's that it needs. Also you need CUPS installed and a printer that uses ARM drivers, which there are very few out there.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Run command at startup as different user

Mon May 23, 2016 6:32 pm

slo wrote:Thanks Google's wiki very confusing. Didn't realize Raspbian uses systemd.
Yes, as an aside, Raspbian is based on Debian. Debian 8 moved to Systemd by default; consequently Raspbian Jessie also moved to Systemd by default. Raspbian Wheezy previously used Sysvinit.
marcus
:ugeek:

Return to “Troubleshooting”