FJIOQEFJKQOIM
unknown
plain_text
24 days ago
3.6 kB
3
Indexable
Never
ACCOUNTS_FILE="/root/accounts.txt" LOCAL_FOLDER="/root/mega/" RESTART_DELAY=5 terminate_sessions() { echo "Terminating all active sessions..." mega-logout pkill -f mega-cmd sleep 2 } terminate_sessions while read -r ACCOUNT; do EMAIL=$(echo "$ACCOUNT" | cut -d: -f1 | xargs) PASSWORD=$(echo "$ACCOUNT" | cut -d: -f2 | xargs) sleep 2 echo "Attempting login for $EMAIL" sleep 2 mega-login "$EMAIL" "$PASSWORD" LOGIN_RESULT=$? if [ $LOGIN_RESULT -eq 104 ]; then echo "Error 104 detected during login. Restarting the script after terminating MEGAcmd..." terminate_sessions sleep $RESTART_DELAY exec "$0" "$@" fi if [ $LOGIN_RESULT -ne 0 ]; then echo "Login failed for account: $EMAIL" if grep -q "Internal error" /root/.megaCmd/megacmdserver.log; then echo "Account $EMAIL is blocked and will be removed from the list." sed -i "/^$EMAIL/d" "$ACCOUNTS_FILE" fi sleep 2 continue fi echo "Login successful for account: $EMAIL" sleep 2 if mega-ls | grep -q 'Exodus Backup'; then echo "Attempting to remove 'TEST' for account: $EMAIL" yes | mega-rm -r 'TEST' --use-pcre if [ $? -ne 0 ]; then echo "Failed to remove 'TEST' for account: $EMAIL" else echo "Successfully removed 'TEST' for account: $EMAIL" fi sleep 2 else echo "'TEST' not found for account: $EMAIL" sleep 2 fi if mega-ls | grep -q 'TEST.zip'; then echo "Attempting to remove 'TEST.zip' for account: $EMAIL" yes | mega-rm 'TEST.zip' --use-pcre if [ $? -ne 0 ]; then echo "Failed to remove 'TEST.zip' for account: $EMAIL" else echo "Successfully removed 'TEST.zip' for account: $EMAIL" fi sleep 2 else echo "'TEST.zip' not found for account: $EMAIL" sleep 2 fi UPLOAD_SUCCESS=false for file in "$LOCAL_FOLDER"*; do if [ -f "$file" ]; then echo "Attempting to upload file: $(basename "$file")" yes | mega-put "$file" / if [ $? -ne 0 ]; then echo "Failed to upload file $(basename "$file") for account: $EMAIL" else echo "Uploaded file $(basename "$file") for account: $EMAIL" UPLOAD_SUCCESS=true fi sleep 2 elif [ -d "$file" ]; then echo "Attempting to upload folder: $(basename "$file")" yes | mega-put "$file" / if [ $? -ne 0 ]; then echo "Failed to upload folder $(basename "$file") for account: $EMAIL" else echo "Uploaded folder $(basename "$file") for account: $EMAIL" UPLOAD_SUCCESS=true fi sleep 2 fi done mega-logout if [ $? -ne 0 ]; then echo "Failed to log out from account: $EMAIL" else echo "Logged out from account: $EMAIL" fi sleep 2 if [ "$UPLOAD_SUCCESS" = true ]; then echo "Removing account $EMAIL from the list." sed -i "/^$EMAIL/d" "$ACCOUNTS_FILE" fi echo "Operations for account $EMAIL completed." sleep 15 if grep -q "ERROR reading state from MEGAcmd server: 104" /root/.megaCmd/megacmdserver.log; then echo "Error 104 detected after operations. Terminating MEGAcmd and restarting the script..." terminate_sessions sleep $RESTART_DELAY exec "$0" "$@" fi done < "$ACCOUNTS_FILE"
Leave a Comment