aliyunpan/docker/sync/app.sh

59 lines
1.5 KiB
Bash
Raw Normal View History

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": "阿里云盘备份",
2024-03-17 15:53:28 +08:00
"id": "5b2d7c10-e927-4e72-8f9d-5abb3bb04815",
2022-06-13 23:28:06 +08:00
"localFolderPath": "$ALIYUNPAN_LOCAL_DIR",
"panFolderPath": "$ALIYUNPAN_PAN_DIR",
"mode": "$ALIYUNPAN_SYNC_MODE",
2024-03-17 15:53:28 +08:00
"driveName": "$ALIYUNPAN_SYNC_DRIVE",
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
2024-03-17 15:53:28 +08:00
#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
2023-02-19 17:04:45 +08:00
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
2024-03-17 15:53:28 +08:00
echo "token is invalid, please use the valid aliyunpan_config.json file and retry"
# ./aliyunpan login -RefreshToken=${ALIYUNPAN_REFRESH_TOKEN}
2022-06-13 23:28:06 +08:00
fi
2022-12-19 20:41:05 +08:00
if [ "$ALIYUNPAN_SYNC_LOG" = "true" ]
then
./aliyunpan config set -file_record_config 1
else
./aliyunpan config set -file_record_config 2
fi
2024-03-17 15:53:28 +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}