Python-based service to change files within a folder to the desired owner and permission level. Originally developed to correct owern/permissions for files uploaded from scanner into Nextcloud over FTP.
permcorrect.py : main program file to be ran as a service
config.yml : configuration paramaters for root folder location, log file location and desired owner/permission settings.
Note: permcorrect.py expects config.yml to be located in /lib/systemd/system/permcorrect.d/. "with open(..." will need to be manually updated if located elsewhere
permcorrect.service : systemd unit file installed by default into /lib/systemd/system
- Clone repo to local system
- Create /lib/systemd/system/permcorrect.d/
- Update config.yml with desired paramaters
- Move config.yml and permcorrect.py into permcorrect.d
- Move permcorrect.service into /lib/systemd/system/
- Run
sudo systemctl daemon-reload
- Run
sudo systemctl start permcorrect.service
- Enable service auto-start by running
sudo systemctl enable permcorrect.service
- Place an incorrect file within the monitored folder and confirm it is corrected within the wait period (default 5 seconds) as well as an entry created in configured log file location (default /var/log/permcorrect.log)
- Clone repo to local system
- Modify permcorrect.py as follows:
- Remove
Import systemd.daemon
- Remove
time.sleep(1)
andsystemd.daemon.notify('READY=1')
- Remove
While True:
loop - Remove
time.sleep(5)
- Adjust indentation of the FOR loops as necessary
- Remove
- Update config.yml with desired paramaters
- Move config.yml and permcorrect.py into desired folder
- Create Cronjob as necessary