Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload.sh not removing correct file, others #625

Merged
merged 1 commit into from
Oct 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions scripts/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,33 @@ else # sftp/ftp
# People sometimes have problems with ftp not working,
# so save the commands we use so they can run lftp manually to debug.

# If REMOTE_DIR isn't null (which it can be), append a "/".
[ "${REMOTE_DIR}" != "" ] && REMOTE_DIR="${REMOTE_DIR}/"
# If REMOTE_DIR isn't null (which it can be) and doesn't already have a trailing "/", append one.
[ "${REMOTE_DIR}" != "" -a "${REMOTE_DIR: -1:1}" != "/" ] && REMOTE_DIR="${REMOTE_DIR}/"

if [ "${SILENT}" = "false" -a "${ALLSKY_DEBUG_LEVEL}" -ge 3 ]; then
echo "${ME}: FTP'ing ${FILE_TO_UPLOAD} to ${REMOTE_DIR}${DESTINATION_FILE}"
fi
LFTP_CMDS="${ALLSKY_TMP}/lftp_cmds.txt"

# COMPATIBILITY CHECK. New names start with "REMOTE_".
# If "REMOTE_HOST" doesn't exist assume the user has the old-style ftp-settings.sh file.
# xxxxx THIS CHECK WILL GO AWAY IN THE FUTURE.
if [ -z "${REMOTE_HOST}" ]; then
REMOTE_HOST="${HOST}"
REMOTE_PASSWORD="${PASSWORD}"
REMOTE_USER="${USER}"
fi
(
[ "${LFTP_COMMANDS}" != "" ] && echo ${LFTP_COMMANDS}
# xxx TODO: escape double quotes in PASSWORD - how? With \ ?
# xxx TODO: escape single quotes in REMOTE_PASSWORD - how? With \ ?
P="${REMOTE_PASSWORD}"
echo "open --user '${REMOTE_USER}' --password '${P}' '${PROTOCOL}://${REMOTE_HOST}' "
# Sometimes have problems with "max-reties 1", so make it 2
echo set net:max-retries 2
echo set net:timeout 20
echo "rm -f '${TEMP_NAME}' " # just in case it's already there
echo "put '${FILE_TO_UPLOAD}' -o '${TEMP_NAME}' || (echo 'put of ${FILE_TO_UPLOAD} failed!' && exit) "
echo "rm -f '${DESTINATION_FILE}' "
echo "mv '${TEMP_NAME}' '${REMOTE_DIR}${DESTINATION_FILE}' || ( echo 'mv of ${TEMP_NAME} to ${REMOTE_DIR}${DESTINATION_FILE} failed!' )"
echo "rm -f '${REMOTE_DIR}${TEMP_NAME}' " # unlikely, but just in case it's already there
echo "put '${FILE_TO_UPLOAD}' -o '${REMOTE_DIR}${TEMP_NAME}' || (echo 'put of ${FILE_TO_UPLOAD} failed!'; exit) "
echo "rm -f '${REMOTE_DIR}${DESTINATION_FILE}' "
echo "mv '${REMOTE_DIR}${TEMP_NAME}' '${REMOTE_DIR}${DESTINATION_FILE}' || ( echo 'mv of ${TEMP_NAME} to ${DESTINATION_FILE} in ${REMOTE_DIR} failed!'; exit )"
echo exit
) > "${LFTP_CMDS}"
lftp -f "${LFTP_CMDS}" > "${LOG}" 2>&1
Expand Down