Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 4694af0c564cd245b8a20d7be43702a4 > scriptlet

dpm-postgres-nameserver-1.8.1.2-1.fc16.i686.rpm

PREUN

/bin/sh
export LANG=C

if [ $1 = 0 ]; then
    /usr/sbin/update-alternatives --display dpnsdaemon | \
	grep currently | grep -q dpm-postgres && \
	/sbin/service dpm-postgres-nameserver stop > /dev/null 2>&1 || :
    /usr/sbin/update-alternatives --remove dpnsdaemon \
	/usr/lib/dpm-postgres/dpnsdaemon
    /sbin/chkconfig --del dpm-postgres-nameserver
fi

POSTIN

/bin/sh
updatedpns () {
    [ -r /etc/sysconfig/dpnsdaemon ] && . /etc/sysconfig/dpnsdaemon
    [ -z "$NSCONFIGFILE" ] && NSCONFIGFILE=/etc/DPNSCONFIG
    [ -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

    export PGPASSWORD=$passwd
    psql="psql -t -q -U $user $db"

    vmajor=$($psql -c "select major from schema_version" 2>/dev/null)
    vminor=$($psql -c "select minor from schema_version" 2>/dev/null)
    vpatch=$($psql -c "select patch from schema_version" 2>/dev/null)

    if [ -z "$vmajor" -o -z "$vminor" -o -z "$vpatch" ] ; then
	return 0
    fi

    if [ $vmajor -eq 3 -a $vminor -eq 0 -a $vpatch -eq 0 ] ; then
	$psql <<-EOF
	ALTER TABLE Cns_groupinfo ADD banned INTEGER;
	ALTER TABLE Cns_userinfo ADD user_ca VARCHAR(255);
	ALTER TABLE Cns_userinfo ADD banned INTEGER;
	CREATE INDEX linkname_idx ON Cns_symlinks(linkname);
	UPDATE schema_version SET major = 3, minor = 1, patch = 0;
	EOF
    fi

    return 0
}

updatedpns

if [ $1 = 1 ]; then
    /sbin/chkconfig --add dpm-postgres-nameserver
fi
/usr/sbin/update-alternatives --install /usr/sbin/dpnsdaemon dpnsdaemon \
	  /usr/lib/dpm-postgres/dpnsdaemon 10 \
  --slave /usr/share/man/man8/dpnsdaemon.8.gz dpnsdaemon.8.gz \
	  /usr/lib/dpm-postgres/dpnsdaemon.8.gz \
  --slave /usr/share/dpm/DPNSCONFIG.templ DPNSCONFIG.templ \
	  /usr/lib/dpm-postgres/DPNSCONFIG.templ \
  --slave /etc/sysconfig/dpnsdaemon dpnsdaemon.conf \
	  /etc/dpm-postgres/dpnsdaemon.conf \
  --slave /etc/logrotate.d/dpnsdaemon dpnsdaemon.logrotate \
	  /etc/dpm-postgres/dpnsdaemon.logrotate \
  --slave /usr/sbin/dpns-shutdown dpns-shutdown \
	  /usr/lib/dpm-postgres/dpns-shutdown \
  --slave /usr/share/man/man8/dpns-shutdown.8.gz dpns-shutdown.8.gz \
	  /usr/lib/dpm-postgres/dpns-shutdown.8.gz \
  --initscript dpm-postgres-nameserver

POSTUN

/bin/sh
export LANG=C

if [ $1 -ge 1 ]; then
    /usr/sbin/update-alternatives --display dpnsdaemon | \
	grep currently | grep -q dpm-postgres && \
	/sbin/service dpm-postgres-nameserver condrestart > /dev/null 2>&1 || :
fi