Create the proper init file in a distribution-agnostic way

From http://unix.stackexchange.com/a/164092/105389
This commit is contained in:
Jose Diaz-Gonzalez
2016-01-02 04:08:54 -05:00
parent bb525a3cf1
commit 5a74d5c247

View File

@@ -11,9 +11,8 @@ fi
# temporary hack for https://github.com/dokku/dokku/issues/82
# redeploys all apps after a reboot
case "$DOKKU_DISTRO" in
ubuntu)
cat<<EOF > /etc/init/dokku-redeploy.conf
if [[ $(/sbin/init --version 2> /dev/null) =~ upstart ]]; then
cat<<EOF > /etc/init/dokku-redeploy.conf
description "Dokku app redeploy service"
start on filesystem and started docker
@@ -23,10 +22,10 @@ script
sudo -i -u dokku /usr/local/bin/dokku ps:restore
end script
EOF
;;
fi
debian|opensuse)
cat<<EOF > /etc/systemd/system/dokku-redeploy.service
if [[ $(systemctl 2> /dev/null) =~ -\.mount ]]; then
cat<<EOF > /etc/systemd/system/dokku-redeploy.service
[Unit]
Description=Dokku app redeploy service
After=docker.target
@@ -39,11 +38,10 @@ ExecStart=/usr/local/bin/dokku ps:restore
[Install]
WantedBy=multi-user.target
EOF
if command -v systemctl &>/dev/null; then
systemctl enable dokku-redeploy
fi
;;
esac
if command -v systemctl &>/dev/null; then
systemctl enable dokku-redeploy
fi
fi
mkdir -p /etc/update-motd.d
cat<<EOF > /etc/update-motd.d/99-dokku