From 4d1436fd126c07a3c5f3d5ffb165d494c66ee6bd Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 12 Apr 2017 18:06:33 +0300 Subject: [PATCH] Alpine: fix bootstrapping from Git -- install OpenRC initscripts --- bootstrap-salt.sh | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index bafd735..7af9402 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -4213,6 +4213,9 @@ install_alpine_linux_stable_deps() { } install_alpine_linux_git_deps() { + # Get latest root CA certs + apk -U add ca-certificates + apk -U add python2 py-virtualenv py2-crypto py2-setuptools \ py2-jinja2 py2-yaml py2-markupsafe py2-msgpack py2-psutil \ py2-zmq zeromq py2-requests || return 1 @@ -4221,6 +4224,11 @@ install_alpine_linux_git_deps() { apk -U add git || return 1 fi + if ! __check_command_exists openssl; then + # Install OpenSSL to be able to pull from https:// URLs + apk -U add openssl + fi + __git_clone_and_checkout || return 1 if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then @@ -4267,7 +4275,6 @@ install_alpine_linux_git() { else python2 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 fi - return 0 } install_alpine_linux_post() { @@ -4286,8 +4293,7 @@ install_alpine_linux_post() { [ $fname = "syndic" ] && continue if [ -f /sbin/rc-update ]; then - /sbin/rc-update add salt-$fname > /dev/null 2>&1 - continue + /sbin/rc-update add salt-$fname > /dev/null 2>&1 || return 1 fi done } @@ -4301,15 +4307,21 @@ install_alpine_linux_git_post() { [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue - # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue - - # Skip salt-syndic as there is no service for it on Alpine Linux - [ $fname = "syndic" ] && continue - if [ -f /sbin/rc-update ]; then - /sbin/rc-update add salt-$fname > /dev/null 2>&1 - continue + script_url="${_SALTSTACK_REPO_URL%.git}/raw/develop/pkg/alpine/salt-$fname" + __fetch_url "/etc/init.d/salt-$fname" "$script_url" + + if [ $? -eq 0 ]; then + chmod +x "/etc/init.d/salt-$fname" + else + echoerror "Failed to get OpenRC init script for $OS_NAME from $script_url." + return 1 + fi + + # Skip salt-api since the service should be opt-in and not necessarily started on boot + [ $fname = "api" ] && continue + + /sbin/rc-update add "salt-$fname" > /dev/null 2>&1 || return 1 fi done } @@ -4330,7 +4342,7 @@ install_alpine_linux_restart_daemons() { # Disable stdin to fix shell session hang on killing tee pipe /sbin/rc-service salt-$fname stop < /dev/null > /dev/null 2>&1 - /sbin/rc-service salt-$fname start < /dev/null + /sbin/rc-service salt-$fname start < /dev/null || return 1 done }