Skip to content

Commit

Permalink
Merge pull request #547 from SvenRoederer/improve-set-permissions
Browse files Browse the repository at this point in the history
speed up ensuring correct file-permissions are set
  • Loading branch information
jcormier authored Feb 27, 2024
2 parents 11d4e33 + 062e3ff commit 627a0f0
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -789,28 +789,6 @@ initialize_logdir() {

initialize_datadir() {
echo "Initializing datadir..."
chmod -R u+rw,go+r ${REDMINE_DATA_DIR}
chown -R ${REDMINE_USER}: ${REDMINE_DATA_DIR}

# create plugins directory
mkdir -p ${REDMINE_PLUGINS_DIR}
chmod -R u+rw,go+r ${REDMINE_PLUGINS_DIR}
chown -R ${REDMINE_USER}: ${REDMINE_PLUGINS_DIR}

# create themes directory
mkdir -p ${REDMINE_THEMES_DIR}
chmod -R u+rw,go+r ${REDMINE_THEMES_DIR}
chown -R ${REDMINE_USER}: ${REDMINE_THEMES_DIR}

# create attachments directory
mkdir -p ${REDMINE_ATTACHMENTS_DIR}
chmod -R u+rw,go+r ${REDMINE_ATTACHMENTS_DIR}
chown -R ${REDMINE_USER}: ${REDMINE_ATTACHMENTS_DIR}

# create backups directory
mkdir -p ${REDMINE_BACKUPS_DIR}
chmod -R u+rw,go+r ${REDMINE_BACKUPS_DIR}
chown -R ${REDMINE_USER}: ${REDMINE_BACKUPS_DIR}

if [[ -d /redmine/files ]]; then # deprecated
echo "WARNING: "
Expand All @@ -819,23 +797,27 @@ initialize_datadir() {
exit 1
fi

# create dotfiles directory
mkdir -p ${REDMINE_DOTFILES_DIR}
chmod -R u+rw,go+r ${REDMINE_DOTFILES_DIR}
chown -R ${REDMINE_USER}: ${REDMINE_DOTFILES_DIR}
# create relevant folders and/or fix permissions
datafolders=(
"${REDMINE_DATA_DIR}"
"${REDMINE_PLUGINS_DIR}"
"${REDMINE_THEMES_DIR}"
"${REDMINE_ATTACHMENTS_DIR}"
"${REDMINE_BACKUPS_DIR}"
"${REDMINE_DOTFILES_DIR}"
"${REDMINE_DOTFILES_DIR}/.subversion"
"${REDMINE_DATA_DIR}/tmp"
)
for dir in "${datafolders[@]}"; do
mkdir -p "${dir}"
find "${dir}" \! -perm -u=wr,go=r -print0 | xargs -0 -r chmod u+rw,go+r
find "${dir}" \! -user ${REDMINE_USER} -print0 | xargs -0 -r chown ${REDMINE_USER}:
done

# special permissions for ~/.ssh
mkdir -p ${REDMINE_DOTFILES_DIR}/.ssh
chmod -R u+rw,go-rwx ${REDMINE_DOTFILES_DIR}/.ssh
chown -R ${REDMINE_USER}: ${REDMINE_DOTFILES_DIR}/.ssh

mkdir -p ${REDMINE_DOTFILES_DIR}/.subversion
chmod -R u+rw,go+r ${REDMINE_DOTFILES_DIR}/.subversion
chown -R ${REDMINE_USER}: ${REDMINE_DOTFILES_DIR}/.subversion

# create tmp directory
mkdir -p ${REDMINE_DATA_DIR}/tmp
chmod -R u+rw,go+r ${REDMINE_DATA_DIR}/tmp
chown -R ${REDMINE_USER}: ${REDMINE_DATA_DIR}/tmp
}

generate_ssh_client_keys() {
Expand Down

3 comments on commit 627a0f0

@SvenRoederer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planing to cherry-pick for v5.0?

@jcormier
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planing to cherry-pick for v5.0?

I can do that, no problem.

@SvenRoederer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for being so fast

Please sign in to comment.