PREIN
/bin/sh
getent group lfcmgr > /dev/null || groupadd -r lfcmgr
getent passwd lfcmgr > /dev/null || useradd -r -g lfcmgr \
-d /var/lib/lfc -s /bin/bash -c "LFC Manager" lfcmgr
exit 0
PREUN
/bin/sh
export LANG=C
if [ $1 = 0 ]; then
/usr/sbin/update-alternatives --display lfcdaemon | \
grep currently | grep -q lfc-mysql && \
/sbin/service lfc-mysql stop > /dev/null 2>&1 || :
/usr/sbin/update-alternatives --remove lfcdaemon \
/usr/lib64/lfc-mysql/lfcdaemon
/sbin/chkconfig --del lfc-mysql
fi
POSTIN
/bin/sh
updatelfc () {
[ -r /etc/sysconfig/lfcdaemon ] && . /etc/sysconfig/lfcdaemon
[ -z "$NSCONFIGFILE" ] && NSCONFIGFILE=/etc/NSCONFIG
[ -r $NSCONFIGFILE ] || return 0
nscfg=$(cat $NSCONFIGFILE)
cfg1=$(echo $nscfg | cut -f1 -d@)
cfg2=$(echo $nscfg | cut -f2 -d@ -s)
user=$(echo $cfg1 | cut -f1 -d/)
passwd=$(echo $cfg1 | cut -f2 -d/ -s)
host=$(echo $cfg2 | cut -f1 -d/)
db=$(echo $cfg2 | cut -f2 -d/ -s)
[ -z "$user" ] && return 0
[ -z "$passwd" ] && return 0
[ -z "$host" ] && return 0
[ -z "$db" ] && db=cns_db
mycfg=$(mktemp)
cat > $mycfg <<-EOF
[client]
user=$user
password=$passwd
EOF
mysql="mysql --defaults-file=$mycfg --skip-column-names $db"
vmajor=$($mysql -e "select major from schema_version" 2>/dev/null)
vminor=$($mysql -e "select minor from schema_version" 2>/dev/null)
vpatch=$($mysql -e "select patch from schema_version" 2>/dev/null)
if [ -z "$vmajor" -o -z "$vminor" -o -z "$vpatch" ] ; then
rm $mycfg
return 0
fi
if [ $vmajor -eq 3 -a $vminor -eq 0 -a $vpatch -eq 0 ] ; then
$mysql <<-EOF
ALTER TABLE Cns_groupinfo ADD banned INTEGER;
ALTER TABLE Cns_userinfo ADD user_ca VARCHAR(255) BINARY;
ALTER TABLE Cns_userinfo ADD banned INTEGER;
CREATE INDEX linkname_idx ON Cns_symlinks(linkname(255));
UPDATE schema_version SET major = 3, minor = 1, patch = 0;
EOF
fi
rm $mycfg
return 0
}
updatelfc
if [ $1 = 1 ]; then
/sbin/chkconfig --add lfc-mysql
fi
/usr/sbin/update-alternatives --install /usr/sbin/lfcdaemon lfcdaemon \
/usr/lib64/lfc-mysql/lfcdaemon 20 \
--slave /usr/share/man/man8/lfcdaemon.8.gz lfcdaemon.8.gz \
/usr/lib64/lfc-mysql/lfcdaemon.8.gz \
--slave /usr/share/lfc/NSCONFIG.templ NSCONFIG.templ \
/usr/lib64/lfc-mysql/NSCONFIG.templ \
--slave /etc/sysconfig/lfcdaemon lfcdaemon.conf \
/etc/lfc-mysql/lfcdaemon.conf \
--slave /etc/logrotate.d/lfcdaemon lfcdaemon.logrotate \
/etc/lfc-mysql/lfcdaemon.logrotate \
--slave /usr/sbin/lfc-shutdown lfc-shutdown \
/usr/lib64/lfc-mysql/lfc-shutdown \
--slave /usr/share/man/man8/lfc-shutdown.8.gz lfc-shutdown.8.gz \
/usr/lib64/lfc-mysql/lfc-shutdown.8.gz \
--initscript lfc-mysql
POSTUN
/bin/sh
export LANG=C
if [ $1 -ge 1 ]; then
/usr/sbin/update-alternatives --display lfcdaemon | \
grep currently | grep -q lfc-mysql && \
/sbin/service lfc-mysql condrestart > /dev/null 2>&1 || :
fi