2024-01-29 05:04:48 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-03-29 20:49:47 -07:00
|
|
|
USER=$1
|
|
|
|
PASS=$2
|
|
|
|
HOST=$3
|
2024-03-30 17:18:48 -07:00
|
|
|
BUNDLE_FILE_NAME=$4
|
2024-06-27 09:06:34 -07:00
|
|
|
RELEASE_TAG=$5
|
2024-03-30 17:18:48 -07:00
|
|
|
|
2024-01-29 05:04:48 -08:00
|
|
|
SCRIPT_NAME=$(basename "$0")
|
|
|
|
|
2024-03-29 20:49:47 -07:00
|
|
|
if [ -n "${USER}" -a -n "$PASS" -a -n "${HOST}" ]; then
|
2024-03-29 20:40:15 -07:00
|
|
|
echo "$SCRIPT_NAME: Uploading both bundles"
|
2024-04-01 07:59:48 -07:00
|
|
|
|
|
|
|
if [ -n "${BUNDLE_FILE_NAME}" ]; then
|
2024-04-02 07:42:41 -07:00
|
|
|
echo "$SCRIPT_NAME: BUNDLE_FILE_NAME is ${BUNDLE_FILE_NAME}"
|
2024-04-01 07:59:48 -07:00
|
|
|
else
|
2024-04-02 07:42:41 -07:00
|
|
|
echo "$SCRIPT_NAME: BUNDLE_FILE_NAME argument not specified"
|
2024-04-01 07:59:48 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
2024-04-18 17:04:45 -07:00
|
|
|
if [ -n "${bundle_upload_folder}" ]; then
|
|
|
|
echo "$SCRIPT_NAME: bundle_upload_folder is ${bundle_upload_folder}"
|
|
|
|
else
|
2024-04-19 08:51:50 -07:00
|
|
|
bundle_upload_folder="build_server"
|
2024-04-18 17:04:45 -07:00
|
|
|
echo "$SCRIPT_NAME: bundle_upload_folder env variable was not specified using default ${bundle_upload_folder}"
|
|
|
|
fi
|
|
|
|
|
2024-06-27 09:06:34 -07:00
|
|
|
if [ -n "${RELEASE_TAG}" ]; then
|
|
|
|
echo "$SCRIPT_NAME: RELEASE_TAG is ${RELEASE_TAG}"
|
|
|
|
fi
|
|
|
|
|
2024-07-02 13:10:10 -07:00
|
|
|
if [[ -z "${WHITE_LABEL}" ]]; then
|
|
|
|
echo "WHITE_LABEL environment variable is not specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
FULL_BUNDLE_FILE="${WHITE_LABEL}_bundle_${BUNDLE_FILE_NAME}.zip"
|
|
|
|
UPDATE_BUNDLE_FILE="${WHITE_LABEL}_bundle_${BUNDLE_FILE_NAME}_autoupdate.zip"
|
2024-04-01 07:59:48 -07:00
|
|
|
|
2024-04-19 07:22:34 -07:00
|
|
|
# sftp does not support -p flag on mkdir :(
|
|
|
|
sshpass -p $PASS sftp -o StrictHostKeyChecking=no ${USER}@${HOST} <<SSHCMD
|
|
|
|
mkdir ${bundle_upload_folder}
|
|
|
|
SSHCMD
|
|
|
|
|
2024-01-29 05:04:48 -08:00
|
|
|
RET=0
|
2024-06-27 09:06:34 -07:00
|
|
|
if [ "$AUTOMATION_LTS" == "true" -a -n "$AUTOMATION_REF" ]; then # lts build
|
2024-05-30 07:52:44 -07:00
|
|
|
DESTINATION_FOLDER="${bundle_upload_folder}/lts/${AUTOMATION_REF}"
|
2024-04-19 07:22:34 -07:00
|
|
|
# sftp does not support -p flag on mkdir :(
|
|
|
|
sshpass -p $PASS sftp -o StrictHostKeyChecking=no ${USER}@${HOST} <<SSHCMD
|
|
|
|
mkdir ${bundle_upload_folder}/lts
|
|
|
|
mkdir ${DESTINATION_FOLDER}
|
2024-06-27 09:06:34 -07:00
|
|
|
SSHCMD
|
|
|
|
elif [ -n "${RELEASE_TAG}" ]; then # daily release with tag
|
|
|
|
DESTINATION_FOLDER="${bundle_upload_folder}/${SHORT_BOARD_NAME}/${RELEASE_TAG}"
|
|
|
|
# sftp does not support -p flag on mkdir :(
|
|
|
|
sshpass -p $PASS sftp -o StrictHostKeyChecking=no ${USER}@${HOST} <<SSHCMD
|
|
|
|
mkdir ${bundle_upload_folder}/${SHORT_BOARD_NAME}
|
|
|
|
mkdir ${DESTINATION_FOLDER}
|
2024-04-19 07:22:34 -07:00
|
|
|
SSHCMD
|
2024-01-29 05:04:48 -08:00
|
|
|
else
|
2024-04-18 17:04:45 -07:00
|
|
|
DESTINATION_FOLDER="${bundle_upload_folder}"
|
2024-01-29 05:04:48 -08:00
|
|
|
fi
|
2024-04-19 07:22:34 -07:00
|
|
|
|
|
|
|
# sftp does not support -p flag on mkdir :(
|
|
|
|
sshpass -p $PASS sftp -o StrictHostKeyChecking=no ${USER}@${HOST} <<SSHCMD
|
|
|
|
cd ${DESTINATION_FOLDER}
|
|
|
|
put $FULL_BUNDLE_FILE
|
|
|
|
mkdir autoupdate
|
|
|
|
cd autoupdate
|
|
|
|
put $UPDATE_BUNDLE_FILE
|
|
|
|
SSHCMD
|
2024-04-19 07:08:42 -07:00
|
|
|
echo "$SCRIPT_NAME: DONE $FULL_BUNDLE_FILE"
|
2024-01-29 05:04:48 -08:00
|
|
|
else
|
|
|
|
echo "$SCRIPT_NAME: Upload not configured"
|
|
|
|
fi
|