-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-sh
executable file
·79 lines (62 loc) · 1.57 KB
/
install-sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
#
# Installation script for Unices without a BSD style install (e.g. HP-UX).
#
# Written by Andrew M. Bishop
#
# This file Copyright 1995,96,97,98 Andrew M. Bishop
# It may be distributed under the GNU Public License, version 2, or
# any higher version. See section COPYING of the GNU Public license
# for conditions under which this file may be redistributed.
#
if [ $# = "0" ]; then
echo "A simple installation script"
echo "usage: install.sh [-c] -d dir"
echo " install.sh [-c] [-m mode] [-g group] [-o owner] file destination"
exit 1
fi
if [ $1 = "-c" ]; then
shift
fi
if [ $1 = "-d" ]; then
if [ "x$2" = "x" ]; then
echo "Directory not specified"
exit 1
fi
dir=''
dirs=`echo $2 | sed 's%/% %g'`
for d in $dirs; do
dir="$dir/$d";
[ -d $dir ] || mkdir $dir
done
else
mode=
owner=
group=
while [ ! $# = 0 ]; do
case $1 in
-m) shift; mode=$1;;
-o) shift; owner=$1;;
-g) shift; group=$1;;
-*) echo "Unrecognised option $1"; exit 1;;
*) src=$1; shift; dst=$1;;
esac
shift
done
if [ "x$src" = "x" -o "x$dst" = "x" ]; then
echo "Source and destination not specified"
exit 1
fi
if [ -d $dst ]; then
dst=$dst/`basename $src`
fi
if cp $src $dst; then
[ $mode ] && chmod $mode $dst
[ $group ] && chgrp $group $dst
[ $owner ] && chown $owner $dst
else
echo Copy of $src to $dst failed
exit 1
fi
fi
exit 0