From 6b8001612330d593f829881bcc5588dc8e02b086 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Wed, 21 Jun 2023 10:54:52 -0500 Subject: [PATCH] feat: script to deploy working changes to server --- plugin/scripts/deploy-dev.sh | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 plugin/scripts/deploy-dev.sh diff --git a/plugin/scripts/deploy-dev.sh b/plugin/scripts/deploy-dev.sh new file mode 100755 index 000000000..337ff0a03 --- /dev/null +++ b/plugin/scripts/deploy-dev.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Path to store the last used server name +state_file="$HOME/.deploy_state" + +# Read the last used server name from the state file +if [[ -f "$state_file" ]]; then + last_server_name=$(cat "$state_file") +else + last_server_name="" +fi + +# Read the server name from the command-line argument or use the last used server name as the default +server_name="${1:-$last_server_name}" + +# Check if the server name is provided +if [[ -z "$server_name" ]]; then + echo "Please provide the SSH server name." + exit 1 +fi + +# Save the current server name to the state file +echo "$server_name" > "$state_file" + +# Source directory path (relative to the script's location) +source_directory="plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers" + +# Destination directory path +destination_directory="/usr/local/emhttp/plugins/dynamix.my.servers" + +# Replace the value inside the rsync command with the user's input +rsync_command="rsync -avz -e ssh $source_directory/ root@${server_name}.local:$destination_directory/" + +echo "Executing the following command:" +echo "$rsync_command" + +# Execute the rsync command +eval "$rsync_command"