Update saltminion.sh

This commit is contained in:
Bas van den Berg 2025-05-29 21:22:38 +02:00 committed by GitHub
parent 5683eef7a0
commit 86a93c97aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,12 +7,13 @@
function header_info { function header_info {
clear clear
cat <<"EOF" cat <<"EOF"
____ __ __ ___ ___ __ _
/ __ \/ /_ ____ / |/ /_ __/ | ____/ /___ ___ (_)___ _____ ____ _ _
/ /_/ / __ \/ __ \/ /|_/ / / / / /| |/ __ / __ `__ \/ / __ \ / ___/____ _/ / /_ ____ ___ (_)___ (_)___ ____
/ ____/ / / / /_/ / / / / /_/ / ___ / /_/ / / / / / / / / / / \__ \/ __ `/ / __/_____/ __ `__ \/ / __ \/ / __ \/ __ \
/_/ /_/ /_/ .___/_/ /_/\__, /_/ |_\__,_/_/ /_/ /_/_/_/ /_/ ___/ / /_/ / / /_/_____/ / / / / / / / / / / /_/ / / / /
/_/ /____/ /____/\__,_/_/\__/ /_/ /_/ /_/_/_/ /_/_/\____/_/ /_/
EOF EOF
} }
@ -27,11 +28,6 @@ INFO="${BL}${CL}"
APP="saltminion" APP="saltminion"
IFACE=$(ip -4 route | awk '/default/ {print $5; exit}')
IP=$(ip -4 addr show "$IFACE" | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
[[ -z "$IP" ]] && IP=$(hostname -I | awk '{print $1}')
[[ -z "$IP" ]] && IP="127.0.0.1"
# Detect OS # Detect OS
if [[ -f "/etc/alpine-release" ]]; then if [[ -f "/etc/alpine-release" ]]; then
OS="Alpine" OS="Alpine"
@ -84,7 +80,7 @@ function install_saltminion() {
$STD apt-get update $STD apt-get update
msg_ok "Setup Salt repo" msg_ok "Setup Salt repo"
msg_info "Installing Salt Master" msg_info "Installing Salt Minion"
RELEASE=$(curl -fsSL https://api.github.com/repos/saltstack/salt/releases/latest | jq -r .tag_name | sed 's/^v//') RELEASE=$(curl -fsSL https://api.github.com/repos/saltstack/salt/releases/latest | jq -r .tag_name | sed 's/^v//')
cat <<EOF >/etc/apt/preferences.d/salt-pin-1001 cat <<EOF >/etc/apt/preferences.d/salt-pin-1001
Package: salt-* Package: salt-*
@ -93,13 +89,14 @@ function install_saltminion() {
EOF EOF
$STD apt-get install -y salt-master $STD apt-get install -y salt-master
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Salt Master" msg_ok "Installed Salt Minion"
} }
function uninstall_saltminion() { function uninstall_saltminion() {
msg_info "Stopping service" msg_info "Stopping service"
if [[ "$OS" == "Debian" ]]; then if [[ "$OS" == "Debian" ]]; then
apt-get purge salt-minion apt-get purge salt-minion
rm -rf /etc/apt/preferences.d/salt-pin-1001
fi fi
msg_ok "Uninstalled Salt Minion" msg_ok "Uninstalled Salt Minion"
} }