X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fmonitoring%2Fplugins%2Fcheck_git;fp=modules%2Fprivate%2Fmonitoring%2Fplugins%2Fcheck_git;h=8c09925cfbf06bcddfc4bb6e492e64a101fd51f9;hb=e820134d38c3b7470ea5112f40a6dc967f039878;hp=0000000000000000000000000000000000000000;hpb=b22ce4895ef1e9723a02061f7293e528cfbf9754;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/monitoring/plugins/check_git b/modules/private/monitoring/plugins/check_git new file mode 100755 index 0000000..8c09925 --- /dev/null +++ b/modules/private/monitoring/plugins/check_git @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +SSH_KEY="$1" + +TMPDIR=$(mktemp -d) + +if [ ! -d "$TMPDIR" ]; then + echo "gitolite UNKNOWN - impossible to create temp dir" + exit 3 +fi + +trap "rm -rf $TMPDIR" EXIT + +ERRORS="" +OUTPUT="" + +cd "$TMPDIR" +OUT=$(git clone -q git://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) +ERR=$? +if [ -n "$OUT" ]; then +OUTPUT="$OUTPUT +$OUT" +fi +if [ "$ERR" != 0 ]; then + ERRORS="$ERRORS git://" +fi +rm -rf Monitor + +OUT=$(git clone -q http://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) +ERR=$? +if [ -n "$OUT" ]; then +OUTPUT="$OUTPUT +$OUT" +fi +if [ "$ERR" != 0 ]; then + ERRORS="$ERRORS http://" +fi +rm -rf Monitor + +OUT=$(git clone -q https://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) +ERR=$? +if [ -n "$OUT" ]; then +OUTPUT="$OUTPUT +$OUT" +fi +if [ "$ERR" != 0 ]; then + ERRORS="$ERRORS https://" +fi +rm -rf Monitor + +OUT=$(GIT_SSH_COMMAND="ssh -i $SSH_KEY -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no" git clone -q gitolite@git.immae.eu:perso/Immae/Projets/Ruby/Monitor 2>&1) +ERR=$? +if [ -n "$OUT" ]; then +OUTPUT="$OUTPUT +$OUT" +fi +if [ "$ERR" != 0 ]; then + ERRORS="$ERRORS ssh" +fi +rm -rf Monitor + +if [ -n "$ERRORS" ]; then + echo "gitolite CRITICAL - impossible to clone via$ERRORS|$OUTPUT" + exit 2 +else + echo "gitolite OK - ssh, git, http and https work|$OUTPUT" + exit 0 +fi