The every day things from Thalamus' life.

Thalamus' Blog

15 January, 2015

Systemd – simple, bash start/stop script.

Filed under: ComputerStuff_en — Thalamus @ 20:02

Typical script, here ‘myscript’, that we call from systemd. Two files

/usr/lib/systemd/scripts/myscript
/etc/systemd/system/myscript.service

start() {
  exec something
}
 
stop() {
  exec something else
}
 
case $1 in
  start|stop) "$1" ;;
esac
[Unit]
Description=Please make a description
 
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/scripts/myscript start
ExecStop=/usr/lib/systemd/scripts/myscript stop
RemainAfterExit=yes
 
[Install]
WantedBy=multi-user.target
• • •