#! /bin/sh # postinst script for GeneWeb # # see: dh_installdeb(1) set -e # Needs Depends: iso-codes, isoquery ISOQUERY=/usr/bin/isoquery # These will be used here and there below SERVICES=/etc/services OLDRCFILE=/etc/geneweb/genewebrc NEWRCFILE=/etc/default/geneweb INITFILE=/etc/init.d/geneweb GENEWEBUSER=geneweb # We we'll need some variables defined there # We first define some defaults values...just in case GENEWEBDB=/var/lib/geneweb USERS_GROUP=geneweb LOGFILE=/var/log/geneweb.log # Default settings DEFAULTLNG="en" DEFAULTFULLLNG="English" DEFAULTPORT=2317 DEFAULTRUNMODE="Always on" DEFAULTREMOVE=false DEFAULTOPTIONS="" # Reads config file (will override defaults above) [ -r $NEWRCFILE ] && . $NEWRCFILE . /usr/share/debconf/confmodule db_version 2.0 write_rcfile() { cat >$NEWRCFILE </dev/null then echo "Adding $USERS_GROUP group ... " addgroup --quiet --force-badname $USERS_GROUP fi if [ ! -x `which adduser` ]; then echo "adduser(8) from the \'adduser\' package is needed..."; exit 1; fi # Make sure geneweb user exists if ! getent passwd ${GENEWEBUSER} >/dev/null then echo "Adding $GENEWEBUSER user ... " adduser --quiet --system --home /var/lib/geneweb --no-create-home --ingroup $USERS_GROUP $GENEWEBUSER fi # Permissions and groups changes come back # to the configure stage again. # Problems may remains if users previously messed up # the permissions...but more huge problems will # occur if this stage occurs _before_ the geneweb # group creation (was bug 171570 on 4.07-3 release) if [ ! -f $LOGFILE ] then touch $LOGFILE fi # Thus all files created there will have geneweb as group chown root:$USERS_GROUP $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc # The database directory is writable by geneweb group chmod ug+rwx,o-rwx $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc # SetGID bit on the database directory owned by geneweb group chmod g+s $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc # The log file is written by gwd running as the geneweb user # Make it readable/writable by this user only chown $GENEWEBUSER:$USERS_GROUP $LOGFILE chmod 600 $LOGFILE # Fix incorrect database and images directories permissions # These directories have to be group-writable # as the daemon now runs with an unprivileged UID # # Thanks to Russell Sutherland for pointing this to me # Bug: 179918 # # Deal properly with database names that contain spaces OLDIFS=${IFS} IFS=' ' for base in `find $GENEWEBDB -type d -name \*.gwb` do chgrp $USERS_GROUP "$base" chmod g+w,g+s "$base" # Fix files permissions. See #219779 for file in `find $base -type f` do chgrp $USERS_GROUP "$file" chmod g+w "$file" done done for imagedir in `find $GENEWEBDB/images -type d` do chgrp $USERS_GROUP "$imagedir" chmod g+w,g+s "$imagedir" done IFS=${OLDIFS} # Values are read from debconf # to update variables get_debconf # The settings file is written # Moved to postinst write_rcfile ;; *) ;; esac # Transition of init scripts links: we don't want them in runlevels # 0 and 6 anymore if dpkg --compare-versions "$2" lt "5.01-4"; then update-rc.d -f geneweb remove fi #DEBHELPER#