#!/usr/bin/env bash set -o errexit set -o pipefail export DEBIAN_FRONTEND=noninteractive # shellcheck source=assets/build/functions.sh FUNCTIONS_FILE="${SALT_BUILD_DIR}/functions.sh" source "${FUNCTIONS_FILE}" log_info "Installing required packages and build dependencies ..." REQUIRED_PACKAGES=( binutils patchelf ) BUILD_DEPENDENCIES=() log_info "Adding salt repository..." add_salt_repository apt-get update install_pkgs "${REQUIRED_PACKAGES[@]}" "${BUILD_DEPENDENCIES[@]}" # Create salt user # https://manpages.ubuntu.com/manpages/xenial/en/man8/useradd.8.html log_info "Creating ${SALT_USER} user ..." useradd --home-dir "${SALT_HOME}" --create-home \ --shell /bin/bash --user-group "${SALT_USER}" \ --groups shadow # Set PATH exec_as_salt cat >> "${SALT_HOME}/.profile" <> /etc/ssh/ssh_config SUPERVISOR_CONFIG_FILE=/etc/supervisor/supervisord.conf # Configure logrotate log_info "Configuring logrotate ..." # move supervisord.log file to ${SALT_LOGS_DIR}/supervisor/ sed -i "s|^[#]*logfile=.*|logfile=${SALT_LOGS_DIR}/supervisor/supervisord.log ;|" "${SUPERVISOR_CONFIG_FILE}" # fix "unknown group 'syslog'" error preventing logrotate from functioning sed -i "s|^su root syslog$|su root root|" /etc/logrotate.conf # Configure supervisor log_info "Configuring supervisor ..." # run supervisord as root if grep -E "^user=" "${SUPERVISOR_CONFIG_FILE}"; then sed -i "s|^user=.*|user=root|" "${SUPERVISOR_CONFIG_FILE}" else sed -i "s|^\[supervisord\]\$|[supervisord]\nuser=root|" "${SUPERVISOR_CONFIG_FILE}" fi # configure supervisord to start salt-master cat > /etc/supervisor/conf.d/salt-master.conf < /etc/supervisor/conf.d/cron.conf <