Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set-perm.sh #78

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/workflows/shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```
13 changes: 3 additions & 10 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
38 changes: 38 additions & 0 deletions bin/set-perm.sh
Original file line number Diff line number Diff line change
@@ -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