CA_VERIFY_CLT=0 #to check PEER/server remote certificate
#------------------------------------------------
#Configured for Postgresql database
-#DB_TYPE can be either POSTGRES,MYSQL
+#DB_TYPE can be either POSTGRESQL,MYSQL
DB_TYPE=TO_BE_DEFINED
DB_NAME=mailleur
DB_HOST=localhost
%attr(0755,%{name},mail) %{_sbindir}/sorter
%attr(0754,root,root) %{_libdir}/%{name}/shell/*.sh
%attr(0754,root,root) %{_libdir}/%{name}/support/starting.sh
+%attr(0754,root,root) %{_libdir}/%{name}/support/crdb.sh
%attr(0755,%{name},mail) %dir %{spooldir}/%{name}/{queue,in.log,out.log}
#-----------------------------------------------------------------------------
%post postgresql
if [ "$1" = 1 ]; then
sed -i \
- -e "s/DB_TO_BE_DEFINED/POSTGRES/" \
+ -e "s/DB_TO_BE_DEFINED/POSTGRESQL/" \
%{_sysconfdir}/%{name}/%{name}.conf
fi
--- /dev/null
+#! /bin/sh
+#-------------------------------------------------------------
+#procedure to create the clement data-base the first
+#time the application is installed.
+#-------------------------------------------------------------
+#loading the variable value
+. /etc/mailleur/mailleur.conf
+#-------------------------------------------------------------
+
+#setting the Variable
+#first the Data-base type
+if [ -z "$DB_TYPE" ] ; then
+ DB_TYPE=POSTGRESQL;
+ fi
+
+#Then the data-base name
+if [ -z "$DB_NAME" ] ; then
+ DB_NAME=$APPNAME;
+ fi
+#-------------------------------------------------------------
+#moving to the right directory
+cd $1
+LOG=/etc/$APPNAME/dbinst.log
+USER=`id -nu`
+#building data_base
+case "$DB_TYPE" in
+ "MYSQL" )
+ ;;
+ "POSTGRESQL" )
+ SQL="psql -q"
+ if [ ! -z "$DB_PORT" ] ; then
+ SQLPORT="-p $DB_PORT"
+ fi
+ if [ ! -z "$DB_HOST" ] ; then
+ SQLHOST="-h $DB_HOST"
+ fi
+ /bin/echo "creating $DB_TYPE:$DB_NAME data-base" >> $LOG
+ if [ "$USER" = "root" ] ; then
+ chown $APPNAME $LOG
+ /bin/su - -m postgres >> $LOG << !EOT
+ echo "CREATE ROLE $APPNAME WITH LOGIN CREATEDB SUPERUSER" | \
+ $SQL $SQLHOST $SQLPORT template1
+ echo "CREATE ROLE apache WITH LOGIN" | \
+ $SQL $SQLHOST $SQLPORT template1
+ echo "CREATE ROLE dovecot WITH LOGIN" | \
+ $SQL $SQLHOST $SQLPORT template1
+ /usr/bin/createdb -T template0 -E $DB_LANG -O \
+ $APPNAME $SQLHOST $SQLPORT $DB_NAME
+!EOT
+ /bin/echo "data-base is now created" >> $LOG
+ fi
+ ;;
+ "*" )
+ #undefined database type at that stage?
+ ;;
+ esac
#Hard coded variables
APPNAME=mailleur
#===============================================================
-#----------------------------------------------------------------------
#reporting a big trouble
+#----------------------------------------------------------------------
sh_failure()
{
}
#----------------------------------------------------------------------
#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()
echo -e "\tAborting start, Exiting at once"
exit -1;
fi
+#----------------------------------------------------------------------
+#building application data-base
+#----------------------------------------------------------------------
+do_mkdb()
+
+{
+case "$DB_TYPE" in
+ "MYSQL" )
+ ;;
+ "POSTGRESQL" )
+ /usr/lib/$APPNAME/support/crdb.sh "/"
+ ;;
+ "TO_BE_DEFINED" )
+ echo "You must install $APPNAME with a DB flavor (ex: $APPNAME-pgsql, $APPNAME-mysql)"
+ echo "Exiting now"
+ exit -2;
+ ;;
+ "*" )
+ echo "Unexpectd DB_TYPE variable within /etc/sysconfig/$APPNAME, please check"
+ echo "Exiting now"
+ exit -3;
+ ;;
+ esac
+}
}
+#----------------------------------------------------------------------
+#setting local mailleur configuration
+#----------------------------------------------------------------------
+do_mkconf()
+{
+if [ ! -f /etc/$APPNAME/config.done ] ; then
+ do_mkdb ;
+ case "$OS" in
+ osukiss )
+ ;;
+ sysvinit )
+ ;;
+ systemd )
+ ;;
+ * )
+ echo "sh_mkconf: Unexpected OS=$OS, exiting!"
+ exit 1
+ ;;
+ esac
+ date > /etc/$APPNAME/config.done
+fi
+}
#===============================================================
#main script
#----------------------------------------------------------------------
[ -f /etc/sysconfig/$APPNAME ] && . /etc/sysconfig/$APPNAME
chk_config $1;
+do_mkconf $1;
exit 0;
#---------------------------------------------------------------