diff --git a/laravel-deploy/app-release b/laravel-deploy/app-release index 0835bb2..44a51b3 100755 --- a/laravel-deploy/app-release +++ b/laravel-deploy/app-release @@ -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" ## 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 diff --git a/pm2-deploy/app-release b/pm2-deploy/app-release index 5b8aca9..b7d5da2 100755 --- a/pm2-deploy/app-release +++ b/pm2-deploy/app-release @@ -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