Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Jan 19, 2024
1 parent c97fb8a commit de161aa
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/static/static/home/yi-hack/script/ftppush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,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 @@ -179,9 +179,7 @@ uploadToFtp ()
#
# Variables.
UTF_FULLFN="${2}"
UTF_FULLFN_TZ="$(translateFULLFNWithTz ${UTF_FULLFN})"
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 @@ -197,9 +195,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 @@ -209,12 +206,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 de161aa

Please sign in to comment.