#!/bin/sh # # install_etcfiles.sh[.in] # # $Id: install_etcfiles.sh.in,v 1.9 2019/02/27 23:02:20 root Exp root $ if [ -d /usr/xpg4/bin ] then # to get a standard 'grep' on Solaris: PATH=/usr/xpg4/bin:$PATH export PATH fi unset BASH_ENV PKGNAME=${RPM_PACKAGE_NAME:-${DEB_PACKAGE_NAME:-notset}} if [ $PKGNAME = ufdbGuard ] then DESTDIR=${DEB_BUILD_ROOT:-${RPM_BUILD_ROOT:-}} else DESTDIR="" fi OS="@ufdb_os_type@" INITDIR="@ufdb_initdir@" CFGDIR="$1" if [ ! -d "$CFGDIR" ] then echo "install_etcfiles.sh: $CFGDIR is not a directory **********" exit 1 fi BINDIR="$2" if [ ! -d "$BINDIR" ] then echo "install_etcfiles.sh: $BINDIR is not a directory **********" exit 1 fi SYSCFGFILE="$3" if [ ! -f "$SYSCFGFILE" ] then echo "install_etcfiles.sh: $SYSCFGFILE does not yet exist (OK)" fi copyparams () { # copy parameters from ufdbUpdate to /etc/sysconfig/ufdbguard cfgfile="@ufdb_bindir@/ufdbUpdate" syscfgfile="$1" if [ -r "$cfgfile" ] then P_DOWNLOAD_USER=`grep -E -e '^DOWNLOAD_USER=' $cfgfile` P_DOWNLOAD_PASSWORD=`grep -E -e '^DOWNLOAD_PASSWORD=' $cfgfile` P_PROXY_USER=`grep -E -e '^PROXY_USER=' $cfgfile` P_PROXY_PASSWORD=`grep -E -e '^PROXY_PASSWORD=' $cfgfile` eval $P_DOWNLOAD_USER usernamelen=`echo $DOWNLOAD_USER | wc -c` if [ $usernamelen -ge 3 ] then sed -e "s,^DOWNLOAD_USER=\"\".*,$P_DOWNLOAD_USER" \ -e "s,^DOWNLOAD_PASSWORD=\"\".*,$P_DOWNLOAD_PASSWORD" \ -e "s,^PROXY_USER=\"\".*,$P_PROXY_USER" \ -e "s,^PROXY_PASSWORD=\"\".*,$P_PROXY_PASSWORD" \ < $syscfgfile > $syscfgfile.new mv $syscfgfile.new $syscfgfile echo "copied DOWNLOAD_USER, DOWNLOAD_PASSWORD, PROXY_USER and PROXY_PASSWORD from $cfgfile to $syscfgfile" fi fi } install_openbsd () { # OpenBSD is different from other *nix systems. # On OpenBSD the stop/start script is installed in $BINDIR # and called from /etc/rc.local and /etc/rc.shutdown rm -f $BINDIR/ufdb.sh cp mtserver/ufdb.sh $BINDIR/ufdb.sh chmod 755 $BINDIR/ufdb.sh ALREADY_DONE=`grep -E -e "/ufdb.sh.*start" $DESTDIR/etc/rc.local` if [ "$ALREADY_DONE" = "" ] then ( echo echo "# start ufdbGuard" echo "$BINDIR/ufdb.sh start" echo ) >> $DESTDIR/etc/rc.local ( echo echo "# stop ufdbGuard" echo "$BINDIR/ufdb.sh stop" echo ) >> $DESTDIR/etc/rc.shutdown echo echo "=======================================================================" echo "/etc/rc.local and /etc/rc.shutdown are modified to start/stop ufdbGuard" echo "=======================================================================" echo else echo echo "Notice: /etc/rc.local and /etc/rc.shutdown already start/stop ufdbGuard" echo fi } install_netbsd () { if [ ! -w $INITDIR ] then echo "No permission to write to $INITDIR" exit 1 fi rm -f $INITDIR/ufdb.sh cp mtserver/ufdb.sh $INITDIR/ufdb.sh chmod 755 $INITDIR/ufdb.sh echo echo "==================================================================" echo "ufdb.sh startup script is copied to $INITDIR " echo "==================================================================" echo } install_smoothwall () { if [ ! -d $INITDIR ] then mkdir -p $INITDIR fi if [ ! -w $INITDIR ] then echo "install_etcfiles.sh: No permission to write to $INITDIR ***" exit 1 fi rm -f $INITDIR/ufdb cp mtserver/ufdb.sh $INITDIR/ufdb chmod 755 $INITDIR/ufdb echo echo "==================================================================" echo "ufdb.sh startup script is copied to $INITDIR " echo "==================================================================" echo } install_freebsd () { if [ ! -w $INITDIR ] then echo "install_etcfiles.sh: No permission to write to $INITDIR ***" exit 1 fi rm -f $INITDIR/ufdb.sh cp mtserver/ufdb.sh $INITDIR/ufdb.sh chmod 755 $INITDIR/ufdb.sh echo echo "==================================================================" echo "ufdb.sh startup script is copied to $INITDIR " echo "==================================================================" echo } install_solaris_smf () { # installation based on SMF METHODDIR=/lib/svc/method if [ ! -d $METHODDIR ] then echo "$METHODDIR does not exist. Cannot install SMF files" exit 1 fi if [ -f $METHODDIR/init.ufdbguard ] then echo "$METHODDIR/init.ufdbguard will be installed but already exists." \ "init.ufdbguard is saved as init.ufdbguard.previous *****" cp $METHODDIR/init.ufdbguard $METHODDIR/init.ufdbguard.previous chmod 555 $METHODDIR/init.ufdbguard.previous fi ./ufdbguard_smf_inst.sh echo } install_unix () { if [ ! -w $DESTDIR$INITDIR ] then echo "No permission to write to $DESTDIR$INITDIR (unix) *****" exit 1 fi if [ "$DEB_PACKAGE_NAME" != ufdbGuard ] then rm -f $DESTDIR$INITDIR/ufdb cp mtserver/ufdb.sh $DESTDIR$INITDIR/ufdb chmod 755 $DESTDIR$INITDIR/ufdb echo echo "==================================================================" echo "ufdbguard startup script is copied to $DESTDIR$INITDIR/ufdb" echo "==================================================================" echo fi if [ $PKGNAME = ufdbGuard ] then # do nothing. the package install script will do post-install processing : void else # Use LSB if the system has it. if [ -x /usr/lib/lsb/install_initd ] then echo "using LSB to manage the system initialisation script" /usr/lib/lsb/remove_initd ufdb /usr/lib/lsb/install_initd ufdb else # use chkconfig if the system has it if [ -x /sbin/chkconfig ] then echo "using chkconfig to manage the system initialisation script" chkconfig ufdb resetpriorities chkconfig ufdb reset else if [ -x /usr/sbin/update-rc.d ] then echo "using update-rc.d to manage the system initialisation script" /usr/sbin/update-rc.d ufdb remove /usr/sbin/update-rc.d ufdb defaults else echo "LSB, chkconfig and update-rc.d were not detected," \ "so symbolic links to $INITDIR/ufdb must be created manually" fi fi fi fi } linux_systemd () { # not yet implemented install_unix } fix_piddir_permissions () { if [ -d "$DESTDIR/@ufdb_piddir@" ] then chmod 755 "$DESTDIR/@ufdb_piddir@" fi } case $OS in openbsd) install_openbsd ;; linux_systemd) install_linux_systemd ;; smoothwall) install_smoothwall ;; solaris_smf) install_solaris_smf ;; esac if [ -f "$SYSCFGFILE" ] then cp mtserver/sysconfig.ufdbguard $SYSCFGFILE.latest echo "$SYSCFGFILE exists. A new version is in $SYSCFGFILE.latest" copyparams $SYSCFGFILE.latest else cp mtserver/sysconfig.ufdbguard $SYSCFGFILE echo "System configuration settings file is $SYSCFGFILE" copyparams $SYSCFGFILE fi fix_piddir_permissions