2f92cc0aa4
the log file to be owned by root because most files were opened/created before the uid was switched to non-root. That's not the case anymore so we need to be sure those files are owned by slimserv:slimserv. This isn't a problem with new installed because they are made correctly in the rc script, but on upgrades it may be an issue. Handle this by resetting the permissions of existing files and directories during the install. While I'm here, remove some leftover directory creation. It properly belongs in the startup script so the files will be created if /var is clear. Bump port revision.
80 lines
2.1 KiB
Bash
80 lines
2.1 KiB
Bash
#!/bin/sh
|
|
# $FreeBSD: /tmp/pcvs/ports/audio/squeezeboxserver/files/pkg-install.in,v 1.2 2005-04-21 20:05:53 brooks Exp $
|
|
|
|
name=slimserver
|
|
u=slimserv
|
|
g=slimserv
|
|
ugid=104
|
|
homedir=/nonexistent
|
|
shell=/sbin/nologin
|
|
comment="Slim Devices SlimServer pseudo-user"
|
|
slimdir="%%PREFIX%%/%%SLIMDIR%%"
|
|
statedir=/var/db/slimserver
|
|
cachedir=${statedir}/cache
|
|
conffile=${statedir}/slimserver.conf
|
|
playlistdir=${statedir}/playlists
|
|
pidfile=/var/run/${name}.pid
|
|
newsyslogfile=/etc/newsyslog.conf
|
|
logfile=/var/log/slimserver.log
|
|
logcomment="# added by audio/slimserver port"
|
|
logline="${logfile} ${u}:${g} 644 3 100 * Z ${pidfile}"
|
|
|
|
case $2 in
|
|
PRE-INSTALL)
|
|
if pw group show "${g}" >/dev/null 2>&1; then
|
|
echo "Using existing group \"${g}\"."
|
|
else
|
|
echo "Creating group \"${g}\", (gid: ${ugid})."
|
|
pw groupadd ${g} -g ${ugid}
|
|
if [ $? != 0 ]; then
|
|
echo "Failed to add group \"${g}\"."
|
|
exit 1
|
|
fi
|
|
fi
|
|
if pw user show "${u}" >/dev/null 2>&1; then
|
|
echo "Using existing user \"${u}\"."
|
|
else
|
|
echo "Creating user \"${u}\", (uid: ${ugid})."
|
|
pw useradd ${u} -u ${ugid} -g ${ugid} -h - \
|
|
-d ${homedir} -s ${shell} -c "${comment}"
|
|
if [ $? != 0 ]; then
|
|
echo "Failed to add user \"${u}\"."
|
|
exit 1
|
|
fi
|
|
fi
|
|
;;
|
|
POST-INSTALL)
|
|
if [ -d ${statedir} ]; then
|
|
chown -R ${u}:${g} ${statedir}
|
|
fi
|
|
if [ -d ${cachedir} ]; then
|
|
chown -R ${u}:${g} ${cachedir}
|
|
fi
|
|
if [ -d ${playlistdir} ]; then
|
|
chown -R ${u}:${g} ${playlistdir}
|
|
fi
|
|
if [ -d /var/run/slimserver ]; then
|
|
chown -R ${u}:${g} /var/run/slimserver
|
|
fi
|
|
if [ -f ${conffile} ]; then
|
|
chown ${u}:${g} ${conffile}
|
|
fi
|
|
if [ -f ${logfile} ]; then
|
|
chown ${u}:${g} ${logfile}
|
|
fi
|
|
if egrep -q "^${logfile}\>" ${newsyslogfile}; then
|
|
echo "Using existing ${newsyslogfile} entry."
|
|
else
|
|
echo "Adding slimserver log entry to ${newsyslogfile}."
|
|
echo "$logcomment" >> ${newsyslogfile}
|
|
echo "$logline" >> ${newsyslogfile}
|
|
fi
|
|
for file in %%CONFFILES%%; do
|
|
path="${slimdir}/${file}"
|
|
if [ ! -e ${path} ]; then
|
|
cp ${path}.sample ${path}
|
|
chmod 644 ${path}
|
|
fi
|
|
done
|
|
;;
|
|
esac
|