1#!/bin/sh23set -e45for i6do7 case "$i" in8 -p)9 proto=$210 shift 211 ;;12 -*)13 echo usage: uninstall [-p proto] root >&214 exit 115 ;;16 esac17done1819root=${1?'root missed'}20proto=${proto:-scripts/proto.all}2122while read type perm name23do24 case $type in25 d)26 echo $type $perm $name27 continue28 ;;29 f)30 rm -f $root/$name31 ;;32 *)33 echo install: wrong entry type >&234 exit 135 ;;36 esac37done < $proto |38sort -r |39while read type perm name40do41 case $type in42 d)43 if test `ls $root/$name | wc -l` -eq 044 then45 rmdir $root/$name46 fi47 ;;48 esac49done