2025-12-18 15:43:24 +03:30
|
|
|
#!/usr/bin/env bash
|
2025-07-02 15:07:47 +08:00
|
|
|
# Copyright 2024 RustFS Team
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2025-04-19 01:52:27 +08:00
|
|
|
|
2025-08-14 00:19:01 +08:00
|
|
|
# Script name: scp_to_servers.sh
|
2025-04-19 01:52:27 +08:00
|
|
|
|
2025-07-22 23:55:57 +08:00
|
|
|
rm ./target/x86_64-unknown-linux-gnu/release/rustfs.zip
|
2025-08-14 00:19:01 +08:00
|
|
|
# Compress ./target/x86_64-unknown-linux-gnu/release/rustfs
|
2025-07-22 23:55:57 +08:00
|
|
|
zip -j ./target/x86_64-unknown-linux-gnu/release/rustfs.zip ./target/x86_64-unknown-linux-gnu/release/rustfs
|
2025-04-19 01:52:27 +08:00
|
|
|
|
2025-08-14 00:19:01 +08:00
|
|
|
# Upload to server
|
2025-07-22 23:55:57 +08:00
|
|
|
LOCAL_FILE="./target/x86_64-unknown-linux-gnu/release/rustfs.zip"
|
2025-04-19 01:52:27 +08:00
|
|
|
REMOTE_PATH="~"
|
|
|
|
|
|
2025-08-14 00:19:01 +08:00
|
|
|
# IP parameter must be provided, otherwise exit with error
|
2025-06-13 18:07:40 +08:00
|
|
|
if [ -z "$1" ]; then
|
2025-08-14 00:19:01 +08:00
|
|
|
echo "Usage: $0 <server_ip>"
|
|
|
|
|
echo "Please provide target server IP address"
|
2025-06-13 18:07:40 +08:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
SERVER_LIST=("root@$1")
|
2025-04-19 01:52:27 +08:00
|
|
|
|
2025-08-14 00:19:01 +08:00
|
|
|
# Iterate through server list
|
2025-04-19 01:52:27 +08:00
|
|
|
for SERVER in "${SERVER_LIST[@]}"; do
|
2025-08-14 00:19:01 +08:00
|
|
|
echo "Copying file to server: $SERVER target path: $REMOTE_PATH"
|
2025-04-19 01:52:27 +08:00
|
|
|
scp "$LOCAL_FILE" "${SERVER}:${REMOTE_PATH}"
|
|
|
|
|
if [ $? -eq 0 ]; then
|
2025-08-14 00:19:01 +08:00
|
|
|
echo "Successfully copied to $SERVER"
|
2025-04-19 01:52:27 +08:00
|
|
|
else
|
2025-08-14 00:19:01 +08:00
|
|
|
echo "Failed to copy to $SERVER"
|
2025-04-19 01:52:27 +08:00
|
|
|
fi
|
2025-06-13 18:07:40 +08:00
|
|
|
done
|