Peppermint OS Community Forum

Support => Advanced Topics => Topic started by: Ulysses_ on September 09, 2018, 11:22:48 am

Title: SOLVED: Best place to put a startup script that requires root privileges
Post by: Ulysses_ on September 09, 2018, 11:22:48 am
Got a script that modifies the installation of firefox a little and mounts a CIFS network share because with /etc/fstab this mounting does not seem to happen automatically at startup (works fine with mount -all later though). So this script needs root privileges. If it is to run at startup, but not too early which might cause the network mount to fail, what is the best place to put it?
Title: Re: Best place to put a startup script that requires root privileges and firefox
Post by: PCNetSpec on September 09, 2018, 11:31:25 am
You should really search the web for how to get systemd to run a script after the network comes up.
Title: Re: Best place to put a startup script that requires root privileges and firefox
Post by: PCNetSpec on September 09, 2018, 11:38:35 am
Another option would be to make your script capable of being run without prompting for a password by adding it to sudoers .. info on this can be found in this topic
https://forum.peppermintos.com/index.php/topic,7285.0.html
and set a simple delay to the script to give the network time to come up



Another option might be to put your script in
/etc/network/if-up.d

Remembering of course to make it executable.



https://unix.stackexchange.com/questions/166473/debian-how-to-run-a-script-on-startup-as-soon-as-there-is-an-internet-connecti
Title: Re: Best place to put a startup script that requires root privileges and firefox
Post by: Ulysses_ on September 09, 2018, 02:35:00 pm
Sorted. By adding this line to sudoers:

user ALL=NOPASSWD: /home/user/myscript.sh

which makes it possible to put the script under the following as a command with sudo in front:

Menu - Settings - Default applications for LXSession - Autostart - Add - sudo /home/user/myscript.sh

It always succeeds in mounting the network share so far. But if it ever fails some sleep time can always be added at the beginning of the script.
Title: Re: Best place to put a startup script that requires root privileges and firefox
Post by: PCNetSpec on September 09, 2018, 05:32:18 pm
Cool, glad you sorted it :)

Can you please remember to mark the topic (SOLVED) .. TIA.