mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 01:23:03 +01:00
166 lines
3.8 KiB
Bash
166 lines
3.8 KiB
Bash
#!/bin/sh
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
# change init.d RunUser
|
|
|
|
changeInitRunUser() {
|
|
NewUser=$1
|
|
|
|
InitFile=`getInitScriptLocation`
|
|
if [ -f $InitFile ]
|
|
then
|
|
editFile $InitFile FBRunUser "FBRunUser=$NewUser"
|
|
chmod u=rwx,g=rx,o= $InitFile
|
|
fi
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
# installInitdScript
|
|
# Everbody stores this one in a seperate location, so there is a bit of
|
|
# running around to actually get it for each packager.
|
|
# Update rcX.d with Firebird initd entries
|
|
# initd script for SuSE >= 7.2 is a part of RPM package
|
|
|
|
installInitdScript() {
|
|
|
|
srcScript=""
|
|
initScript=
|
|
|
|
# This is for RH and MDK specific
|
|
|
|
if [ -e /etc/rc.d/init.d/functions ]
|
|
then
|
|
srcScript=firebird.init.d.mandrake
|
|
initScript=/etc/rc.d/init.d/firebird
|
|
|
|
# SuSE specific
|
|
|
|
elif [ -r /etc/SuSE-release ]
|
|
then
|
|
srcScript=firebird.init.d.suse
|
|
initScript=/etc/init.d/firebird
|
|
rm -f /usr/sbin/rcfirebird
|
|
ln -s ../../etc/init.d/firebird /usr/sbin/rcfirebird
|
|
|
|
# Debian specific
|
|
|
|
elif [ -r /etc/debian_version ]
|
|
then
|
|
srcScript=firebird.init.d.debian
|
|
initScript=/etc/init.d/firebird
|
|
rm -f /usr/sbin/rcfirebird
|
|
ln -s ../../etc/init.d/firebird /usr/sbin/rcfirebird
|
|
|
|
# Slackware specific
|
|
|
|
elif [ -r /etc/slackware-version ]
|
|
then
|
|
srcScript=firebird.init.d.slackware
|
|
initScript=/etc/rc.d/rc.firebird
|
|
rclocal=/etc/rc.d/rc.local
|
|
if ! grep -q "$initScript" $rclocal
|
|
then
|
|
cat >>$rclocal <<EOF
|
|
if [ -x $initScript ] ; then
|
|
$initScript start
|
|
fi
|
|
EOF
|
|
fi
|
|
|
|
# Gentoo specific
|
|
|
|
elif [ -r /etc/gentoo-release ]
|
|
then
|
|
srcScript=firebird.init.d.gentoo
|
|
initScript=/etc/init.d/firebird
|
|
|
|
# Generic...
|
|
|
|
elif [ -d /etc/rc.d/init.d ]
|
|
then
|
|
srcScript=firebird.init.d.generic
|
|
initScript=/etc/rc.d/init.d/firebird
|
|
fi
|
|
|
|
|
|
if [ "$initScript" ]
|
|
then
|
|
# Install the firebird init.d script
|
|
cp $FBRootDir/misc/$srcScript $initScript
|
|
chown root:root $initScript
|
|
chmod ug=rx,o=r $initScript
|
|
|
|
|
|
# RedHat and Mandrake specific
|
|
if [ -x /sbin/chkconfig ]
|
|
then
|
|
/sbin/chkconfig --add firebird
|
|
|
|
# Gentoo specific
|
|
elif [ -x /sbin/rc-update ]
|
|
then
|
|
/sbin/rc-update add firebird default
|
|
|
|
# Suse (& Debian ?) specific
|
|
elif [ -x /sbin/insserv ]
|
|
then
|
|
/sbin/insserv /etc/init.d/firebird
|
|
|
|
# One more way to register service - used in Knoppix (& Debian ?)
|
|
elif [ -x /usr/sbin/update-rc.d ]
|
|
then
|
|
/usr/sbin/update-rc.d firebird start 14 2 3 5 . stop 20 0 1 6 .
|
|
fi
|
|
|
|
# More SuSE - rc.config fillup
|
|
if [ -f /etc/rc.config ]
|
|
then
|
|
if [ -x /bin/fillup ]
|
|
then
|
|
/bin/fillup -q -d = /etc/rc.config $FBRootDir/misc/rc.config.firebird
|
|
fi
|
|
elif [ -d /etc/sysconfig ]
|
|
then
|
|
cp $FBRootDir/misc/rc.config.firebird /etc/sysconfig/firebird
|
|
fi
|
|
|
|
else
|
|
echo "Couldn't autodetect linux type. You must select"
|
|
echo "the most appropriate startup script in $FBRootDir/misc/"
|
|
echo "and manually register it in your OS."
|
|
fi
|
|
|
|
# Create directory to store pidfile
|
|
if [ ! -d $PidDir ]
|
|
then
|
|
[ -e $PidDir ] && rm -rf $PidDir
|
|
mkdir $PidDir
|
|
fi
|
|
chown $RunUser:$RunGroup $PidDir
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
# start init.d service
|
|
|
|
startService() {
|
|
InitFile=`getInitScriptLocation`
|
|
if [ -f $InitFile ]
|
|
then
|
|
$InitFile start
|
|
|
|
checkString=`ps -efww| grep fbserver |grep -v grep`
|
|
if [ -z "$checkString" ]
|
|
then
|
|
# server didn't start - possible reason bad shell /bin/false for user "firebird"
|
|
echo
|
|
echo Fixing firebird\'s shell to /bin/sh
|
|
echo
|
|
usermod -s /bin/sh firebird
|
|
$InitFile start
|
|
fi
|
|
fi
|
|
}
|