diff --git a/.github/workflows/shell.yml b/.github/workflows/shell.yml index 2390f36..99a4618 100644 --- a/.github/workflows/shell.yml +++ b/.github/workflows/shell.yml @@ -107,5 +107,8 @@ jobs: - name: Clear cache run: ./bin/clear-cache.sh + - name: Set permissions + run: ./bin/set-perm.sh + - name: Reinstall CiviCRM run: ./bin/reinstall.sh . --sample diff --git a/README.md b/README.md index e68560e..dce3dea 100644 --- a/README.md +++ b/README.md @@ -99,3 +99,12 @@ However if you plan to use it for development, there are several utility scripts INSTALL_DIR: Installation dir (the same dir where you installed in step #4). Defaults to civi-zero project dir. ``` + +- `bin/set-perm.sh`: Set file permissions. + + ``` + set-perm.sh [INSTALL_DIR] + + INSTALL_DIR: Installation dir (the same dir where you installed in step #4). + Defaults to civi-zero project dir. + ``` diff --git a/bin/install.sh b/bin/install.sh index 29db958..62a9352 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -106,10 +106,10 @@ print-header Install Drupal... --account-pass="${civi_pass}" \ --site-name="${civi_site}" \ --yes -sudo chown -R "${USER}:www-data" "${install_dir}" -sudo chmod -R u+w,g+r "${install_dir}" print-finish +"${base_dir}/bin/set-perm.sh" "${install_dir}" + print-header Enable Drupal modules... "${install_dir}/vendor/bin/drush" pm:enable --root "${install_dir}" --yes "${drupal_modules}" print-finish @@ -152,14 +152,7 @@ if [[ -n "${load_sample}" ]]; then print-finish fi -print-status Set permissions... -# Base -sudo chown -R "${USER}:www-data" "${install_dir}" -sudo chmod -R u+w,g+r "${install_dir}" -# Files -sudo chown -R www-data:www-data "${install_dir}/web/sites/default/files" -sudo chmod -R g+w "${install_dir}/web/sites/default/files" -print-finish +"${base_dir}/bin/set-perm.sh" "${install_dir}" print-status Update civicrm.settings.php... sed -i \ diff --git a/bin/set-perm.sh b/bin/set-perm.sh new file mode 100755 index 0000000..0ab2d11 --- /dev/null +++ b/bin/set-perm.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +################################################## +## civi-zero ## +## ## +## Set file permissions ## +## ## +## Options: ## +## $1 Install dir, where CiviCRM is installed ## +################################################## + +# Strict mode +set -eufo pipefail +IFS=$'\n\t' + +# Include library +base_dir=$(builtin cd "$(dirname "${0}")/.." >/dev/null 2>&1 && pwd) +# shellcheck source=bin/library.sh +. "${base_dir}/bin/library.sh" + +# Include configs +# shellcheck source=cfg/install.cfg +. "${base_dir}/cfg/install.cfg" +# shellcheck disable=SC1091 +[[ -r "${base_dir}/cfg/install.local.cfg" ]] && . "${base_dir}/cfg/install.local.cfg" + +# Parse options +install_dir="${1:-${base_dir}}" +install_dir=$(realpath "${install_dir}") + +print-status Set permissions... +# Base +sudo chown -R "${USER}:www-data" "${install_dir}" +sudo chmod -R u+rw,g+r "${install_dir}" +# Files +sudo chmod -R g+w "${install_dir}/web/sites/default/files" +print-finish + +exit 0