diff --git a/build/deb/apache-cominclude.sh b/build/deb/apache-cominclude.sh new file mode 100644 index 00000000000..ec6c292cc18 --- /dev/null +++ b/build/deb/apache-cominclude.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# File: apache-cominclude.sh +# Changes: +# 20010219 Ola Lundqvist +# 20011022 Luca De Vitis +# Introduced the error variable. +# o /[[:space:]][[:space:]]*/[[:space:]]\+/ +# Changed from "cat $conffile | sed" to "sed ... < $conffile" +# 20020116 Ola Lundqvist +# Documented the error variable. +# Needs: $conffile - The file that should be modified. +# $includefile - The file that should be commented out. +# Description: Comments out a include statement. +# Sets: $status = {error, nothing, comment} +# $error = error message (if $status = error). + +status=error + +if [ -z "$conffile" ] ; then + error="No config file specified in apache-cominclude.sh" +elif [ -z "$includefile" ] ; then + error="No include file specified in apache-cominclude.sh" +elif [ ! -f $conffile ] ; then + error="File $conffile not found!" +elif [ ! -f $includefile ] ; then + error="File $includefile not found!" +else + status=nothing + if grep -e "^[[:space:]]*Include[[:space:]]\+$includefile\b" $conffile > /dev/null 2>&1; then + log="${log}Commenting import for $includefile in $conffile." + status=comment + sed -e "s#^\( *\)\(Include *$includefile\b\)#\1\#\2#" < $conffile > $conffile.new + mv $conffile.new $conffile + fi +fi diff --git a/build/deb/apache-include.sh b/build/deb/apache-include.sh new file mode 100644 index 00000000000..e32caa7925c --- /dev/null +++ b/build/deb/apache-include.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# File: apache-include.sh +# Changes: +# 20010219 Ola Lundqvist +# 20011022 Luca De Vitis +# Introduced the error variable. +# o /[[:space:]][[:space:]]*/[[:space:]]\+/ +# 20020116 Ola Lundqvist +# Documented the error variable. +# Needs: $conffile - where the config file is. +# $includefile - what file that should not be included. +# /usr/share/wwwconfig-common/apache-uncominclude.sh +# Description: Includes a file in a apache config file. +# If it is not included (and commented) it will be added +# at the bottom of the file. +# Sets: $status = {error, nothing, include, uncomment} +# $error = error message (if $status = error). + +status=error +if [ -z "$conffile" ] ; then + error="No config file specified in apache-include.sh" +elif [ -z "$includefile" ] ; then + error="No include file specified in apache-include.sh" +elif [ ! -f $conffile ] ; then + error="File $conffile not found!" +elif [ ! -f $includefile ] ; then + error="File $includefile not found!" +else + status=nothing + . /usr/share/dolibarr/build/deb/apache-uncominclude.sh + if [ "$status" = "nothing" ] ; then + if ! grep -e "Include[[:space:]]\+$includefile\b" $conffile > /dev/null 2>&1; then + status=include + log="${log}Including $includefile in $conffile." + echo "Include $includefile" >> $conffile + fi + fi +fi diff --git a/build/deb/apache-include_all.sh b/build/deb/apache-include_all.sh new file mode 100644 index 00000000000..7f76e895d83 --- /dev/null +++ b/build/deb/apache-include_all.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# File: apache-include_all.sh +# Changes: +# 20010219 Ola Lundqvist +# 20011022 Luca De Vitis +# Introduced the error variable. +# o /[[:space:]][[:space:]]*/[[:space:]]\+/ +# Reduced the 3 assignment in the function to a single sed +# script. +# 20020116 Ola Lundqvist +# Documented the error variable. +# 20020412 Ola Lundqvist +# Added check for if the server is installed. +# Needs: $server - what apache server that should be configured. +# That can be any matching /etc/$server/*.conf +# $includefile - what file that should not be included. +# /usr/share/wwwconfig-common/apache-uncominclude.sh +# /usr/share/wwwconfig-common/apache-include.sh +# Description: Includes a file in a apache config file. +# If it is not included (and commented) it will be added +# at the bottom of the file. +# It first checks for if any in the server +# Sets: $status = {error, nothing, uncomment, include} +# $error = error message (if $status = error). + +status=error + +if [ -z "$includefile" ] ; then + error="No include file specified for apache-include_all.sh." +elif [ ! -f $includefile ] ; then + error="Includefile $includefile not found in apache-include_all.sh." +elif [ ! -d /etc/$server ] ; then + error="No server $server installed, unable to configure it." +else + status=nothing + if grep -e "Include[[:space:]]\+$includefile" /etc/$server/*.conf > /dev/null 2>&1; then + lstatus=nothing + log="${log}Include of $includefile found in apache config files." + for conffile in /etc/$server/*.conf; do + . /usr/share/dolibarr/build/deb/apache-uncominclude.sh + if [ "$status" = "uncomment" ] ; then + lstatus=$status + fi + done + status=$lstatus + else + conffile=/etc/$server/httpd.conf + . /usr/share/dolibarr/build/deb/apache-include.sh + status=include + fi +fi diff --git a/build/deb/apache-uncominclude.sh b/build/deb/apache-uncominclude.sh new file mode 100644 index 00000000000..192e2704f47 --- /dev/null +++ b/build/deb/apache-uncominclude.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# File: apache-uncominclude.sh +# Changes: +# 20010219 Ola Lundqvist +# 20011022 Luca De Vitis +# Introduced the error variable. +# o /[[:space:]][[:space:]]*/[[:space:]]\+/ +# Changed from "cat $conffile | sed" to "sed ... < $conffile" +# 20020116 Ola Lundqvist +# Documented the error variable. +# Needs: $conffile - The file that should be modified. +# $includefile - The file that should not be included. +# Description: Comments out a include statement. +# Sets: $status = {error, nothing, uncomment} +# $error = error message (if $status = error). + +status=error + +if [ -z "$conffile" ] ; then + error="No config file specified in apache-uncominclude.sh" +elif [ -z "$includefile" ] ; then + error="No include file specified in apache-uncominclude.sh" +elif [ ! -f $conffile ] ; then + error="File $conffile not found!" +elif [ ! -f $includefile ] ; then + error="File $includefile not found!" +else + status=nothing + if grep -e "^[[:space:]]*#[[:space:]]*Include[[:space:]]\+$includefile\b" $conffile > /dev/null 2>&1; then + log="${log}Uncommenting import for $includefile in $conffile" + status=uncomment + sed -e "s|^\([[:space:]]*\)#\([[:space:]]*Include[[:space:]][[:space:]]*$includefile\b\)|\1\2|g;" < $conffile > $conffile.new + mv $conffile.new $conffile + fi +fi diff --git a/build/deb/control b/build/deb/control index 0f74c4d8818..f751f6c5563 100644 --- a/build/deb/control +++ b/build/deb/control @@ -6,7 +6,7 @@ Maintainer: Laurent Destailleur Package: dolibarr Architecture: all Essential: no -Depends: wwwconfig-common, apache2, libapache2-mod-php5, php5, php5-cgi, php5-curl, php5-gd, php5-imagick, php5-ldap, php5-mcrypt, php5-mysql, mysql-server, perl +Depends: apache2, libapache2-mod-php5, php5, php5-cgi, php5-curl, php5-gd, php5-ldap, php5-mysql, mysql-server, perl Recommends: mozilla | netscape Installed-Size: 31200 Homepage: http://www.dolibarr.org diff --git a/build/deb/postinst b/build/deb/postinst index 886dcfedcea..8ff7bf5f5bb 100644 --- a/build/deb/postinst +++ b/build/deb/postinst @@ -109,7 +109,7 @@ case "$1" in includefile="/etc/dolibarr/apache.conf" #echo "$includefile $server" - . /usr/share/wwwconfig-common/apache-include_all.sh + . /usr/share/dolibarr/build/deb/apache-include_all.sh test "$status" = "uncomment" -o "$status" = "include" && restart="$server $restart" # (useless) @@ -151,7 +151,7 @@ case "$1" in # Another way to restart for server in $servers ; do if [ -x /usr/sbin/invoke-rc.d ]; then - # This on works with Debian 5 + # This on works with Debian (5.05,...) and Ubuntu (9.10,10.04,...) invoke-rc.d $server reload || true else /etc/init.d/$server reload || true diff --git a/build/deb/postrm b/build/deb/postrm index df1bbd08ed6..f32de396c58 100644 --- a/build/deb/postrm +++ b/build/deb/postrm @@ -99,7 +99,48 @@ case "$1" in # mysql # /usr/share/wwwconfig-common/mysql.get echo "postrm Delete database $dbname on server $dbserver using account $dbadmin" - . /usr/share/wwwconfig-common/${dbtype}-dropdb.sh + + # Define mysqlcmd + if [ -z "$dbserver" ] || [ "$dbserver" = "localhost" ]; then + hostopt="" + dbserver=localhost + else + case "$dbserver" in + :*) + dbsocket=`echo $dbserver | sed -e 's/^://'` + hostopt="-S $dbsocket" + ;; + *) + hostopt="-h $dbserver" + ;; + esac + fi + if [ -z "$dbadmpass" ] ; then + log="${log}No password used." + passopt="" + else + passopt="--password='"`echo "$dbadmpass" | sed -e "s/'/'"'"'"'"'"'"'/g"`"'" + fi + mysqlcmd="mysql $hostopt $passopt -u $dbadmin" + + # Now run the drop commands + if eval $mysqlcmd -f -e "\"show databases;\"" | grep -e "^$dbname" > /dev/null 2>&1 ; then + log="${log}Droping database $dbname." + if eval $mysqlcmd -f -e "\"DROP DATABASE $dbname;\"" ; then + if eval $mysqlcmd -f -e "\"show databases;\"" | grep -e "^$dbname" > /dev/null 2>&1 ; then + error="Database $dbname NOT successfully droped. You have to do it manually." + echo $error + else + status=drop + fi + else + error="Unable to run the drop database script." + echo $error + fi + else + status=nothing + log="${log}Database $dbname already not exists." + fi else echo "postrm Delete of dolibarr database not wanted" @@ -117,7 +158,13 @@ case "$1" in # We disable set -e to avoid premature end of script if error echo postrm remove dolibarr include from /etc/dolibarr/apache.conf set +e - . /usr/share/wwwconfig-common/apache-uninclude.sh + GREP="Include[[:space:]]\+$includefile\b" + if grep -e "$GREP" $conffile > /dev/null 2>&1; then + log="${log}Include of $includefile found in $conffile file, purging." + status=purge + grep -v -e "$GREP" < $conffile > $conffile.purg + mv $conffile.purg $conffile + fi set -e fi fi