summaryrefslogtreecommitdiff
path: root/print/cups/pkg/INSTALL
blob: 46378126ebb35668ed3b78575dc4904b67d08ab0 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /bin/sh
#
# $NetBSD: INSTALL,v 1.11 2001/08/14 03:41:39 jlam Exp $

PKGNAME=$1
STAGE=$2

USER="@CUPS_USER@"
GROUP="@CUPS_GROUP@"

ADDUSER="@ADDUSER@"
ADDGROUP="@ADDGROUP@"
CAT="@CAT@"
CHGRP="@CHGRP@"
CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
CP="@CP@"
ID="@ID@"
MKDIR="@MKDIR@"
RM="@RM@"
TOUCH="@TOUCH@"

LOGDIR=/var/log/cups
REQUESTDIR=/var/spool/cups
SAMPLECONFDIR=${PKG_PREFIX}/share/examples/cups
CONFDIR=/etc/cups
CONFFILES="client.conf cupsd.conf"
NONCONFFILES="classes.conf mime.convs mime.types printers.conf"

case ${STAGE} in
PRE-INSTALL)
	# Group... the default's shipped with NetBSD
	# We need to check that ${GROUP} exists before adding the user.
	# Do it with chgrp to be able to use NIS.
	#
	${TOUCH} "/tmp/grouptest.$$"
	${CHGRP} ${GROUP} "/tmp/grouptest.$$" >/dev/null 2>&1
	if [ $? -eq 0 ]
	then
		echo "Group '${GROUP}' already exists...proceeding."
	else
		echo "Creating '${GROUP}' group..."
		${ADDGROUP} ${GROUP}
		echo "Done."
	fi
	${RM} -f "/tmp/grouptest.$$"

	# Use `id' to be able to use NIS.
	#
	${ID} ${USER} 2>/dev/null >/dev/null
	if [ $? -eq 0 ]
	then
		echo "User '${USER}' already exists...proceeding."
	else
		echo "Creating '${USER}' user..."
		${ADDUSER} -c "Common UNIX Printing System user" -g ${GROUP} -s /bin/sh ${USER}
		echo "Done."
	fi
	;;

POST-INSTALL)
	${MKDIR} ${CONFDIR}
	${MKDIR} ${CONFDIR}/certs
	${CHMOD} 711 ${CONFDIR}/certs
	${CHOWN} ${USER}:${GROUP} ${CONFDIR}/certs
	${MKDIR} ${CONFDIR}/interfaces
	${MKDIR} ${CONFDIR}/ppd
        ${MKDIR} ${LOGDIR}
        ${MKDIR} ${REQUESTDIR}
	${CHMOD} 700 ${REQUESTDIR}
	${CHOWN} ${USER}:${GROUP} ${REQUESTDIR}
	${MKDIR} ${REQUESTDIR}/tmp
	${CHMOD} 1700 ${REQUESTDIR}/tmp
	${CHOWN} ${USER}:${GROUP} ${REQUESTDIR}/tmp

	echo "Installing configuration files:"
	for file in ${CONFFILES} ${NONCONFFILES}
	do
		FILE=${CONFDIR}/${file}
		SAMPLEFILE=${SAMPLECONFDIR}/${file}
		if [ -f ${FILE} ]
		then
			echo "    ${FILE} already exists"
		else
			echo "    ${FILE}"
			${CP} ${SAMPLEFILE} ${FILE}
			${CHMOD} 644 ${FILE}
		fi
	done
	${CAT} << EOF

===========================================================================
Some files you might need to customize include the following:

EOF
	for file in ${CONFFILES}
	do
		FILE=${CONFDIR}/${file}
		echo "	${FILE}"
	done
	if [ -f ${SAMPLECONFDIR}/cups.pam ]
	then
		${CAT} << EOF

To authenticate for CUPS using PAM, add the contents of the file:

	${SAMPLECONFDIR}/cups.pam

to your PAM configuration file.
EOF
	fi
	${CAT} << EOF
===========================================================================
EOF
	;;

*)
	echo "Unexpected argument: ${STAGE}"
	exit 1
	;;
esac
exit 0