forked from proftpd/proftpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PFTEST.install
executable file
·83 lines (66 loc) · 1.61 KB
/
PFTEST.install
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
80
81
82
#!/bin/sh
#
# PFTEST.install - setup files for an unprivileged proftpd test
#
PFTESTDIR=/tmp/PFTEST
SRCDIR=./sample-configurations
FILELIST="PFTEST.passwd PFTEST.group PFTEST.conf.in"
PATH=/usr/bin:/bin
export PATH
umask 022
#
# Preconditions
#
if [ ! -d ${SRCDIR} ] || [ ! -r ${SRCDIR} ]; then
echo "Error: \"${SRCDIR}\" not found." >&2
exit 2
fi
for file in ${FILELIST} ; do
if [ ! -r ${SRCDIR}/${file} ]; then
echo "Error: \"${SRCDIR}/${file}\" not found." >&2
exit 2
fi
done
if [ -d ${PFTESTDIR} ] || [ -f ${PFTESTDIR} ] || [ -h ${PFTESTDIR} ] \
|| [ -b ${PFTESTDIR} ] || [ -c ${PFTESTDIR} ] || [ -p ${PFTESTDIR} ]
then
echo "Error: \"${PFTESTDIR}\" already exists." >&2
exit 2
fi
#
# Determine current user and group names
#
if [ -x /usr/xpg4/bin/id ] && /usr/xpg4/bin/id -un >/dev/null 2>&1 ; then
USERNAME=`/usr/xpg4/bin/id -un`
GROUPNAME=`/usr/xpg4/bin/id -gn`
elif type id >/dev/null && id -un >/dev/null 2>&1 ; then
USERNAME=`id -un`
GROUPNAME=`id -gn`
else
# Could try harder...
echo "Error: can not determine user and group names." >&2
exit 3
fi
#
# Install the files
#
mkdir ${PFTESTDIR} || {
echo "Error: mkdir failed." >&2
exit 4
}
chmod 755 ${PFTESTDIR} || {
echo "Error: chmod failed." >&2
exit 4
}
cp -p ${SRCDIR}/PFTEST.passwd ${PFTESTDIR} \
&& cp -p ${SRCDIR}/PFTEST.group ${PFTESTDIR} \
&& sed -e "s/%User%/${USERNAME}/" \
-e "s/%Group%/${GROUPNAME}/" \
-e "s|%TestDir%|${PFTESTDIR}|" \
${SRCDIR}/PFTEST.conf.in > ${PFTESTDIR}/PFTEST.conf
if [ $? -ne 0 ]; then
echo "Error: installation failed." >&2
exit 5
fi
echo "Sample test files successfully installed in ${PFTESTDIR}."
exit 0