#!/bin/sh # user=`whoami` self=`basename $0 .sh` folder="/u/$user/.elm" aliasfile="aliases.text" tempfile1="aliases.raw.$$.tmp" tempfile2="aliases.sorted.$$.tmp" # umask 177 # if [ ! \( -d "$folder" -a -r "$folder" -a -w "$folder" -a -x "$folder" \) ] then echo >&2 echo "Can't open directory '$folder'!" >&2 echo >&2 exit 1 fi # cd $folder # ok="" # if [ -f $aliasfile ] then if [ -r $aliasfile -a -w $aliasfile ] then ok="true" else chmod 600 $aliasfile if [ -r $aliasfile -a -w $aliasfile ] then ok="true" fi fi else cp /dev/null $aliasfile chmod 600 $aliasfile if [ -f $aliasfile -a -r $aliasfile -a -w $aliasfile ] then ok="true" fi fi # if [ "$ok" = "" ] then echo >&2 echo "Can't open file '$folder/$aliasfile'!" >&2 echo >&2 exit 1 fi # rc=0 trap 'rm -f $tempfile1 ; rm -f $tempfile2 ; exit $rc' 0 trap 'rm -f $tempfile1 ; rm -f $tempfile2 ; exit 1' 1 2 3 14 15 # cat $aliasfile >$tempfile1 # gawk -f /opt/lib/$self/$self.awk >$tempfile1 rc=$? # if [ "$rc" != "0" ] then echo >&2 echo "'awk' reports error '$rc' while creating temporary aliases file!" >&2 echo >&2 exit fi # trap '' 2 # sort +0 -1 -u <$tempfile1 >$tempfile2 rc=$? # if [ "$rc" != "0" ] then echo >&2 echo "Couldn't sort temporary aliases file!" >&2 echo >&2 exit fi # rm -f $aliasfile mv $tempfile2 $aliasfile # /opt/bin/newalias rc=$? # if [ "$rc" != "0" ] then echo >&2 echo "New aliases could not be installed successfully in elm!" >&2 echo >&2 exit fi # echo echo "New aliases for user '$user' successfully installed." echo exit # #### EOF ####