-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmkupdate
36 lines (36 loc) · 1.36 KB
/
cmkupdate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# This script is only intended for single sites
export APT_LISTCHANGES_FRONTEND="none"
export DEBCONF_NONINTERACTIVE_SEEN="true"
export DEBIAN_FRONTEND="noninteractive"
export NEEDRESTART_MODE="a"
if [[ $EUID -ne 0 ]]; then
exec sudo "$0"
fi
MIRROR="https://download.checkmk.com/checkmk"
# Don't to release-upgrades automatically.
CURRENT=$(omd version -b $(omd sites -b) |awk '{gsub(/\.cre/,""); print}')
TRAIN=$(cut -d. -f1,2 <<< $CURRENT)
V="$(curl -s https://download.checkmk.com/stable_downloads.json |jq -r '.checkmk[].version'|grep -v b|sort -h|grep -m1 "$TRAIN")"
# arg[1] to override the version
CMKVER="${1:-${V}}"
if [ $CMKVER = $CURRENT ]; then
echo "Already at latest version $CURRENT."
exit 0
fi
DEBFILE="check-mk-raw-${CMKVER}_0.$(lsb_release -cs)_amd64.deb"
DEBLINK="${MIRROR}/${CMKVER}/${DEBFILE}"
# could moved to mktemp -d ... and trap rm -rf tempdir 'EXIT' ...
wget "${DEBLINK}" -P /tmp -nc
# install new version
apt-get install --yes "/tmp/${DEBFILE}"
omd stop
omd -f -V ${CMKVER}.cre update --conflict=install "$(omd sites -b)"
omd start "$(omd sites -b)"
# Update Agent
apt-get install --yes "/opt/omd/versions/default/share/check_mk/agents/check-mk-agent_${CMKVER}-1_all.deb"
rm "/tmp/${DEBFILE}"
# Rather do cleanups manually to be safe...
#omd cleanup
clear
su - $(omd sites -b) bash -c 'omd status; omd version; omd versions'