quarta-feira, 17 de maio de 2017

Boot

#!/bin/sh -e
...
exit 0

sudo cp rc.local /etc/rc.local
sudo cp rc.local.init.d /etc/init.d/rc.local

sudo chown root /etc/rc.local
sudo chmod 755 /etc/rc.local

sudo update-rc.d rc.local defaults
sudo /etc/init.d/rc.local start
sudo systemctl status rc-local.service

head -n1 /etc/rc.local
#!/bin/sh -e
53
In my case none of the instructions were a perfect solution. If you were as unlucky as me, try this detailed one
  1. Put all your executing code in a separate text file with an arbitrary name such as foo.sh and save it in an arbitrary place.
  2. Add
    #!/bin/sh
    as first line of your code.
  3. Try executing your foo.sh by
    sudo foo.sh
    to check there are no errors at all.
  4. Provide your /etc/rc.local script with full path and name of your created script after the sh command
    sh '/path/to/your/script/foo.sh'
  5. Remember to put the above line before the last line of code
    exit 0
    at the end of the /etc/rc.local script.
  6. Check first line of /etc/rc.local to be
    #!/bin/sh -e
  7. Make your /etc/rc.local executable in case it is not already executable by
    sudo chown root /etc/rc.local
    sudo chmod 755 /etc/rc.local
  8. Check everything works fine by executing
    sudo /etc/init.d/rc.local start
  9. Test restart your system.
28
On newer Ubuntu versions systemd is used and /etc/rc.local is not loaded always by default.
Check if the Compatibility service is loaded with
systemctl status rc-local.service

Nenhum comentário:

Postar um comentário