X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmigrate_aliases.sh;h=bc5c31ef3caf89b21e810fdb6638c6bfcf82c2cd;hb=8179fa6e60da83d53435ed943d15a3eddb3a0d5f;hp=9408135f25425c36ec680ff27181c32caa396925;hpb=f08f0bc29d1d25e260899818949d8992a2d62924;p=citadel.git diff --git a/citadel/migrate_aliases.sh b/citadel/migrate_aliases.sh index 9408135f2..bc5c31ef3 100755 --- a/citadel/migrate_aliases.sh +++ b/citadel/migrate_aliases.sh @@ -1,22 +1,32 @@ #!/bin/bash +if test -z "$1"; then + echo "Usage: $0 mail.aliases" + exit +fi CITALIAS=$1 if test -f /etc/aliases; then - cat /etc/aliases | \ +# don't work with temp fils, so they can't get hijacked. +# sorry users with megabytes of aliases. + NLINES=`cat /etc/aliases | \ sed -e "s; *;;g" \ -e "s;\t*;;g" | \ grep -v ^root: | \ grep -v ^# | \ sed -e "s;:root;,room_aide;" \ - -e "s;:;,;" >/tmp/aliases - - NLINES=`cat /tmp/aliases|wc -l` + -e "s;:;,;" |wc -l` for ((i=1; i <= $NLINES; i++)); do - ALIAS=`head -n $i /tmp/aliases |tail -n 1` + ALIAS=` cat /etc/aliases | \ + sed -e "s; *;;g" \ + -e "s;\t*;;g" | \ + grep -v ^root: | \ + grep -v ^# | \ + sed -e "s;:root;,room_aide;" \ + -e "s;:;,;" |head -n $i |tail -n 1` ORG=`echo $ALIAS|sed "s;,.*;;"` - if grep $ORG $CITALIAS; then - echo "Ignoring Alias $ORG as its alreday there" + if grep "$ORG" "$CITALIAS"; then + echo "Ignoring Alias $ORG as its already there" else echo "$ALIAS" >>$CITALIAS fi