Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Add auto-enable modules even custom #154

Merged
merged 3 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end
```
\docker-init.d
|- custom_script.sql
|- custom_script.php
|- custom_script.php // You should create your own module instead of doing this.
|- custom_script.sh
```

Expand Down
2 changes: 1 addition & 1 deletion README.template
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end
```
\docker-init.d
|- custom_script.sql
|- custom_script.php
|- custom_script.php // You should create your own module instead of doing this.
Vaadasch marked this conversation as resolved.
Show resolved Hide resolved
|- custom_script.sh
```

Expand Down
69 changes: 36 additions & 33 deletions docker-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,46 @@
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$dirMods = array_keys(dolGetModulesDirs())[0];

$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
$modName = 'mod'.$mod;
$modFile = $modName.'.class.php';
if (file_exists($dirMods.$modFile) ) {
printf("Activating module ".$mod." ...");
activateModule('mod' . $mod);
printf(" OK\n");
} else {
printf("Unable to find module : ".$modName."\n");
}
if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
Vaadasch marked this conversation as resolved.
Show resolved Hide resolved
}
else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
Vaadasch marked this conversation as resolved.
Show resolved Hide resolved
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
else {
printf(" OK\n");
}
}
catch (Throwable $t) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
}
}
1 change: 1 addition & 0 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function initializeDatabase()
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
# You should create your own module and activate it with DOLI_ENABLE_MODULES instead of doing that
Vaadasch marked this conversation as resolved.
Show resolved Hide resolved
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
Expand Down
69 changes: 36 additions & 33 deletions images/15.0.3-php7.4/docker-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,46 @@
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$dirMods = array_keys(dolGetModulesDirs())[0];

$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
$modName = 'mod'.$mod;
$modFile = $modName.'.class.php';
if (file_exists($dirMods.$modFile) ) {
printf("Activating module ".$mod." ...");
activateModule('mod' . $mod);
printf(" OK\n");
} else {
printf("Unable to find module : ".$modName."\n");
}
if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
else {
printf(" OK\n");
}
}
catch (Throwable $t) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
}
}
1 change: 1 addition & 0 deletions images/15.0.3-php7.4/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function initializeDatabase()
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
# You should create your own module and activate it with DOLI_ENABLE_MODULES instead of doing that
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
Expand Down
69 changes: 36 additions & 33 deletions images/16.0.5-php8.1/docker-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,46 @@
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$dirMods = array_keys(dolGetModulesDirs())[0];

$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
$modName = 'mod'.$mod;
$modFile = $modName.'.class.php';
if (file_exists($dirMods.$modFile) ) {
printf("Activating module ".$mod." ...");
activateModule('mod' . $mod);
printf(" OK\n");
} else {
printf("Unable to find module : ".$modName."\n");
}
if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
else {
printf(" OK\n");
}
}
catch (Throwable $t) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
}
}
1 change: 1 addition & 0 deletions images/16.0.5-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function initializeDatabase()
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
# You should create your own module and activate it with DOLI_ENABLE_MODULES instead of doing that
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
Expand Down
69 changes: 36 additions & 33 deletions images/17.0.4-php8.1/docker-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,46 @@
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$dirMods = array_keys(dolGetModulesDirs())[0];

$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
$modName = 'mod'.$mod;
$modFile = $modName.'.class.php';
if (file_exists($dirMods.$modFile) ) {
printf("Activating module ".$mod." ...");
activateModule('mod' . $mod);
printf(" OK\n");
} else {
printf("Unable to find module : ".$modName."\n");
}
if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
$db->commit();
}
else {
printf('Unable to find country '.$countryCode."\n");
}
if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
$db->commit();
if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
else {
printf(" OK\n");
}
}
catch (Throwable $t) {
print(" FAILED. Unable to find module. Be sure to check the case\n");
}
}
}
1 change: 1 addition & 0 deletions images/17.0.4-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function initializeDatabase()
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
# You should create your own module and activate it with DOLI_ENABLE_MODULES instead of doing that
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
Expand Down
Loading
Loading