#!/bin/ksh # # $Id: mtree.ksh,v 1.2 2008/01/08 18:45:09 vogelke Exp $ # # /some/spec # mtree compare /some/spec # mtree set /some/spec - set perms, owerships PATH=/usr/local/bin:/bin:/sbin:/usr/sbin:/usr/bin export PATH die () { echo "$*" >& 2 exit 1 } umsg="usage: $0 [create|compare|set] path" case "$#" in 2) choice=$1; path="$2" ;; *) die "$umsg" ;; esac # to create a new tree copts="rmd160,gname,link,mode,nlink,size,time,type,uname" case "$choice" in create) test -d "$path" || die "$path: not a directory" mtree -x -c -k $copts -p $path ;; compare) test -f "$path" || die "$path: not a file" mtree -f $path ;; set) test -f "$path" || die "$path: not a file" mtree -Ut -f $path ;; *) die "$umsg" ;; esac exit 0