54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# SSH connection details
|
|
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
|
|
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
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: $0 <command>"
|
|
exit 1
|
|
fi
|
|
|
|
# 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
|