Choose style:

Author Topic: SOLVED: Best place to put a startup script that requires root privileges  (Read 740 times)

0 Members and 1 Guest are viewing this topic.

Offline Ulysses_

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 0
  • New Forum User
    • View Profile
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?
« Last Edit: September 10, 2018, 01:05:21 pm by Ulysses_ »

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26102
  • Karma: 2843
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
You should really search the web for how to get systemd to run a script after the network comes up.
« Last Edit: September 09, 2018, 11:38:21 am by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26102
  • Karma: 2843
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
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
« Last Edit: September 09, 2018, 11:41:13 am by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Ulysses_

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 0
  • New Forum User
    • View Profile
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.
« Last Edit: September 09, 2018, 05:09:47 pm by Ulysses_ »

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26102
  • Karma: 2843
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Cool, glad you sorted it :)

Can you please remember to mark the topic (SOLVED) .. TIA.
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec