SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV Linux > SageTV for unRAID/Docker

Notices

SageTV for unRAID/Docker Discussion related to SageTV for unRAID/Docker. Questions, issues, problems, suggestions, etc. relating to SageTV for unRAID/Docker should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-22-2021, 04:16 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,199
Automatically "power on" extenders on docker start

How to use:
  1. Download the two attached files.
  2. Change the Extenders list in the start_extenders.sh file to the IP addresses used by your extenders.
  3. Remove the .txt extensions so that the files both have extensions of .sh.
  4. Look to see if you have a file called /appdata/sagetv/server/sagetv-user-script.sh - if you do see the warning below
  5. Put both of these files in the /appdata/sagetv/server folder.
  6. Start a ssh session to your unRAID server.
  7. Start a bash session in your sagetv docker with "docker exec -it sagetv /bin/bash"
  8. Download the package list with "apt-get update"
  9. Install telnet with "apt-get install telnet"

Warning - if you already have a sagetv-user-script.sh file then you will need to just copy line 2 of the attached version of sagetv-user-script.sh into your existing sagetv-user-script.sh file.

Pre-req: Your extenders should have IP addresses that don't change. This can be done either by setting up a static IP address in the extenders setup pages, or by setting up DHCP reservations in your router's UI.

This thread contains scripts to restart your HD200 and HD300 extenders automatically whenever the SageTV docker starts. This is possible because the SageTV docker looks for a script file called sagetv-user-script.sh and it runs this script as part of the docker start process. The script in this threadn starts a telnet session on each SageTV extender and "turns on" the extender.

Note that telnet is not installed in the sagetv docker (this may change in the future), so you need to manually install telnet in the docker. You will need to redo this if your SageTV version is updated or you install a new version of the docker.

There is a slight trick needed here as SageTV waits for this script to exit before contiuing to start up, but the extenders can't connect to the SageTV server unless it is up and running. Therefore you have to use this script to call another script and have it run asynchronously, which you can do by putting an & after the script name.

This script sends some output to your sagetv log file - I have posted a sample of what you will see below. Note that the script waits 30 seconds for SageTV to get up and running before turning on the extenders.

Here is the sagetv-user-script.sh script
Code:
#!/bin/bash
bash /opt/sagetv/server/start_extenders.sh &
Here is the start_extenders.sh script - This is the script that actually does all of the work. It loops through a list of extenders (by IP address). Replace the list in the 9th line with your actual extender IP addresses

Code:
#!/bin/bash

echo -e "\n" 
echo "==========================================================" 
echo "Starting all extenders at : " $(date) 
echo "==========================================================" 

# Put the IP addresses of your extenders in the list below
declare -a  Extenders=("192.168.1.48" "192.168.1.50" "192.168.1.51" "192.168.1.52" "192.168.1.56" "192.168.1.58" "192.168.1.59" "192.168.1.143")
sleep 30
# Iterate the string array using for loop
for val in ${Extenders[@]}; do
     { sleep 0.2; echo "root"; sleep 0.2; echo "killall waitpower"; sleep 0.2; }  | telnet $val 
	 echo -e "======================================================\n" 
done
Sample Log output (Some of the lines are from SageTV and not from this script):
Code:
dos2unix: converting file /opt/sagetv/server/sagetv-user-script.sh to Unix format ...

=========================================================
*** Running /etc/my_init.d/90-sagetv...
Starting all extenders at : Mon Mar 22 01:39:41 EDT 2021
==========================================================
Changing to SageTV directory /opt/sagetv/server
cat: activkey: No such file or directory
*** Running /etc/rc.local...
Executing pre-scripts
*** Booting runit daemon...
*** Runit started as PID 96
Starting server mode
./startsagecore: line 54: /var/run/sagetv.pid: Permission denied
Mar 22 01:39:44 Hoylake syslog-ng[106]: syslog-ng starting up; version='3.5.6'

Main is starting
Trying 192.168.1.48...
Connected to 192.168.1.48.
Escape character is '^]'.

tango3 login: root
tango3[~]# killall waitpower
Connection closed by foreign host.
tango3[~]# ======================================================

Trying 192.168.1.50...
Connected to 192.168.1.50.
Escape character is '^]'.

tango3 login: root
tango3[~]# killall waitpower
Connection closed by foreign host.
tango3[~]# ======================================================

Trying 192.168.1.51...
Connected to 192.168.1.51.
Escape character is '^]'.

tango3 login: root
tango3[~]# killall waitpower
Connection closed by foreign host.
tango3[~]# ======================================================

Trying 192.168.1.52...
Connected to 192.168.1.52.
Escape character is '^]'.

tango3 login: root
tango3[~]# killall waitpower
Connection closed by foreign host.
tango3[~]# ======================================================

Trying 192.168.1.56...
Connected to 192.168.1.56.
Escape character is '^]'.

STP-HD200 login: root
killall waitpower
STP-HD200[/tmp]# killall waitpower
Connection closed by foreign host.
STP-HD200[/tmp]# ======================================================

Trying 192.168.1.58...
Connected to 192.168.1.58.
Escape character is '^]'.

STP-HD200 login: root
STP-HD200[/tmp]# killall waitpower
killall: waitpower: no process killed

Connection closed by foreign host.
STP-HD200[/tmp]# ======================================================

Trying 192.168.1.59...
Connected to 192.168.1.59.
Escape character is '^]'.

STP-HD200 login: root
STP-HD200[/tmp]# killall waitpower
killall: waitpower: no process killed

Connection closed by foreign host.
STP-HD200[/tmp]# ======================================================

Trying 192.168.1.143...
Connected to 192.168.1.143.
Escape character is '^]'.

tango3 login: root
tango3[~]# killall waitpower
Connection closed by foreign host.
tango3[~]# ======================================================
Attached Files
File Type: txt sagetv-user-script.sh.txt (58 Bytes, 56 views)
File Type: txt start_extenders.sh.txt (664 Bytes, 56 views)
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to unraid docker, no "TV" Menu Item dealsdyker SageTV for unRAID/Docker 7 09-30-2017 09:30 AM
"Backdrops" "SageTV" "Covers" folders - what's creating them mp328 Sage My Movies 4 09-20-2010 05:31 PM
"Set defaults" for Series forgets "Keep"/"Auto-delete" setting maxpower SageMC Custom Interface 9 05-14-2008 09:44 PM


All times are GMT -6. The time now is 09:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.