2023-07-17 18:24:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Nagios plugin to check paste version
|
|
|
|
#
|
|
|
|
# Author : Obitanz <hb+chapril@unenieme.eu>
|
|
|
|
# Date : 17 Jul 2023
|
|
|
|
#
|
|
|
|
|
|
|
|
OK=0
|
|
|
|
WARNING=1
|
|
|
|
CRITICAL=2
|
|
|
|
UNKNOWN=3
|
|
|
|
|
2023-08-18 04:13:57 +02:00
|
|
|
function usage {
|
2023-07-17 18:24:25 +02:00
|
|
|
echo "Usage : $0"
|
|
|
|
echo "This script check if minetest mods are up to date"
|
|
|
|
result=${UNKNOWN}
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$#" -ne 0 ]; then
|
|
|
|
usage
|
|
|
|
else
|
2023-08-18 04:13:57 +02:00
|
|
|
mod_outdated=-1
|
2023-07-17 18:24:25 +02:00
|
|
|
for mod in $(ls -1d /srv/minetest.chapril.org/home/.minetest/mods/*);
|
|
|
|
do
|
|
|
|
shortname=$(echo ${mod} | cut -d "/" -f 7)
|
|
|
|
lastCommit=$(cd ${mod} && git ls-remote origin | head -1 | cut -d " " -f 1)
|
|
|
|
currentCommit=$(cd ${mod} && git rev-parse HEAD)
|
|
|
|
|
|
|
|
if [ "${currentVersion}" = "${lastVersion}" ]; then
|
|
|
|
result_msg=${result_msg}"\n${shortname} is up to date"
|
2023-08-18 04:13:57 +02:00
|
|
|
if [ ${mod_outdated} -eq -1 ]; then
|
|
|
|
mod_outdated=0
|
|
|
|
fi
|
2023-07-17 18:24:25 +02:00
|
|
|
else
|
|
|
|
result_msg=${result_msg}"\nnew version available for ${shortname}, current is ${currentVersion}, last is ${lastVersion}"
|
|
|
|
mod_outdated=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ ${mod_outdated} -eq 0 ]; then
|
|
|
|
echo "OK - all mods are up to date"
|
|
|
|
result=${OK}
|
2023-08-18 04:13:57 +02:00
|
|
|
elif [ ${mod_outdated} -eq -1 ]; then
|
|
|
|
echo "UNKNWON - error during script execution"
|
|
|
|
result=${UNKNOWN}
|
2023-07-17 18:24:25 +02:00
|
|
|
else
|
|
|
|
echo -e "WARNING - all mods aren't up to date${result_msg}"
|
|
|
|
result=${WARNING}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit $result
|
|
|
|
|