GithubHelp home page GithubHelp logo

wernerjoss / grav-directory-permissions-monitor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trezcan/grav-directory-permissions-monitor

1.0 0.0 0.0 10 KB

Maintain consistent file/folder owner and permission settings.

License: MIT License

Shell 10.02% Python 49.48% Dockerfile 40.50%

grav-directory-permissions-monitor's Introduction

Grav Directory Permissions Monitor

Author

Eric Stauffer
Website

Table of Contents

Overview

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:

  1. main.py: The Python script that scans the designated directory at regular intervals, logging changes in permissions or ownership.
  2. perms-script.sh: A Bash script that resets the permissions and ownership for all the files and folders within the target directory.

WARNING

This script manipulates file/folder ownership and permissions. The default setup utilizes sudo in the bash script.

It is intended for development use only.

Prerequisites

  • Python 3.x
  • Linux environment with shell access
  • docker.io, docker-compose (optional)

Installation

  1. Clone the GitHub repository to your local machine.
    git clone https://github.com/trezcan/grav-directory-permissions-monitor.git
  2. Navigate to the directory and install any dependencies if necessary.

Usage

  1. Modify the monitor_dir and excluded_dirs variables in main.py to specify which directory you'd like to monitor and any subdirectories you'd like to exclude from the monitoring.
  2. Customize perms-script.sh to set your desired web directory, file owner, file group, directory permissions, and file permissions.
  3. Run main.py.
    python3 main.py

Configuration

  • 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.

Scripts

  • perms-script.sh: Customize this script to suit the permissions and ownership requirements of your web directory. The script utilizes chmod and chown 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

Docker

This Fork comes with additional Files so the permissions monitor can be run directly inside a docker-container automatically after startup.
For this to work, do the following:

  • install docker.io, docker-compose
  • navigate to the clone directory
  • build the docker image with docker build -t grav:perms .
  • start the image with docker-compose up -d
  • point your browser to http://localhost/admin - create admin user from there upon first login, then proceed as usual
  • if unsure what is going on, log into the docker image with docker exec -it playground bash, check console output, log File, processes etc.

Logging

Logs of changes are saved in a ./logs/changes.log file. You can use this log file to track changes over time.

Contributing

Feel free to open an issue or submit a pull request if you find a bug or have a feature to suggest.

License

This project is open-source and available under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.