summaryrefslogtreecommitdiff
path: root/zshfunc/upgrade-debian-samhain
diff options
context:
space:
mode:
Diffstat (limited to 'zshfunc/upgrade-debian-samhain')
-rw-r--r--zshfunc/upgrade-debian-samhain86
1 files changed, 42 insertions, 44 deletions
diff --git a/zshfunc/upgrade-debian-samhain b/zshfunc/upgrade-debian-samhain
index be5dc7b..6267567 100644
--- a/zshfunc/upgrade-debian-samhain
+++ b/zshfunc/upgrade-debian-samhain
@@ -1,48 +1,46 @@
## vim:ft=zsh:foldmethod=marker
-upgrade-debian-samhain() {
- for i in $DEBHOSTS; do
- mkdir hosts/$i 2> /dev/null || continue;
- echo $i
- preexec $i;
- ssh $i -t '
- didsudo=0
- check() {
- sudo /usr/sbin/samhain -t check -i -p err -s none -l none -m none
- };
- reinit() {
- if [ "`check 2>&1 | grep "^CRIT" | wc -l`" != 0 ]; then
- echo Updating samhain db...
- sudo samhain --foreground -t update
- didsudo=1
- echo done.
- fi
- }
- if [ -x /usr/sbin/samhain ]; then
- t="`tempfile`";
- trap "rm -f $t" 0 1 2 5 15;
- check > "$t" 2>&1;
- if [ "`grep "^CRIT" "$t" | wc -l`" != 0 ]; then
- echo "samhain db errors found:";
- sed -e "s/.*path=<\([^>]*\)>, .*/\1/" "$t";
- echo;
- echo "Enter 'y' to continue upgrade and update samhaindb for `hostname`";
- read ans;
- [ "$ans" = "y" ] || exit;
- fi;
- fi
- sudo apt-get update &&
- sudo apt-get dist-upgrade &&
- sudo apt-get clean &&
- [ -x /usr/sbin/samhain ] && reinit
- if [ "$didsudo" = 1 ]; then
- echo Updating nagios status
- echo "apt"
- sudo /usr/sbin/dsa-update-apt-status
- echo "samhain"
- grep -q OK /var/cache/dsa/nagios/samhain || sudo dsa-update-samhain-status
+for i in $DEBHOSTS; do
+ mkdir hosts/$i 2> /dev/null || continue;
+ echo $i
+ preexec $i;
+ ssh $i -t '
+ didsudo=0
+ check() {
+ sudo /usr/sbin/samhain -t check -i -p err -s none -l none -m none
+ };
+ reinit() {
+ if [ "`check 2>&1 | grep "^CRIT" | wc -l`" != 0 ]; then
+ echo Updating samhain db...
+ sudo samhain --foreground -t update
+ didsudo=1
echo done.
fi
- ';
- done
-}
+ }
+ if [ -x /usr/sbin/samhain ]; then
+ t="`tempfile`";
+ trap "rm -f $t" 0 1 2 5 15;
+ check > "$t" 2>&1;
+ if [ "`grep "^CRIT" "$t" | wc -l`" != 0 ]; then
+ echo "samhain db errors found:";
+ sed -e "s/.*path=<\([^>]*\)>, .*/\1/" "$t";
+ echo;
+ echo "Enter 'y' to continue upgrade and update samhaindb for `hostname`";
+ read ans;
+ [ "$ans" = "y" ] || exit;
+ fi;
+ fi
+ sudo apt-get update &&
+ sudo apt-get dist-upgrade &&
+ sudo apt-get clean &&
+ [ -x /usr/sbin/samhain ] && reinit
+ if [ "$didsudo" = 1 ]; then
+ echo Updating nagios status
+ echo "apt"
+ sudo /usr/sbin/dsa-update-apt-status
+ echo "samhain"
+ grep -q OK /var/cache/dsa/nagios/samhain || sudo dsa-update-samhain-status
+ echo done.
+ fi
+ ';
+done