From: Jean-Marc Pigeon (Delson) Date: Thu, 26 Jun 2025 16:36:36 +0000 (-0400) Subject: postgresql sql config near working X-Git-Tag: tag-0.10~9 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=0cb7cceddca8256d9cf9c0fe0464f55cbe9255c2;p=jmp%2Fmailleur postgresql sql config near working --- diff --git a/mailleur.spec.in b/mailleur.spec.in index 48a5628..3562422 100644 --- a/mailleur.spec.in +++ b/mailleur.spec.in @@ -51,6 +51,7 @@ search about email exchange within time and transaction context. %attr(0754,root,root) %{_libdir}/%{name}/support/dummy-cert.sh %attr(0754,root,root) %{_libdir}/%{name}/support/starting.sh %attr(0750,%{name},mail) %{_libdir}/%{name}/support/mailleur-reset-db.sh +%attr(0750,%{name},mail) %{_libdir}/%{name}/support/mailleur-settest-db.sh %attr(0755,%{name},mail) %dir %{spooldir}/%{name}/{in-logs,queue,out-logs} %attr(0750,%{name},mail) %dir %{spooldir}/%{name}/mails %attr(0640,root,root) %{_datadir}/%{name}/sql/Makefile diff --git a/sql/datatest.sql b/sql/datatest.sql index 1207b63..7f02dc7 100644 --- a/sql/datatest.sql +++ b/sql/datatest.sql @@ -1,6 +1,8 @@ #include "datatest.def" +//First remove ALL Email data +DELETE FROM emails; //password is generated via command line: //openssl password //present password is crypte 'mailleur' diff --git a/support/addconfig.sh b/support/addconfig.sh index 608a577..fa54371 100755 --- a/support/addconfig.sh +++ b/support/addconfig.sh @@ -27,7 +27,7 @@ case "$DB_TYPE" in echo "driver = pgsql" echo "connect= dbname=$APPNAME" echo "password_query=SELECT password FROM emails WHERE email='%u'" - echo "user_query=SELECT 'mailleur' AS uid,'mail' AS gid,'$SPOOLDIR/%d/%n' AS home,'maildir:~/dovecot' AS mail,'*:storage='||mxspace||'M' AS quota_rule FROM email WHERE email='%u'" + echo "user_query=SELECT 'mailleur' AS uid,'mail' AS gid,'$SPOOLDIR/%d/%n' AS home,'maildir:~' AS mail,'*:storage='||mxspace||'M' AS quota_rule FROM emails WHERE email='%u'" ;; "MYSQL" ) diff --git a/support/mailleur-reset-db.sh b/support/mailleur-reset-db.sh index 3f5392f..a1e5925 100755 --- a/support/mailleur-reset-db.sh +++ b/support/mailleur-reset-db.sh @@ -70,4 +70,4 @@ case "$DB_TYPE" in #loading database cpp -P -D$DB_TYPE $ROOTBASE/usr/share/$APPNAME/sql/$APPNAME.sql | $SQL -cpp -P -D$DB_TYPE $ROOTBASE/usr/share/$APPNAME/sql/datatest.sql | $SQL +#cpp -P -D$DB_TYPE $ROOTBASE/usr/share/$APPNAME/sql/datatest.sql | $SQL diff --git a/support/mailleur-settest-db.sh b/support/mailleur-settest-db.sh new file mode 100755 index 0000000..5169cb3 --- /dev/null +++ b/support/mailleur-settest-db.sh @@ -0,0 +1,61 @@ +#! /usr/bin/bash +#--------------------------------------------------------------- +#program to reset the database contents +#parameters ["doit"] "confdirectory +#--------------------------------------------------------------- +#start delay +APPLICATION=mailleur +DELAY=10 +DOIT=doit +#--------------------------------------------------------------- +OWNER=`stat -c '%U' $0` +USER=`id -nu` +if [ "$USER" != "$OWNER" ] ; then + echo "" + echo "-----------" + echo "ATTENTION! $0 MUST BE executed by $0 file owner, exiting" + echo "-----------" + exit 1 + fi +#--------------------------------------------------------------- +if [ $# -eq 0 -o $# -ge 1 -a "$1" != "$DOIT" ] ; then + echo "" + echo "-----------" + echo "ATTENTION!:" + echo "- You are requesting a FULL database PRERESET." + echo "" + echo "SOME database data will be GONE forever and replace by test value." + echo "Are you sure!" + echo "You have $DELAY seconds to cancel (CTRL-C)" + echo "-----------" + sleep $DELAY + fi +if [ -n "$1" -a "$1" == "$DOIT" ] ; then + shift; + fi +CONF=/etc/$APPLICATION/$APPLICATION.conf +if [ $# -gt 0 ] ; then + CONF=$1 + fi +if [ ! -f $CONF ] ; then + echo "configuration file $CONF is missing, exiting!" + exit 1 + fi +. $CONF +#--------------------------------------------------------------- +#destroying the database +case "$DB_TYPE" in + "POSTGRESQL" ) + SQL="psql -q $APPNAME" + ;; + "MYSQL" ) + SQL="mariadb -q $APPNAME" + ;; + * ) + echo $DB_TYPE is not expected!, check configuration file! + exit 1 + ;; + esac + +#RE loading database +cpp -P -D$DB_TYPE $ROOTBASE/usr/share/$APPNAME/sql/datatest.sql | $SQL