2022-06-20 14:22:05 +08:00
|
|
|
#!/bin/sh
|
2022-06-13 23:28:06 +08:00
|
|
|
cd /home/app
|
|
|
|
chmod +x ./aliyunpan
|
|
|
|
|
|
|
|
# sync config file
|
|
|
|
readonly sync_drive_config_file="$ALIYUNPAN_CONFIG_DIR/sync_drive/sync_drive_config.json"
|
|
|
|
if test -s $sync_drive_config_file
|
|
|
|
then
|
2022-06-16 14:20:49 +08:00
|
|
|
echo "using existed sync_drive_config.json file"
|
2022-06-13 23:28:06 +08:00
|
|
|
else
|
|
|
|
echo "generate sync_drive_config.json file"
|
|
|
|
tee $sync_drive_config_file << EOF
|
|
|
|
{
|
|
|
|
"configVer": "1.0",
|
|
|
|
"syncTaskList": [
|
|
|
|
{
|
|
|
|
"name": "阿里云盘备份",
|
|
|
|
"id": "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
|
|
|
"localFolderPath": "$ALIYUNPAN_LOCAL_DIR",
|
|
|
|
"panFolderPath": "$ALIYUNPAN_PAN_DIR",
|
|
|
|
"mode": "$ALIYUNPAN_SYNC_MODE",
|
2022-08-13 18:43:29 +08:00
|
|
|
"priority": "$ALIYUNPAN_SYNC_PRIORITY",
|
2022-06-13 23:28:06 +08:00
|
|
|
"lastSyncTime": "2022-06-12 19:28:20"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 2s
|
|
|
|
|
2023-02-19 17:04:45 +08:00
|
|
|
# device-id
|
|
|
|
if [[ -z $ALIYUNPAN_DEVICE_ID ]];
|
|
|
|
then
|
|
|
|
echo "the program use random device id"
|
|
|
|
else
|
|
|
|
echo "set device id"
|
|
|
|
./aliyunpan config set -device_id ${ALIYUNPAN_DEVICE_ID}
|
|
|
|
fi
|
|
|
|
|
2022-06-13 23:28:06 +08:00
|
|
|
# check login already or not
|
|
|
|
./aliyunpan who
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "cache token is valid, not need to re-login"
|
|
|
|
else
|
|
|
|
echo "login use refresh token: ${ALIYUNPAN_REFRESH_TOKEN}"
|
|
|
|
./aliyunpan login -RefreshToken=${ALIYUNPAN_REFRESH_TOKEN}
|
|
|
|
fi
|
|
|
|
|
2022-12-19 20:41:05 +08:00
|
|
|
./aliyunpan config set -transfer_url_type ${ALIYUNPAN_TRANSFER_URL_TYPE}
|
|
|
|
|
|
|
|
if [ "$ALIYUNPAN_SYNC_LOG" = "true" ]
|
|
|
|
then
|
|
|
|
./aliyunpan config set -file_record_config 1
|
|
|
|
else
|
|
|
|
./aliyunpan config set -file_record_config 2
|
|
|
|
fi
|
|
|
|
|
2022-09-29 19:48:25 +08:00
|
|
|
./aliyunpan sync start -dp ${ALIYUNPAN_DOWNLOAD_PARALLEL} -up ${ALIYUNPAN_UPLOAD_PARALLEL} -dbs ${ALIYUNPAN_DOWNLOAD_BLOCK_SIZE} -ubs ${ALIYUNPAN_UPLOAD_BLOCK_SIZE} -log ${ALIYUNPAN_SYNC_LOG} -ldt ${ALIYUNPAN_LOCAL_DELAY_TIME} -step ${ALIYUNPAN_TASK_STEP}
|