Update remote.sh

This commit is contained in:
Sthope 2024-03-17 16:15:31 +01:00
parent febb2f3688
commit 89407d63d7

View File

@ -5,11 +5,23 @@ SSH_USER="username"
SSH_PASSWORD="password"
SMARTTV_IP="remote_ip"
SMARTTV_SCRIPT="python3 smarttv.py"
SMARTTV_OPS_REBOOT="sudo reboot"
SMARTTV_OPS_AUDIO="pacmd set-default-sink alsa_output.pci-0000_00_1f.3.hdmi-stereo"
# Function to execute Python script remotely
execute_remote() {
local command="$1"
sshpass -p "$SSH_PASSWORD" ssh "$SSH_USER@$SMARTTV_IP" "$SMARTTV_SCRIPT $command"
send_command() {
local COMMAND="$1"
sshpass -p "$SSH_PASSWORD" ssh "$SSH_USER@$SMARTTV_IP" "$SMARTTV_SCRIPT" "$COMMAND"
}
# Function to reboot OPS remotely
ops_reboot() {
sshpass -p "$SSH_PASSWORD" ssh "$SSH_USER@$SMARTTV_IP" "$SMARTTV_OPS_REBOOT"
}
# Function to change the Audio source of the OPS
change_ops_audio() {
sshpass -p "$SSH_PASSWORD" ssh "$SSH_USER@$SMARTTV_IP" "$SMARTTV_OPS_AUDIO"
}
# Check if a command is provided
@ -18,5 +30,24 @@ if [ $# -eq 0 ]; then
exit 1
fi
# Call the function with the provided command
execute_remote "$1"
# Call the appropriate function based on the provided command
case "$1" in
send_command)
if [ $# -lt 2 ]; then
echo "Usage: $0 send_command <command>"
exit 1
fi
send_command "$2"
;;
ops_reboot)
ops_reboot
;;
change_ops_audio)
change_ops_audio
;;
*)
echo "Unknown command: $1"
echo "Usage: $0 <send_command|ops_reboot|change_ops_audio> [additional arguments]"
exit 1
;;
esac