Eric Stauffer
Website
- Overview
- WARNING
- Prerequisites
- Installation
- Usage
- Configuration
- Scripts
- Logging
- Contributing
- License
The Grav Directory Permissions Monitor is a Python-based utility tool that helps maintain consistency in folder and file ownership and permissions for Grav CMS websites. When working locally on a Grav CMS website, it's common to encounter issues with folder/file permissions or ownership, especially when using an IDE or the Admin Plugin that might modify them.
The project consists of two main components:
main.py
: The Python script that scans the designated directory at regular intervals, logging changes in permissions or ownership.perms-script.sh
: A Bash script that resets the permissions and ownership for all the files and folders within the target directory.
This script manipulates file/folder ownership and permissions. The default setup utilizes sudo
in the bash script.
It is intended for development use only.
- Python 3.x
- Linux environment with shell access
- Clone the GitHub repository to your local machine.
git clone https://github.com/trezcan/grav-directory-permissions-monitor.git
- Navigate to the directory and install any dependencies if necessary.
- Modify the
monitor_dir
andexcluded_dirs
variables inmain.py
to specify which directory you'd like to monitor and any subdirectories you'd like to exclude from the monitoring. - Customize
perms-script.sh
to set your desired web directory, file owner, file group, directory permissions, and file permissions. - Run
main.py
.python3 main.py
monitor_dir
: The root directory to monitor (e.g.,/var/www/DOMAIN-DIRECTORY/
).excluded_dirs
: List of directory names to exclude from monitoring (e.g.,['.git', '.svn']
).scan_interval
: Time interval in seconds between directory scans (default is 30).print_scan_time
: Whether to print the time taken for each scan (default is True).
Note - Keeping print_scan_time
set to True
is recommended when first setting up on a new directory. It was originally added to monitor the scanning loop, and ensure it was not getting hung up on large directories. Feel free to toggle it to False
and restart the script.
perms-script.sh
: Customize this script to suit the permissions and ownership requirements of your web directory. The script utilizeschmod
andchown
to reset the permissions and ownership.
If the script will not run without your user password, you can remove the password requirement for sudo
. (Remember: Development Use Only):
sudo nano /etc/sudoers
Add to the end of the file:
YOUR_USERNAME_HERE ALL=(ALL:ALL) NOPASSWD: ALL
Logs of changes are saved in a ./logs/changes.log
file. You can use this log file to track changes over time.
Feel free to open an issue or submit a pull request if you find a bug or have a feature to suggest.
This project is open-source and available under the MIT License.