blob: e5a757a161d0ac405f58beb8c67b8baf03b822ad (
plain)
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
|
#!/bin/sh
POLIPOUSER=%%USER%%
POLIPOGROUP=%%GROUP%%
UID=173
GID=${UID}
POLIPOCACHE=%%PCACHEDIR%%
POLIPOLOG=%%PLOGFILE%%
PPIDDIR=%%PPIDDIR%%
POLIPOPID=%%PPIDFILE%%
if [ "$2" = "PRE-INSTALL" ]; then
if fgrep "polipo" "%%DESTDIR%%/etc/newsyslog.conf" 2>/dev/null 1>&2; then
if ! fgrep "polipo.pid" "%%DESTDIR%%/etc/newsyslog.conf" 2>/dev/null 1>&2; then
echo "==> ERROR: Previous installation left an invalid entry in %%DESTDIR%%/etc/newsyslog.conf."
echo "==> Please remove the polipo line from this file and try again."
exit 1
fi
fi
if ! pw groupshow "$POLIPOGROUP" 2>/dev/null 1>&2; then
if pw groupadd $POLIPOGROUP -g ${GID} ; then
echo "=> Added group \"$POLIPOGROUP\"."
else
echo "=> Adding group \"$POLIPOGROUP\" failed..."
exit 1
fi
fi
if ! pw usershow "$POLIPOUSER" 2>/dev/null 1>&2; then
if pw useradd $POLIPOUSER -u ${UID} -g $POLIPOGROUP -h - \
-s "/sbin/nologin" -d "/nonexistent" \
-c "polipo web cache"; \
then
echo "=> Added user \"$POLIPOUSER\"."
else
echo "=> Adding user \"$POLIPOUSER\" failed..."
exit 1
fi
fi
elif [ "$2" = "POST-INSTALL" ]; then
if [ ! -d "%%DESTDIR%%$PPIDDIR" ]; then
mkdir -p "%%DESTDIR%%$PPIDDIR" || exit 1
chgrp "$POLIPOGROUP" "%%DESTDIR%%$PPIDDIR" || exit 1
chmod g+w "%%DESTDIR%%$PPIDDIR" || exit 1
fi
if [ ! -f "%%DESTDIR%%$POLIPOLOG" ]; then
touch "%%DESTDIR%%$POLIPOLOG" || exit 1
chown "$POLIPOUSER" "%%DESTDIR%%$POLIPOLOG" || exit 1
chmod u=rw,g=r,o= "%%DESTDIR%%$POLIPOLOG" || exit 1
fi
if ! fgrep "${POLIPOLOG}" "%%DESTDIR%%/etc/newsyslog.conf" 2>/dev/null 1>&2; then
echo "Add a line to /etc/newsyslog.conf (or /usr/local/etc/newsyslog.conf.d/polipo.conf if"
echo "supported on your system) to enable automatic log file rotation:"
echo
echo "${POLIPOLOG} ${POLIPOUSER}: 640 3 100 * J ${POLIPOPID} 30"
echo
fi
fi
OSVER=`uname -r | sed -e 's/\..*//'`
if [ ${OSVER} = "8" -o ${OSVER} = "9" ]; then
CACHEPARENT=`dirname ${POLIPOCACHE}`
echo "You will need to manually run:"
echo " chmod o+x %%DESTDIR%%$CACHEPARENT"
echo "to ensure the cache is useable."
fi
exit 0
|