Skip to content

Commit

Permalink
Fix bug in ftppush.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Jan 19, 2024
1 parent 5685c9c commit 29c0caf
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/static/static/home/yi-hack/script/ftppush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ translateFULLFNWithTz ()
TR_HOUR_PREFIX=""
TR_SUFFIX=""
TR_DATE="${1:15:4}-${1:20:2}-${1:23:2} ${1:26:2}:${1:30:2}:${1:33:2}"
TR_SUFFIX=${1:35:7}
TR_SUFFIX=${1:36:6}
TR_SECONDS_1970=$(date +%s -u -d "$TR_DATE")
TR_RET=$(TZ=$TIMEZONE date +$TR_PREFIX%YY%mM%dD%HH/$TR_HOUR_PREFIX%MM%SS$TR_SUFFIX -d "@$TR_SECONDS_1970")
echo $TR_RET
Expand Down Expand Up @@ -181,13 +181,7 @@ uploadToFtp ()
#
# Variables.
UTF_FULLFN="${2}"
# if [ "$HV" == "12" ]; then
# UTF_FULLFN_TZ="${UTF_FULLFN}"
# else
UTF_FULLFN_TZ="$(translateFULLFNWithTz ${UTF_FULLFN})"
# fi
FTP_DIR_HOUR="$(lparentdir ${UTF_FULLFN})"
FTP_DIR_HOUR_TZ="$(lparentdir ${UTF_FULLFN_TZ})"
#
if [ "${SKIP_UPLOAD_TO_FTP}" = "1" ]; then
logAdd "[INFO] uploadToFtp skipped due to SKIP_UPLOAD_TO_FTP == 1."
Expand All @@ -203,9 +197,8 @@ uploadToFtp ()
if [ "${FTP_DIR_TREE}" == "yes" ]; then
if [ ! -z "${FTP_DIR_HOUR}" ]; then
# Create hour directory on FTP server
echo -e "USER ${FTP_USERNAME}\r\nPASS ${FTP_PASSWORD}\r\nmkd ${FTP_DIR}/${FTP_DIR_HOUR_TZ}\r\nquit\r\n" | nc -w 5 ${FTP_HOST} 21 | grep "${FTP_DIR_HOUR}"
echo -e "USER ${FTP_USERNAME}\r\nPASS ${FTP_PASSWORD}\r\nmkd ${FTP_DIR}/${FTP_DIR_HOUR}\r\nquit\r\n" | nc -w 5 ${FTP_HOST} 21 | grep "${FTP_DIR_HOUR}"
FTP_DIR_HOUR="${FTP_DIR_HOUR}/"
FTP_DIR_HOUR_TZ="${FTP_DIR_HOUR_TZ}/"
fi
fi
#
Expand All @@ -215,12 +208,12 @@ uploadToFtp ()
fi
#
if [ "${FTP_DIR_TREE}" == "yes" ]; then
if ( ! ftpput -u "${FTP_USERNAME}" -p "${FTP_PASSWORD}" "${FTP_HOST}" "${FTP_DIR}${FTP_DIR_HOUR_TZ}$(lbasename "${UTF_FULLFN_TZ}")" "${UTF_FULLFN}" ); then
if ( ! ftpput -u "${FTP_USERNAME}" -p "${FTP_PASSWORD}" "${FTP_HOST}" "${FTP_DIR}${FTP_DIR_HOUR}$(lbasename "${UTF_FULLFN}")" "${UTF_FULLFN}" ); then
logAdd "[ERROR] uploadToFtp: ftpput FAILED."
return 1
fi
else
if ( ! ftpput -u "${FTP_USERNAME}" -p "${FTP_PASSWORD}" "${FTP_HOST}" "${FTP_DIR}$(lbasename "${UTF_FULLFN_TZ}")" "${UTF_FULLFN}" ); then
if ( ! ftpput -u "${FTP_USERNAME}" -p "${FTP_PASSWORD}" "${FTP_HOST}" "${FTP_DIR}$(lbasename "${UTF_FULLFN}")" "${UTF_FULLFN}" ); then
logAdd "[ERROR] uploadToFtp: ftpput FAILED."
return 1
fi
Expand Down

0 comments on commit 29c0caf

Please sign in to comment.