Refactoring of function executing scripts during initialization or container starting (#160)
* Refactoring of function running scripts * Update readme files * Update images with new docker-run script --------- Co-authored-by: Benoit Vianin <benoit.vianin@pixeleez.ch>
This commit is contained in:
@@ -138,8 +138,10 @@ Environment variables that are compatible with docker secrets:
|
||||
* `DOLI_CRON_USER` => `DOLI_CRON_USER_FILE`
|
||||
* `DOLI_INSTANCE_UNIQUE_ID` => `DOLI_INSTANCE_UNIQUE_ID_FILE`
|
||||
|
||||
## Add post-deployment scripts
|
||||
It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end of deployment by mounting a volume in `/var/www/scripts/docker-init.d`
|
||||
## Add post-deployment and before starting scripts
|
||||
It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end of deployment or before starting Apache by mounting volumes.
|
||||
For scripts executed during deployment mount volume in `/var/www/scripts/docker-init.d`.
|
||||
For scripts executed before Apache stating mount volume in `/var/www/scripts/before-starting.d`.
|
||||
```
|
||||
\docker-init.d
|
||||
|- custom_script.sql
|
||||
@@ -147,7 +149,7 @@ It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end
|
||||
|- custom_script.sh
|
||||
```
|
||||
|
||||
Mount the volume with compose file :
|
||||
Mount the volumes with compose file :
|
||||
```yaml
|
||||
services:
|
||||
mariadb:
|
||||
@@ -167,6 +169,7 @@ services:
|
||||
PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
|
||||
volumes :
|
||||
- volume-scripts:/var/www/scripts/docker-init.d
|
||||
- before-starting-scripts:/var/www/scripts/before-starting.d
|
||||
ports:
|
||||
- "80:80"
|
||||
links:
|
||||
|
||||
@@ -132,8 +132,10 @@ Environment variables that are compatible with docker secrets:
|
||||
* `DOLI_CRON_USER` => `DOLI_CRON_USER_FILE`
|
||||
* `DOLI_INSTANCE_UNIQUE_ID` => `DOLI_INSTANCE_UNIQUE_ID_FILE`
|
||||
|
||||
## Add post-deployment scripts
|
||||
It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end of deployment by mounting a volume in `/var/www/scripts/docker-init.d`
|
||||
## Add post-deployment and before starting scripts
|
||||
It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end of deployment or before starting Apache by mounting volumes.
|
||||
For scripts executed during deployment mount volume in `/var/www/scripts/docker-init.d`.
|
||||
For scripts executed before Apache stating mount volume in `/var/www/scripts/before-starting.d`.
|
||||
```
|
||||
\docker-init.d
|
||||
|- custom_script.sql
|
||||
@@ -141,7 +143,7 @@ It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end
|
||||
|- custom_script.sh
|
||||
```
|
||||
|
||||
Mount the volume with compose file :
|
||||
Mount the volumes with compose file :
|
||||
```yaml
|
||||
services:
|
||||
mariadb:
|
||||
@@ -161,6 +163,7 @@ services:
|
||||
PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
|
||||
volumes :
|
||||
- volume-scripts:/var/www/scripts/docker-init.d
|
||||
- before-starting-scripts:/var/www/scripts/before-starting.d
|
||||
ports:
|
||||
- "80:80"
|
||||
links:
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
@@ -129,6 +129,29 @@ function lockInstallation()
|
||||
chmod 400 /var/www/documents/install.lock
|
||||
}
|
||||
|
||||
function runScripts()
|
||||
{
|
||||
if [ -d /var/www/scripts/$1 ] ; then
|
||||
for file in /var/www/scripts/$1/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function initializeDatabase()
|
||||
{
|
||||
for fileSQL in /var/www/html/install/mysql/tables/*.sql; do
|
||||
@@ -172,25 +195,8 @@ function initializeDatabase()
|
||||
echo "Enable user module ..."
|
||||
php /var/www/scripts/docker-init.php
|
||||
|
||||
if [ -d /var/www/scripts/docker-init.d ] ; then
|
||||
for file in /var/www/scripts/docker-init.d/*; do
|
||||
[ ! -f $file ] && continue
|
||||
|
||||
# If extension is not in PHP SQL SH, we loop
|
||||
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
|
||||
[ -z "$isExec" ] && continue
|
||||
|
||||
echo "Importing custom ${isExec} from `basename ${file}` ..."
|
||||
if [ "$isExec" == "SQL" ] ; then
|
||||
sed -i 's/--.*//g;' ${file}
|
||||
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
|
||||
elif [ "$isExec" == "PHP" ] ; then
|
||||
php $file
|
||||
elif [ "$isExec" == "SH" ] ; then
|
||||
/bin/bash $file
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Run init scripts
|
||||
runScripts "docker-init.d"
|
||||
|
||||
# Update ownership after initialisation of modules
|
||||
chown -R www-data:www-data /var/www/documents
|
||||
@@ -256,6 +262,9 @@ function run()
|
||||
lockInstallation
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run scripts before starting
|
||||
runScripts "before-starting.d"
|
||||
}
|
||||
|
||||
DOLI_DB_USER=$(get_env_value 'DOLI_DB_USER' 'doli')
|
||||
|
||||
Reference in New Issue
Block a user