Run a script on first boot after install in 16.04

Ralf Mardorf silver.bullet at zoho.com
Fri Jul 8 09:54:16 UTC 2016


On Thu, 7 Jul 2016 20:14:06 +0200, Josef Wolf wrote:
>Unfortunately, with 16.04, this won't work anymore. The symlinks
>in /etc/rcS.d are created, but the scripts won't be run at startup.

Ubuntu switched from upstart to systemd.
Install the script to some /path/to/foo.sh, then add a
unit /lib/systemd/system/foo.service, e.g.

  [Unit]
  Description=foo script

  [Service]
  Type=oneshot
  ExecStart=/path/to/foo.sh --start
  ExecStop=/path/to/foo.sh --stop
  RemainAfterExit=true

  [Install]
  WantedBy=multi-user.target

and enable start on bootup by executing

  sudo systemctl enable foo.service

Regards,
Ralf





More information about the ubuntu-users mailing list