-
-
Save radiowave911/ebabd3411bf449af22cf97a863ab3ec4 to your computer and use it in GitHub Desktop.
Non-Working Sanitized Script
This file contains 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/bash | |
# This script is run M-F, 0540 - 1740, by CRON to download <redacted> | |
# Function to sync the <redacted> directory with the ownCloud server | |
function ownCloudSync { | |
owncloudcmd -s --non-interactive --trust -u <username> -p <password> /var/opt/<redacted>/<redacted> https://<OwnCloud Server>/remote.php/dav/files/<redacted>/<redacted>/ | |
} | |
# Get the current hour as 2 digits, 24 hour clock | |
CURHR=$(date +%H) | |
# Construct the URL for the file | |
URL="https://<Download Host>/<redacted>/<redacted>/${CURHR}<redacted>.mp3" | |
# Download the file and save it to /var/opt/<redacted>/<redacted>/ | |
wget -q -t 5 --no-cache -P /var/opt/<redacted>/<redacted>/ ${URL} | |
EXIT=$? | |
# Check if the download was successful | |
if [ $EXIT -ne "0" ]; then | |
logger -p user.err "<redacted> <redacted> wget download failed: ${URL} Exitcode: ${EXIT}" | |
exit 1 | |
fi | |
# Wait for the ownCloud sync to complete | |
ownCloudSync | |
EXIT=$? | |
# Check if the last ownCloud sync was successful | |
if [ $EXIT -ne "0" ]; then | |
logger -p user.err "<redacted> <redacted> ownCloud sync failed: ${URL} Exitcode: ${EXIT}" | |
exit 2 | |
fi | |
# Delete the file | |
rm -f /var/opt/<redacted>/redacted>/<redacted> | |
logger -p user.info "<redacted> News download successful for ${URL}" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment