Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Set file permissions as last step, after all cache files etc have bee…
Browse files Browse the repository at this point in the history
…n created
  • Loading branch information
tristan-orourke committed Mar 2, 2021
1 parent b6ba1fe commit de30189
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions etc/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,11 @@ sudo chmod 777 $SRC.zip;
echo "Unzipping contents of $SRC.zip...";
sudo unzip -qq $SRC.zip;

echo "Ensure storage/framework/cache/data directory exists...";
sudo mkdir -p $SRC/storage/framework/cache/data;

echo "Ensure file upload directory exists...";
sudo mkdir -p $SRC/storage/app/public/resources;

# Set permissions
echo "Setting proper app permissions in $SRC:"

echo "Setting directory permissions...";
sudo find $SRC -type d -exec chmod 775 {} \;

echo "Setting file permissions...";
sudo find $SRC -type f -exec chmod 664 {} \;

echo "Setting SELinux security context...";
sudo chcon -Rt httpd_sys_content_t $SRC;

echo "Setting nginx as onwer of all files...";
sudo chown -Rf nginx:nginx $SRC;

# Move the old Storage folder so it doesn't get deleted
echo "Saving previous Storage folder...";
sudo mv $APP_DIR/storage ./storage_backup;

# Copy to APP_DIR
echo "Updating app with contents of $SRC:";

echo "Deleting contents of app directory...";
sudo rm -Rf $APP_DIR/*;

Expand All @@ -52,13 +29,11 @@ sudo rm -rf $APP_DIR/storage/*;
sudo mv ./storage_backup/* $APP_DIR/storage;
sudo rm -rf ./storage_backup;

echo "Setting permissions and owner of storage files, which came from old version of app...";
sudo find $APP_DIR/storage -type d -exec chmod 775 {} \;
sudo find $APP_DIR/storage -type f -exec chmod 664 {} \;
sudo chown -Rf nginx:nginx $APP_DIR/storage;

echo "Setting SELinux security context on writable directories...";
sudo chcon -Rt httpd_sys_rw_content_t $APP_DIR/storage;
echo "Ensure some storage directories are created now, instead of later, so permissions can be set correctly:";
echo "...framework cache data directory..."
sudo mkdir -p $SRC/storage/framework/cache/data;
echo "...and file upload directory...";
sudo mkdir -p $SRC/storage/app/public/resources;

echo "Deleting empty src directory...";
sudo rm -R $SRC;
Expand All @@ -81,3 +56,21 @@ sudo php artisan queue:restart;

echo "Link file storage folder with public folder...";
sudo php artisan storage:link;

# Set permissions
echo "Setting proper app permissions in $APP_DIR:"

echo "Setting directory permissions...";
sudo find $APP_DIR -type d -exec chmod 775 {} \;

echo "Setting file permissions...";
sudo find $APP_DIR -type f -exec chmod 664 {} \;

echo "Setting SELinux security context...";
sudo chcon -Rt httpd_sys_content_t $APP_DIR;

echo "Setting nginx as onwer of all files...";
sudo chown -Rf nginx:nginx $APP_DIR;

echo "Setting SELinux security context on writable directories...";
sudo chcon -Rt httpd_sys_rw_content_t $APP_DIR/storage;

0 comments on commit de30189

Please sign in to comment.