From 231947b2bac3d7744626bb95f927683689fd9f47 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 18 Jun 2025 08:50:38 -0400 Subject: [PATCH] Improving starting.sh --- conf/mailleur.conf | 5 ++--- mailleur.spec.in | 13 +++++++++++++ support/starting.sh | 28 ++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/conf/mailleur.conf b/conf/mailleur.conf index 24073d1..4690934 100644 --- a/conf/mailleur.conf +++ b/conf/mailleur.conf @@ -30,9 +30,8 @@ CA_KEY_CLT = "./certs/localhost-key.pem" CA_VERIFY_CLT = 0 #to check PEER/server remote certificate #------------------------------------------------ #Configured for Postgresql database -#DB_TYPE can be either POSTGRES,MYSQL, default POSTGRES -#DB_TYPE = MYSQL -DB_TYPE = POSTGRES +#DB_TYPE can be either POSTGRES,MYSQL +DB_TYPE = DB_TO_BE_DEFINED DB_NAME = mailleur DB_HOST = localhost DB_PORT = 5432 diff --git a/mailleur.spec.in b/mailleur.spec.in index 74d3d25..9f33178 100644 --- a/mailleur.spec.in +++ b/mailleur.spec.in @@ -145,6 +145,13 @@ Obsoletes : %{name}-mysql <= %{version}-%{release} %files postgresql %defattr(-,root,root,-) +%post +if [ "$1" = 1 ]; then + sed -i \ + -e "s/DB_TO_BE_DEFINED/POSTGRES/" \ + %{_sysconfdir}/%{name}/%{name}.conf + fi + #============================================================================= %package mysql Summary : mailleur using mysql/mariadb as Data-base @@ -163,6 +170,12 @@ Obsoletes : %{name}-postgresql <= %{version}-%{release} %files mysql %defattr(-,root,root,-) +%post +if [ "$1" = 1 ]; then + sed -i \ + -e "s/DB_TO_BE_DEFINED/MYSQL/" \ + %{_sysconfdir}/%{name}/%{name}.conf + fi #============================================================================= %prep %setup -q diff --git a/support/starting.sh b/support/starting.sh index adbdaf1..2db71a6 100644 --- a/support/starting.sh +++ b/support/starting.sh @@ -1,5 +1,29 @@ #! /usr/bin/bash #--------------------------------------------------------------- -#empty scrript for now +#program to check everything is ready to start clement +#$1 is either "sysvinit", "systemd" or "osukiss +#=============================================================== +OS=$1 #set the OS Type +#Hard coded variables +APPNAME=mailleur +#=============================================================== +#procedure to check if the config is properly done +#you MUST AT LEAST, specify the Data Base type to be used by clement. +#---------------------------------------------------------------------- +chk_config() + +{ +if [ -z "$DB_TYPE" -o "$DB_TYPE" = "DB_TO_BE_DEFINED" ] ; then + echo -n "Checking file /etc/$APPNAME/$APPNAME.conf" + sh_failure $1 $" ->> not configured" + echo -e "\tPlease set DB_TYPE within /etc/$APPNAME/$APPNAME.conf" + echo -e "\tAborting start, Exiting at once" + exit -1; + fi +} + +#=============================================================== +#main script +chk_config $1; +exit 0; #--------------------------------------------------------------- -exit 0 -- 2.47.3