-
-
Save pannal/3c7c6f6dd0c1fa869541ae3adc12a85f to your computer and use it in GitHub Desktop.
An NZBGet post processing script that sets user, group and permissions of folders and files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ################################################################################ | |
| ### NZBGET POST-PROCESSING SCRIPT ### | |
| # Change user:group ownership and folder/file permission. | |
| ################################################################################ | |
| ### OPTIONS ### | |
| # Set owner and group (yes, no). | |
| #SetOwner=yes | |
| # Owner user ID or username. | |
| #User=nobody | |
| # Owner group ID or group name. | |
| #Group=nogroup | |
| # Set folder and file permissions (yes, no). | |
| #SetMode=no | |
| # File permission mode. | |
| #Mode=664 | |
| # Folder permission mode. | |
| #DirMode=775 | |
| ### NZBGET POST-PROCESSING SCRIPT ### | |
| ################################################################################ | |
| # Exit codes | |
| #POSTPROCESS_PARCHECK=92 | |
| #POSTPROCESS_SUCCESS=93 | |
| POSTPROCESS_ERROR=94 | |
| #POSTPROCESS_NONE=95 | |
| POSTPROCESS=95 | |
| # Check if the script is called from nzbget 11.0 or later | |
| if [ "${NZBOP_SCRIPTDIR}" = "" ]; then | |
| echo "*** NZBGet post-processing script ***" | |
| echo "This script is supposed to be called from nzbget (11.0 or later)." | |
| exit ${POSTPROCESS_ERROR} | |
| fi | |
| # Check if directory exists | |
| if [ -d "${NZBPP_DIRECTORY}" ]; then | |
| # chown | |
| if [ "${NZBPO_SETOWNER}" = "yes" ]; then | |
| if chown "${NZBPO_USER}:${NZBPO_GROUP}" -R "${NZBPP_DIRECTORY}"; then | |
| echo "[INFO] Ownership set to ${NZBPO_USER}:${NZBPO_GROUP}" | |
| POSTPROCESS=93 | |
| else | |
| echo "[WARN] User and group NOT set" | |
| exit ${POSTPROCESS_ERROR} | |
| fi | |
| fi | |
| # chmod | |
| if [ "${NZBPO_SETMODE}" = "yes" ]; then | |
| # recursively set perms on files | |
| if find "${NZBPP_DIRECTORY}" -type f -exec chmod "${NZBPO_MODE}" '{}' ';'; then | |
| echo "[INFO] File permissions set to ${NZBPO_MODE}" | |
| POSTPROCESS=93 | |
| else | |
| echo "[WARN] File permissions NOT set" | |
| exit ${POSTPROCESS_ERROR} | |
| fi | |
| # recursively set perms on folders | |
| if find "${NZBPP_DIRECTORY}" -type d -exec chmod "${NZBPO_DIRMODE}" '{}' ';'; then | |
| echo "[INFO] Folder permissions set to ${NZBPO_DIRMODE}" | |
| POSTPROCESS=93 | |
| else | |
| echo "[WARN] Folder permissions NOT set" | |
| exit ${POSTPROCESS_ERROR} | |
| fi | |
| fi | |
| else | |
| echo "[WARN] Directory not found" | |
| echo "[DETAIL] $NZBPP_DIRECTORY" | |
| exit ${POSTPROCESS} | |
| fi | |
| exit ${POSTPROCESS} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adjusted to /bin/sh, adapted to newer config style.