#!/bin/bash # 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. # ps -ef | grep rustfs | awk '{print $2}'| xargs kill -9 # Local rustfs.zip path ZIP_FILE="./rustfs.zip" # Unzip target UNZIP_TARGET="./" SERVER_LIST=( "root@node1" # node1 "root@node2" # node2 "root@node3" # node3 "root@node4" # node4 # "root@node5" # node5 # "root@node6" # node6 # "root@node7" # node7 # "root@node8" # node8 ) REMOTE_TMP="~/rustfs" # Deploy rustfs to all servers deploy() { echo "Unzipping $ZIP_FILE ..." unzip -o "$ZIP_FILE" -d "$UNZIP_TARGET" if [ $? -ne 0 ]; then echo "Unzip failed, exiting" exit 1 fi LOCAL_RUSTFS="${UNZIP_TARGET}rustfs" if [ ! -f "$LOCAL_RUSTFS" ]; then echo "Unzipped rustfs file not found, exiting" exit 1 fi for SERVER in "${SERVER_LIST[@]}"; do echo "Uploading $LOCAL_RUSTFS to $SERVER:$REMOTE_TMP" scp "$LOCAL_RUSTFS" "${SERVER}:${REMOTE_TMP}" if [ $? -ne 0 ]; then echo "❌ Upload to $SERVER failed, skipping" continue fi echo "Operating systemctl and file replacement on $SERVER" ssh "$SERVER" bash <