From 7138e04fa459901ae0ef2e687d3ad8a9790cdaff Mon Sep 17 00:00:00 2001 From: Jon Shaulis Date: Wed, 14 Sep 2016 22:20:39 -0400 Subject: [PATCH 1/4] Make sure that the emitted sha file gets cleaned up --- plexupdate.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plexupdate.sh b/plexupdate.sh index d145eae..570911b 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -471,6 +471,7 @@ if [ $? -ne 0 ]; then fi echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"${DOWNLOADDIR}/${FILENAME}.sha" +trap "rm ${DOWNLOADDIR}/${FILENAME}.sha" EXIT if [ "${PRINT_URL}" = "yes" ]; then if [ "${QUIET}" = "yes" ]; then From 89cc3ff3f933c463fd93e66aa9b8f67e50fd695d Mon Sep 17 00:00:00 2001 From: Jon Shaulis Date: Thu, 15 Sep 2016 21:20:42 -0400 Subject: [PATCH 2/4] Move trap call to cleanup function --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 570911b..204ec1c 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -365,6 +365,7 @@ function cleanup { rm /tmp/raw 2>/dev/null >/dev/null rm /tmp/failcause 2>/dev/null >/dev/null rm /tmp/kaka 2>/dev/null >/dev/null + rm "${DOWNLOADDIR}/${FILENAME}.sha" 2>/dev/null >/dev/null } trap cleanup EXIT @@ -471,7 +472,6 @@ if [ $? -ne 0 ]; then fi echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"${DOWNLOADDIR}/${FILENAME}.sha" -trap "rm ${DOWNLOADDIR}/${FILENAME}.sha" EXIT if [ "${PRINT_URL}" = "yes" ]; then if [ "${QUIET}" = "yes" ]; then From 256ece32f3703253d1d8b872c33793397f8668c5 Mon Sep 17 00:00:00 2001 From: Jon Shaulis Date: Wed, 28 Sep 2016 19:48:04 -0400 Subject: [PATCH 3/4] Move sha checksum file to tmp dir --- plexupdate.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 204ec1c..b1e3ca5 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -365,7 +365,7 @@ function cleanup { rm /tmp/raw 2>/dev/null >/dev/null rm /tmp/failcause 2>/dev/null >/dev/null rm /tmp/kaka 2>/dev/null >/dev/null - rm "${DOWNLOADDIR}/${FILENAME}.sha" 2>/dev/null >/dev/null + rm "/tmp/${FILENAME}.sha" 2>/dev/null >/dev/null } trap cleanup EXIT @@ -471,7 +471,7 @@ if [ $? -ne 0 ]; then cronexit 3 fi -echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"${DOWNLOADDIR}/${FILENAME}.sha" +echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"/tmp/${FILENAME}.sha" if [ "${PRINT_URL}" = "yes" ]; then if [ "${QUIET}" = "yes" ]; then @@ -502,7 +502,7 @@ fi if [ -f "${DOWNLOADDIR}/${FILENAME}" ]; then if [ "${FORCE}" != "yes" -a "${FORCEALL}" != "yes" ]; then - sha1sum --status -c "${DOWNLOADDIR}/${FILENAME}.sha" + sha1sum --status -c "/tmp/${FILENAME}.sha" if [ $? -eq 0 ]; then echo "File already exists (${FILENAME}), won't download." if [ "${AUTOINSTALL}" != "yes" ]; then @@ -516,7 +516,7 @@ if [ -f "${DOWNLOADDIR}/${FILENAME}" ]; then elif [ "${FORCEALL}" == "yes" ]; then echo "Note! File exists, but asked to overwrite with new copy" else - sha1sum --status -c "${DOWNLOADDIR}/${FILENAME}.sha" + sha1sum --status -c "/tmp/${FILENAME}.sha" if [ $? -ne 0 ]; then echo "Note! File exists but fails checksum. Redownloading." else @@ -540,7 +540,7 @@ if [ "${SKIP_DOWNLOAD}" = "no" ]; then echo "OK" fi -sha1sum --status -c "${DOWNLOADDIR}/${FILENAME}.sha" +sha1sum --status -c "/tmp/${FILENAME}.sha" if [ $? -ne 0 ]; then echo "Downloaded file corrupt. Try again." cronexit 4 @@ -566,8 +566,6 @@ fi if [ "${AUTODELETE}" = "yes" ]; then if [ "${AUTOINSTALL}" = "yes" ]; then rm -rf "${DOWNLOADDIR}/${FILENAME}" - # Also delete the SHA1 file - rm -rf "${DOWNLOADDIR}/${FILENAME}.sha" echo "Deleted \"${FILENAME}\"" else echo "Will not auto delete without [-a] auto install" From c4a2ee44809cac20cba3397697cff6c68bd5afe4 Mon Sep 17 00:00:00 2001 From: Jon Shaulis Date: Thu, 29 Sep 2016 10:15:09 -0400 Subject: [PATCH 4/4] Do not depend on filename var --- plexupdate.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index b1e3ca5..fa45e36 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -365,7 +365,7 @@ function cleanup { rm /tmp/raw 2>/dev/null >/dev/null rm /tmp/failcause 2>/dev/null >/dev/null rm /tmp/kaka 2>/dev/null >/dev/null - rm "/tmp/${FILENAME}.sha" 2>/dev/null >/dev/null + rm "/tmp/package.sha" 2>/dev/null >/dev/null } trap cleanup EXIT @@ -471,7 +471,7 @@ if [ $? -ne 0 ]; then cronexit 3 fi -echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"/tmp/${FILENAME}.sha" +echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"/tmp/package.sha" if [ "${PRINT_URL}" = "yes" ]; then if [ "${QUIET}" = "yes" ]; then @@ -502,7 +502,7 @@ fi if [ -f "${DOWNLOADDIR}/${FILENAME}" ]; then if [ "${FORCE}" != "yes" -a "${FORCEALL}" != "yes" ]; then - sha1sum --status -c "/tmp/${FILENAME}.sha" + sha1sum --status -c "/tmp/package.sha" if [ $? -eq 0 ]; then echo "File already exists (${FILENAME}), won't download." if [ "${AUTOINSTALL}" != "yes" ]; then @@ -516,7 +516,7 @@ if [ -f "${DOWNLOADDIR}/${FILENAME}" ]; then elif [ "${FORCEALL}" == "yes" ]; then echo "Note! File exists, but asked to overwrite with new copy" else - sha1sum --status -c "/tmp/${FILENAME}.sha" + sha1sum --status -c "/tmp/package.sha" if [ $? -ne 0 ]; then echo "Note! File exists but fails checksum. Redownloading." else @@ -540,7 +540,7 @@ if [ "${SKIP_DOWNLOAD}" = "no" ]; then echo "OK" fi -sha1sum --status -c "/tmp/${FILENAME}.sha" +sha1sum --status -c "/tmp/package.sha" if [ $? -ne 0 ]; then echo "Downloaded file corrupt. Try again." cronexit 4