From ce3b96b14a7b0b2aba3db7bc1019eeda469706e5 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 27 Apr 2016 11:36:04 +0300 Subject: [PATCH] Use initscripts and units from Git working directory if present --- bootstrap-salt.sh | 48 +++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 8fad023..da3652c 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2951,6 +2951,7 @@ install_debian_7_git_deps() { install_debian_8_git_deps() { install_debian_8_deps || return 1 + # No user interaction, libc6 restart services for example export DEBIAN_FRONTEND=noninteractive @@ -3061,43 +3062,54 @@ install_debian_git_post() { for fname in minion master syndic api; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "api" ] && \ + [ "$fname" = "api" ] && \ ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && \ continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + # Configure SystemD for Debian 8 "Jessie" and later if [ -f /bin/systemctl ]; then if [ ! -f /lib/systemd/system/salt-${fname}.service ] || \ ([ -f /lib/systemd/system/salt-${fname}.service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then - __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.service" /lib/systemd/system - # FIXME: add Debian-specific unit files to the salt main repo - sed -i -e '/^Type/ s/notify/simple/' /lib/systemd/system/salt-${fname}.service + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.service" ]; then + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.service" /lib/systemd/system + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.environment" "/etc/default/salt-${fname}" + else + # workaround before adding Debian-specific unit files to the Salt main repo + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.service" /lib/systemd/system + sed -i -e '/^Type/ s/notify/simple/' /lib/systemd/system/salt-${fname}.service + fi fi # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - /bin/systemctl enable salt-${fname}.service + /bin/systemctl enable "salt-${fname}.service" SYSTEMD_RELOAD=$BS_TRUE - elif [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then - if [ -f "${_SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init" ]; then - __copyfile "${_SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init" "/etc/init.d/salt-$fname" + # Install initscripts for Debian 7 "Wheezy" + elif [ ! -f /etc/init.d/salt-$fname ] || \ + ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-$fname.init" ]; then + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.init" "/etc/init.d/salt-${fname}" + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.environment" "/etc/default/salt-${fname}" else - __fetch_url "/etc/init.d/salt-$fname" "${HTTP_VAL}://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-${fname}.init" + __fetch_url "/etc/init.d/salt-${fname}" "${HTTP_VAL}://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-${fname}.init" fi - if [ ! -f "/etc/init.d/salt-$fname" ]; then - echowarn "The init script for salt-$fname was not found, skipping it..." + + if [ ! -f "/etc/init.d/salt-${fname}" ]; then + echowarn "The init script for salt-${fname} was not found, skipping it..." continue fi - chmod +x "/etc/init.d/salt-$fname" + + chmod +x "/etc/init.d/salt-${fname}" # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - update-rc.d "salt-$fname" defaults + update-rc.d "salt-${fname}" defaults fi done