install ()
{
-if [ -f ${INIFILE} ]; then
+if [ -f ${INIFILE} ] && ! grep -q "^extension[[:space:]]*=[[:space:]]*${MODNAME}.so" ${INIFILE} ; then
echo "activating module '${MODNAME}.so' in ${INIFILE}" 1>&2
- perl -pi -e "s|^;extension=${MODNAME}.so|extension=${MODNAME}.so|g" ${INIFILE}
+ echo "extension=${MODNAME}.so" >> ${INIFILE}
fi
if [ -f /var/lock/subsys/httpd ]; then
/etc/rc.d/init.d/httpd restart 1>&2
deinstall()
{
-if [ -f ${INIFILE} ]; then
+if [ -f ${INIFILE} ] && grep -q "^extension[[:space:]]*=[[:space:]]*${MODNAME}.so" ${INIFILE} ; then
+ TMPFILE=`mktemp -q /tmp/php-module-install.XXXXXX`
+ if [ $? -ne 0 ]; then
+ echo "$0: Can't create temp file, exiting..."
+ exit 1
+ fi
echo "deactivating module '${MODNAME}.so' in ${INIFILE}" 1>&2
- perl -pi -e "s|^extension=${MODNAME}.so|;extension=${MODNAME}.so|g" $INIFILE
+ grep -v "^extension[[:space:]]*=[[:space:]]*${MODNAME}.so" > ${TMPFILE} < ${INIFILE}
+ mv ${TMPFILE} ${INIFILE}
+ chmod 644 ${INIFILE}
fi
if [ -f /var/lock/subsys/httpd ]; then
/etc/rc.d/init.d/httpd restart 1>&2
MODNAME="$2"
INIFILE="$3"
- if [ "$1" = "install"]; then
+ if [ "$1" = "install" ]; then
install
else
- if [ "$1" = "remove"]; then
- remove
+ if [ "$1" = "remove" ]; then
+ deinstall
else
usage
fi
exit 1
fi
+exit 0