* add a script that tries to migrate the systems /etc/aliases file if existant.
[citadel.git] / citadel / migrate_aliases.sh
1 #!/bin/bash
2
3 CITALIAS=$1
4 if test -f /etc/aliases; then
5     cat /etc/aliases | \
6         sed -e "s; *;;g" \
7             -e "s;\t*;;g" | \
8         grep -v ^root: | \
9         grep -v ^# | \
10         sed -e "s;:root;,room_aide;" \
11             -e "s;:;,;" >/tmp/aliases
12
13     NLINES=`cat /tmp/aliases|wc -l`
14     
15     for ((i=1; i <= $NLINES; i++)); do 
16         ALIAS=`head -n $i /tmp/aliases |tail -n 1`
17         ORG=`echo $ALIAS|sed "s;,.*;;"`
18         if grep $ORG $CITALIAS; then
19             echo "Ignoring Alias $ORG as its alreday there"
20         else
21             echo "$ALIAS" >>$CITALIAS
22         fi
23     done
24 else
25     echo "no /etc/aliases found."
26 fi