diff --git a/extras/cronwrapper b/extras/cronwrapper index f0c4677..a7ba31b 100755 --- a/extras/cronwrapper +++ b/extras/cronwrapper @@ -20,51 +20,51 @@ if [ ! -f /etc/plexupdate.cron.conf ]; then - echo "ERROR: You have not configured /etc/plexupdate.cron.conf" >&2 - exit 255 + echo "ERROR: You have not configured /etc/plexupdate.cron.conf" >&2 + exit 255 else - source /etc/plexupdate.cron.conf + source /etc/plexupdate.cron.conf fi if [ -z "${SCRIPT}" -o ! -f "${SCRIPT}" ]; then - echo "ERROR: Cannot find plexupdate.sh (tried ${SCRIPT})" >&2 - exit 255 + echo "ERROR: Cannot find plexupdate.sh (tried ${SCRIPT})" >&2 + exit 255 elif [ ${EUID} -eq 0 ]; then - UNSAFE_FILES=$(find -L "$(dirname "${SCRIPT}")" -perm /002 -or -not -uid 0 -or -not -gid 0) - if [ ! -z "${UNSAFE_FILES}" ]; then - echo "ERROR: Permissions on some files are too lax for running as root. Files must be owned by root:root and not world-writeable." >&2 - echo "Unsafe files found:" >&2 - echo "${UNSAFE_FILES}" >&2 - exit 255 - fi + UNSAFE_FILES=$(find -L "$(dirname "${SCRIPT}")" -perm /002 -or -not -uid 0 -or -not -gid 0) + if [ ! -z "${UNSAFE_FILES}" ]; then + echo "ERROR: Permissions on some files are too lax for running as root. Files must be owned by root:root and not world-writeable." >&2 + echo "Unsafe files found:" >&2 + echo "${UNSAFE_FILES}" >&2 + exit 255 + fi fi if [ ! -z "$CONF" ]; then - # We have a config file, prefix it with parameter - if [ ! -f "${CONF}" ]; then - echo "ERROR: Cannot find config file (tried ${CONF})" >&2 - exit 255 - fi - CONF="--config=${CONF}" + # We have a config file, prefix it with parameter + if [ ! -f "${CONF}" ]; then + echo "ERROR: Cannot find config file (tried ${CONF})" >&2 + exit 255 + fi + CONF="--config=${CONF}" fi LOGFILE=$(mktemp /tmp/plexupdate.cron.XXXX) RET=0 if $LOGGING; then - "${SCRIPT}" "${CONF}" 2>&1 | tee ${LOGFILE} | logger -t plexupdate -p daemon.info - RET="${PIPESTATUS[0]}" + "${SCRIPT}" "${CONF}" 2>&1 | tee ${LOGFILE} | logger -t plexupdate -p daemon.info + RET="${PIPESTATUS[0]}" else - "${SCRIPT}" "${CONF}" >${LOGFILE} 2>&1 - RET=$? + "${SCRIPT}" "${CONF}" >${LOGFILE} 2>&1 + RET=$? fi if [ $RET -ne 2 -a $RET -ne 5 ]; then - # Make sure user gets an email about this - cat ${LOGFILE} >&2 + # Make sure user gets an email about this + cat ${LOGFILE} >&2 else - # Nah, not important - RET=0 + # Nah, not important + RET=0 fi rm "${LOGFILE}" 2>/dev/null diff --git a/plexupdate.sh b/plexupdate.sh index 8a447c5..b03db6b 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -334,6 +334,7 @@ if [ "${AUTOUPDATE}" = "yes" ]; then exit 1 fi + # Force FETCH_HEAD to point to the correct branch (for older versions of git which don't default to current branch) if git fetch origin $BRANCHNAME --quiet && ! git diff --quiet FETCH_HEAD; then info "Auto-updating..." if ! git merge --quiet FETCH_HEAD; then