File: installit.sh

package info (click to toggle)
remstats 1.00a4-8woody1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,576 kB
  • ctags: 1,020
  • sloc: perl: 11,706; ansic: 2,776; makefile: 944; sh: 869
file content (44 lines) | stat: -rwxr-xr-x 1,052 bytes parent folder | download
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
#!/bin/sh

# Copyright 1999, 2000, 2001 (c) Thomas Erskine <@@AUTHOR@@>
# See the COPYRIGHT file with the distribution.

# installit - simple install script
# $Id: installit.sh,v 1.3 2001/08/28 15:22:24 remstats Exp $

# - - -   Setup   - - -

if [ $# -lt 5 ] ; then
	echo >&2 "usage: `basename $0` owner group mode src destdir"
	exit 1
fi

owner=$1
group=$2
mode=$3
src=`echo $* | awk '{for (i=4; i<=NF-1; ++i) { out=out " " $i;} print out}'`
last="\$$#"
destdir=`eval echo $last`

if [ -z "$destdir" ] ; then
	echo >&2 "`basename $0`: missing destination"
	exit 2
fi

# - - -   Mainline   - - -

# copy them all
cp $src $destdir || (echo "can't copy $src to $destdir" && exit 3)

# Have to loop anyway, might as well fix them here
for f in $src ; do
	dest="$destdir/`basename $f`"

	if [ `id | cut -f2 -d\( | cut -f1 -d\)` = root ] ; then
		chown $owner $dest || (echo "can't chown for $dest" && exit 4)
		chgrp $group $dest || (echo "can't chgrp for $dest" && exit 5)
	fi
	chmod $mode $dest || (echo "can't chmod for $dest" && exit 6)
done

exit 0;