#!/bin/bash # Variables REMOTE_HOST="router" REMOTE_DIR="/jffs/scripts/" # Replace with the destination directory on the remote server RESTART_SCRIPT="$(git rev-parse --show-toplevel)/router/scripts/restart-wan" # Replace with the path to the first local file INIT_SCRIPT="$(git rev-parse --show-toplevel)/router/scripts/init" # Replace with the path to the second local file # Prompt for the password read -sp "Enter SSH password: " SSH_PASSWORD echo # Init dir sshpass -p "$SSH_PASSWORD" ssh "$REMOTE_HOST" "mkdir -p $REMOTE_DIR" # Copy files to the remote directory sshpass -p "$SSH_PASSWORD" scp "$RESTART_SCRIPT" "$REMOTE_HOST:$REMOTE_DIR" sshpass -p "$SSH_PASSWORD" scp "$INIT_SCRIPT" "$REMOTE_HOST:$REMOTE_DIR" # Change permissions to 775 sshpass -p "$SSH_PASSWORD" ssh "$REMOTE_HOST" "chmod 775 $REMOTE_DIR/*" # Execute the init sshpass -p "$SSH_PASSWORD" ssh "$REMOTE_HOST" "$REMOTE_DIR/$(basename $INIT_SCRIPT) &" echo "Files copied, permissions changed, and executed."