Skip to content

Instantly share code, notes, and snippets.

@wizofe
Last active July 12, 2018 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wizofe/cd918acce1877b722899cdb82a881ed7 to your computer and use it in GitHub Desktop.
Save wizofe/cd918acce1877b722899cdb82a881ed7 to your computer and use it in GitHub Desktop.
Start systemd/init level services sequentially
#!/bin/sh
# Start all system services sequentially
wants=$(systemctl show -p Wants multi-user.target | sed 's/^Wants=//' | tr ' ' '\n' | sort)
log=/var/tmp/multi-user-steps-$(date +%Y%m%d-%H%M%S)
log () {
echo "$* ..." | tee -a "$log"
sync
"$@"
ret=$?
echo "$* -> $ret" | tee -a "$log"
sync
return $ret
}
# systemd services
for service in $wants; do
log systemctl start $service
sleep 2
done
# up start services
for conf in /etc/init/*.conf; do
service=${conf##*/}; service=${service%.conf}
log service ${service} start
sleep 2
done
# init level 3 services
for service in /etc/rc3.d/S*; do
log ${service} start
sleep 2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment