@@ -10,6 +10,11 @@ DRUSH=/var/www/vendor/bin/drush
1010mkdir -p ${PERSIST_DIR} /db ${PERSIST_DIR} /files
1111chown -R www-data:www-data ${PERSIST_DIR}
1212
13+ # Function to run commands as www-data
14+ run_as_www_data () {
15+ su www-data -s /bin/bash -c " $1 "
16+ }
17+
1318# Auto-install Drupal if DB is missing
1419if [ ! -f " ${DB_PATH} " ]; then
1520 echo " No DB found — installing PPUC Config Tool with SQLite..."
@@ -19,30 +24,30 @@ if [ ! -f "${DB_PATH}" ]; then
1924 exit 1
2025 fi
2126
22- # Run drush as www-data using su-exec
23- su-exec www-data ${DRUSH} site:install ppuc \
24- --site-name=" Pinball Power-Up Controller" \
27+ # Run drush as www-data
28+ run_as_www_data " ${DRUSH} site:install ppuc \
29+ --site-name=' Pinball Power-Up Controller' \
2530 --account-name=admin \
2631 --account-pass=admin \
2732 --existing-config \
28- --yes
33+ --yes"
2934
30- su-exec www-data ${DRUSH} dcdi \
35+ run_as_www_data " ${DRUSH} dcdi \
3136 --folder=sites/default/files/default_content \
3237 --preserve-ids \
33- --yes
38+ --yes"
3439
3540 echo " PPUC Config Tool installation completed."
3641else
3742 echo " Existing DB found - check for updates"
3843
39- # Run drush commands as www-data using su-exec
40- su-exec www-data ${DRUSH} deploy
44+ # Run drush commands as www-data
45+ run_as_www_data " ${DRUSH} deploy"
4146
42- su-exec www-data ${DRUSH} dcdi \
47+ run_as_www_data " ${DRUSH} dcdi \
4348 --folder=sites/default/files/default_content \
4449 --preserve-ids \
45- --yes
50+ --yes"
4651fi
4752
4853# Ensure permissions are correct
0 commit comments