diff --git a/install/alternc.install b/install/alternc.install index b152fdbe..f0318208 100755 --- a/install/alternc.install +++ b/install/alternc.install @@ -90,6 +90,23 @@ lock_jobs # hook run-parts --arg=startup /usr/lib/alternc/install.d +####################################################################### +# Enter the initial database configuration if needed +# + +# Creating admin user if needed +# This is done before any templating, since it adds the default database server. +# User feedback is provided near the end of the script. +HAS_ROOT=`mysql --defaults-file=/etc/alternc/my.cnf -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1` +if [ "$HAS_ROOT" != "1" ] ; then + echo "Creating admin user..." + echo "" + + su - alterncpanel -s /bin/bash -c /usr/share/alternc/install/newone.php + NEWONE_RETVAL=$? +fi + + ####################################################################### # Script configuration # @@ -606,15 +623,8 @@ chown alterncpanel:adm /var/log/alternc/bureau.log /var/log/alternc/update_domai # Launch a script that will populate AlternC variables as needed su - alterncpanel -s /bin/bash -c /usr/share/alternc/install/variables.php -# Creating admin user if needed -HAS_ROOT=`mysql --defaults-file=/etc/alternc/my.cnf -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1` - if [ "$HAS_ROOT" != "1" ]; then - echo "Creating admin user..." - echo "" - - if su - alterncpanel -s /bin/bash -c /usr/share/alternc/install/newone.php - then + if [ "$NEWONE_RETVAL" ] ; then echo "*******************************************" echo "* *" echo "* Admin account *" @@ -626,7 +636,7 @@ if [ "$HAS_ROOT" != "1" ]; then echo "* *" echo "*******************************************" else - echo "Unable to create the first AlternC account (named 'admin'). newone.php returned $?. Check your MySQL database, PHP, and the /etc/alternc/local.sh file. Also check for any error above during install." + echo "Unable to create the first AlternC account (named 'admin'). newone.php returned $NEWONE_RETVAL. Check your MySQL database, PHP, and the /etc/alternc/local.sh file. Also check for any error above during install." fi else ##UPDATE default db_server following /etc/alternc/my.cnf values