Merge from vendor branch CVS:
[dragonfly.git] / contrib / ipfilter / bsdinstall
1 #! /bin/sh
2 #
3 #       @(#)install.sh  4.5     (Berkeley)      10/12/83
4 #
5 cmd=/bin/mv
6 strip=""
7 chmod="chmod 755"
8 chown="chown -f root"
9 chgrp="chgrp -f bin"
10 while true ; do
11         case $1 in
12                 -s )    strip="strip"
13                         shift
14                         ;;
15                 -c )    cmd="cp"
16                         shift
17                         ;;
18                 -m )    chmod="chmod $2"
19                         shift
20                         shift
21                         ;;
22                 -o )    chown="chown -f $2"
23                         shift
24                         shift
25                         ;;
26                 -g )    chgrp="chgrp -f $2"
27                         shift
28                         shift
29                         ;;
30                 -d )    cmd="mkdir"
31                         shift
32                         ;;
33                 * )     break
34                         ;;
35         esac
36 done
37
38 if [ ! ${2-""} ]
39 then    echo "install: no destination specified"
40         exit 1
41 fi
42 if [ ${3-""} ]
43 then    echo "install: too many files specified -> $*"
44         exit 1
45 fi
46 if [ $1 = $2 -o $2 = . ]
47 then    echo "install: can't move $1 onto itself"
48         exit 1
49 fi
50 case $cmd in
51 /bin/mkdir )
52         file=$2/$1
53         ;;
54 * )
55         if [ '!' -f $1 ]
56         then    echo "install: can't open $1"
57                 exit 1
58         fi
59         if [ -d $2 ]
60         then    file=$2/$1
61         else    file=$2
62         fi
63         /bin/rm -f $file
64         ;;
65 esac
66
67 case $cmd in
68 /bin/mkdir )
69         if [ ! -d "$file" ]
70         then    $cmd $file
71         fi
72         ;;
73 * )
74         $cmd $1 $file
75         if [ $strip ]
76         then    $strip $file
77         fi
78         ;;
79 esac
80
81 $chown $file
82 $chgrp $file
83 $chmod $file