From fcc04c9c51f229aeaa70f8ccce9f26e2872a35b3 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 8 May 2009 19:03:30 +0000 Subject: Split out functions git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@388 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- zshrc | 176 +++++++----------------------------------------------------------- 1 file changed, 17 insertions(+), 159 deletions(-) (limited to 'zshrc') diff --git a/zshrc b/zshrc index e8254f9..42d880c 100644 --- a/zshrc +++ b/zshrc @@ -207,6 +207,12 @@ fi # SETUP PATH ############ +fpath=( "$HOME/.zshfunc" "$fpath[@]" ) +export FPATH +# Only unique entries please. +typeset -U fpath + + path=( "$HOME/bin" "$HOME/local/bin" @@ -236,14 +242,24 @@ typeset -U path path=( ${^path}(N-/) ) - #MANPATH="/usr/share/man:/usr/local/share/man:/usr/local/man:$MANPATH" #if [ -d $HOME/local/share/man ] ; then # MANPATH="${HOME}/local/share/man:${MANPATH}" #fi +# FUNCTIONS +########### +# Now that FPATH is set correctly, do autoloaded functions. +# autoload all functions in $FPATH - that is, all files in +# each component of the array $fpath. If there are none, feed the list +# it prints into /dev/null. +for paths in "$fpath[@]" + do + autoload -U "$paths"/*(N:t) >/dev/null +done +unset paths # we want colorful listings zmodload -i zsh/complist @@ -257,164 +273,6 @@ fi autoload -U compinit compinit -########## -upgrade-porter-chroots() { - cd - for i in $DEBPORTERHOSTS; do - mkdir hosts/chroot-$i 2>/dev/null || continue; - echo $i; - preexec $i; - ssh $i -t 'sudo /usr/sbin/upgrade-porter-chroots' - done -} -upgrade-debian-hosts() { - cd - for i in $DEBHOSTS; do - mkdir hosts/$i 2>/dev/null || continue; - echo $i; - preexec $i; - ssh $i -t ' - sudo apt-get update && - sudo apt-get dist-upgrade && - sudo apt-get clean - '; - done -} -upgrade-systems() { - cd - for i in $HOSTS; do - mkdir hosts/$i 2>/dev/null || continue; - echo $i; - preexec $i; - ssh $i -t 'apt-get update && - if [ -e /usr/bin/apt-get.distrib ]; then - aptitude dist-upgrade; - else - apt-get dist-upgrade; - fi && - apt-get clean'; - done -} -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 - echo done. - fi - '; - done -} - -reinit-debian-samhain-one() { - host=$1 - if [ "$host" = "${host%%.debian.org}" ]; then - host="$host.debian.org" - fi - echo $host - preexec $host; - ssh $host -t ' - check() { - sudo /usr/sbin/samhain -t check -i -p err -s none -l none -m none - }; - 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; - - echo Updating samhain db... - sudo samhain --foreground -t update - grep -q OK /var/cache/dsa/nagios/samhain || sudo dsa-update-samhain-status - echo done. - fi; - fi - '; -} -reinit-debian-samhain() { - for i in $DEBHOSTS; do - mkdir hosts/$i 2> /dev/null || continue; - reinit-debian-samhain-one $i - done -} - -update-debian-exim() { - for i in $DEBHOSTS; do - mkdir hosts/$i 2> /dev/null || continue; - echo $i - preexec $i; - ssh $i -t ' - [ -d /etc/exim4 ] || exit; - cd /etc/exim4 && - sudo ./Git/bin/update && - sudo env -i /etc/init.d/exim4 reload - '; - done -} - -fpr() { - ( - ssh-keygen -r '' -f =( ssh-keyscan -t rsa $1 2>/dev/null | sed -e 's/^[^ ]* //'); - ssh-keygen -r '' -f =( ssh-keyscan -t dsa $1 2>/dev/null | sed -e 's/^[^ ]* //'); - ) | sed -e 's/^[^ ]* //' -} - -########## -md() { - DIR="$1" - mkdir "$1" && cd "$1" -} - -######### -sd() { - fp=$( wget -q -O - http://tor.noreply.org:80/tor/status/authority | \ - awk '$1 == "r" && $2 == "'$1'" {printf "%s===", $3}' | \ - perl -MMIME::Base64 -e "print unpack(\"H*\", decode_base64(<>)),\"\n\"" ) - echo wget -q -O - http://tor.noreply.org:80/tor/server/fp/$fp -} - if [ -x /usr/bin/ddate ] ; then -- cgit v1.2.3