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

WIP - Update permissions for pm2, laravel app-release commands #7

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions laravel-deploy/app-release
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,22 @@ sudo chmod 777 "$CURRENT/storage" -R
sudo chmod 777 "$CURRENT/bootstrap" -R

## Make Logs Directory
sudo mkdir -p "$REPO_ROOT/$LARAVELLOGSFOLDER_LOCATION"
sudo mkdir -m 775 -p "$REPO_ROOT/$LARAVELLOGSFOLDER_LOCATION"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will make the end directory have the correct permissions, but not the full tree. hence the looping afterward


## Change ownership of the logs folder
sudo chown $OWNER_USER:$OWNER_GROUP "$REPO_ROOT/$LARAVELLOGSFOLDER_LOCATION"
# If the logs location has a /, loop through and chown each one
# Prevents issues with paths like Parent/Logs, `chown` will not change the permissions of Parent
if [[ $LARAVELLOGSFOLDER_LOCATION == *\/* ]]; then
IFS='/' read -ra ADDR <<< "$LARAVELLOGSFOLDER_LOCATION"
for i in "${ADDR[@]}"; do
# join the path, but there should be no leading slash if it's the first one
CUR_LOG_PATH="${CUR_LOG_PATH:+$CUR_LOG_PATH/}$i"
sudo chown $OWNER_USER:$OWNER_GROUP "$REPO_ROOT/$CUR_LOG_PATH"
sudo chmod 775 "$REPO_ROOT/$CUR_LOG_PATH"
done
else
sudo chown $OWNER_USER:$OWNER_GROUP "$REPO_ROOT/$LARAVELLOGSFOLDER_LOCATION"
fi

## Change back to the commands directory
cd $RELEASING_FROM
Expand Down
18 changes: 15 additions & 3 deletions pm2-deploy/app-release
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,23 @@ fi

REPO_ROOT=$(pwd)

# Add Logs Folder
sudo mkdir -p "$REPO_ROOT/$APPLOGSFOLDER_LOCATION"
# Add logs folder
sudo mkdir -m 775 -p "$REPO_ROOT/$APPLOGSFOLDER_LOCATION"

## Change ownership of the logs folder
sudo chown $OWNER_USER:$OWNER_GROUP "$REPO_ROOT/$APPLOGSFOLDER_LOCATION"
# If the logs location has a /, loop through and chown each one
# Prevents issues with paths like Parent/Logs, `chown` will not change the permissions of Parent
if [[ $APPLOGSFOLDER_LOCATION == *\/* ]]; then
IFS='/' read -ra ADDR <<< "$APPLOGSFOLDER_LOCATION"
for i in "${ADDR[@]}"; do
# join the path, but there should be no leading slash if it's the first one
CUR_LOG_PATH="${CUR_LOG_PATH:+$CUR_LOG_PATH/}$i"
sudo chown $OWNER_USER:$OWNER_GROUP "$REPO_ROOT/$CUR_LOG_PATH"
sudo chmod 775 "$REPO_ROOT/$CUR_LOG_PATH"
done
else
sudo chown $OWNER_USER:$OWNER_GROUP "$REPO_ROOT/$APPLOGSFOLDER_LOCATION"
fi

# Go into the repo's appfolder, where npm is?
cd $REPO_ROOT/$APPFOLDER
Expand Down