]> SAFE projects GIT repository - jmp/mailleur/commitdiff
postgresql sql config near working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 26 Jun 2025 16:36:36 +0000 (12:36 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 26 Jun 2025 16:36:36 +0000 (12:36 -0400)
mailleur.spec.in
sql/datatest.sql
support/addconfig.sh
support/mailleur-reset-db.sh
support/mailleur-settest-db.sh [new file with mode: 0755]

index 48a5628be89b1bbc7d7db13c2f3a10885460ad13..3562422dfab31cbd254c218d887f54a0a1b8ee2a 100644 (file)
@@ -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
index 1207b63983191bcb2c7edb9975ab68155aef4015..7f02dc7b6c193bf37982a13c6ee8b04a63562068 100644 (file)
@@ -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'
index 608a57777780ad7ce59e6ff95cd344dbe89f2f98..fa5437169bcbbff15dc30f80517cb10fb6d2b30f 100755 (executable)
@@ -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"             )
index 3f5392f45a3313a21995164850e08df7c4addb7f..a1e592508ea5df75b46e49cae34fd372a7900a3b 100755 (executable)
@@ -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 (executable)
index 0000000..5169cb3
--- /dev/null
@@ -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