Move server scripts here

This commit is contained in:
Thomas Avé 2024-03-15 18:18:13 +01:00
parent ac464fc6a8
commit 3b81d0104f
3 changed files with 65 additions and 4 deletions

47
scripts/cronic Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# Cronic v3 - cron job report wrapper
# Copyright 2007-2016 Chuck Houpt. No rights reserved, whatsoever.
# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/
set -eu
TMP=$(mktemp -d)
OUT=$TMP/cronic.out
ERR=$TMP/cronic.err
TRACE=$TMP/cronic.trace
set +e
"$@" >$OUT 2>$TRACE
RESULT=$?
set -e
PATTERN="^${PS4:0:1}\\+${PS4:1}"
if grep -aq "$PATTERN" $TRACE
then
! grep -av "$PATTERN" $TRACE > $ERR
else
ERR=$TRACE
fi
if [ $RESULT -ne 0 ]
then
echo "Cronic detected failure or error output for the command:"
echo "$@"
echo
echo "RESULT CODE: $RESULT"
echo
echo "ERROR OUTPUT:"
cat "$ERR"
echo
echo "STANDARD OUTPUT:"
cat "$OUT"
if [ $TRACE != $ERR ]
then
echo
echo "TRACE-ERROR OUTPUT:"
cat "$TRACE"
fi
fi
rm -rf "$TMP"

15
scripts/disk_check.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
REPORT_EMAIL=email@thomasave.be
ZPOOL_STATUS=`zpool status -x`
if [ "$ZPOOL_STATUS" = "all pools are healthy" -o "$ZPOOL_STATUS" = "no pools available" ]
then
echo -n 0 > /var/db/zpool.status
else
if [ `cat /var/db/zpool.status` -eq 0 ]
then
zpool status | mail -s "ZPOOL NOT HEALTHY" $REPORT_EMAIL
echo -n 1 > /var/db/zpool.status
fi
fi

View File

@ -90,12 +90,11 @@ function zvm_after_init() {
# Use FZY instead of FZF for ctrl-t
function find_files() {
zle -I
# Check if ~/Containers exists
PATHS=$(fd -H . ~/Workspace -t d -d 5)
if [ -d ~/Containers ]; then
BUFFER=cd "$(fd -H . ~/Workspace ~/Containers -t d | fzy -l 20)"
else
BUFFER=cd "$(fd -H . ~/Workspace -t d | fzy -l 20)"
PATHS="$PATHS $(fd -H . ~/Containers -t d -d 2)"
fi
BUFFER=cd "$(echo $PATHS | fzy -l 20)"
zle accept-line
clear
}