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 10-10-2016, 04:52 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,675
Adding a custom script during startup

While the docker container tries to do many things, it's likely that there are configurations that will require extra tweaking.

During startup if the following script exists in the SAGE_HOME (ie, root of the sagetv server) then it will get executed.

Code:
sagetv-user-script.sh
(Full path inside the container is)
Code:
/opt/sagetv/server/sagetv-user-script.sh
This script must be a valid linux script. ie...
1. Must have a script header like
Code:
#!/bin/bash
2. Must be executable
Code:
# chmod 775 sagetv-user-script.sh
3. Must be an in unix format (ie, if you are creating/editing this file from Windows, make sure the editor that you are using supports saving a file unix line endings). (If you are editing this file using vi, vim, or nano, etc, it will already have the correct line endings)

So, using the "sagetv-user-script.sh", you can do whatever you want BEFORE sagetv is started.
Reply With Quote
  #2  
Old 10-10-2017, 12:38 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,103
Does SageTV wait for this script to complete before executing or does it execute SageTV concurrently with this script? Let's say I wanted to use a SageTV startup script to restart my HD-PVRs. If I ran the script to do a power cycle and then waited 10 seconds (or longer) would I be good?
__________________
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
  #3  
Old 10-10-2017, 01:23 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,675
Quote:
Originally Posted by wayner View Post
Does SageTV wait for this script to complete before executing or does it execute SageTV concurrently with this script? Let's say I wanted to use a SageTV startup script to restart my HD-PVRs. If I ran the script to do a power cycle and then waited 10 seconds (or longer) would I be good?
It should wait. The intention was really to add a hook to do something important BEFORE sagetv was started.
Reply With Quote
  #4  
Old 10-10-2017, 01:27 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,103
Ok then I think this could be a good way to restart my HD-PVRs rather than using a cron job that runs during the weekly backup process described here.

On a related note - what is the easiest way to have SageTV trigger a SageTV system message when the service restarts? I use your notification plugin so this way I will see when this happens.
__________________
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
  #5  
Old 10-28-2017, 03:33 PM
mibsy mibsy is offline
Sage User
 
Join Date: Jul 2007
Posts: 57
Quote:
Originally Posted by wayner View Post
Ok then I think this could be a good way to restart my HD-PVRs rather than using a cron job that runs during the weekly backup process described here.

On a related note - what is the easiest way to have SageTV trigger a SageTV system message when the service restarts? I use your notification plugin so this way I will see when this happens.
Did you write a script to reboot your HD-PVRs. If so, could you share? I'd like to do the same.
Reply With Quote
  #6  
Old 10-28-2017, 05:31 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,103
Quote:
Originally Posted by mibsy View Post
Did you write a script to reboot your HD-PVRs. If so, could you share? I'd like to do the same.
I can share it but unless you have the same hardware, which in my case is a Digital Loggers web controlled power switch, then it won't be of any use to you. How to you plan to switch the power on and off?
__________________
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
  #7  
Old 10-29-2017, 08:27 PM
mibsy mibsy is offline
Sage User
 
Join Date: Jul 2007
Posts: 57
Quote:
Originally Posted by wayner View Post
I can share it but unless you have the same hardware, which in my case is a Digital Loggers web controlled power switch, then it won't be of any use to you. How to you plan to switch the power on and off?
My fault, I was thinking you were telling them to reboot directly over the HD-PVR USB connection. I might be able to do it with my UPS. I'll look into it. Thanks.
Reply With Quote
  #8  
Old 12-06-2017, 11:00 AM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
What user does this script run as?
__________________
Running SageTV on unRAID via Docker
Tuning handled by HDHR3-6CC-3X2 using OpenDCT
Reply With Quote
  #9  
Old 12-06-2017, 11:12 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,675
Quote:
Originally Posted by bcjenkins View Post
What user does this script run as?
It runs as sagetv. It also takes care of the ownerships and file format (ie, settting it properly) before running it.
Reply With Quote
  #10  
Old 03-19-2021, 04:31 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,103
So I want to run a script that uses the telnet command. But telnet does not exist in the docker. I was able to manually install it with apt-get update and apt-get install telnet.

Will Linux commands installed by the end user within a docker get deleted (I am guessing that they will)? What causes them to get deleted?

Can I request that telnet be added to the core sagetv docker builds?

The reason is that telnet can be used to start or stop sagetv extenders.
__________________
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
  #11  
Old 04-14-2021, 01:04 PM
KeithAbbott KeithAbbott is online now
Sage Icon
 
Join Date: Oct 2009
Location: Southeastern Michigan
Posts: 1,177
Quote:
Originally Posted by wayner View Post
So I want to run a script that uses the telnet command. But telnet does not exist in the docker. I was able to manually install it with apt-get update and apt-get install telnet.

Will Linux commands installed by the end user within a docker get deleted (I am guessing that they will)? What causes them to get deleted?

Can I request that telnet be added to the core sagetv docker builds?

The reason is that telnet can be used to start or stop sagetv extenders.
My SageTV docker contains /usr/lib/python3.5/telnetlib.py, which is a Python module/library which implements the Telnet protocol. My docker also contains /usr/bin/python3.5, between those two files I am able to execute a script to power on my extenders when the SageTV docker is started. I'm not sure if the docker itself originally contained those files, or if a plug-in put them there, but I know I did not do any sort of "apt get install" myself to put them there. You might want to check and see if your docker container has those files.

But not being familiar with the inner workings of docker containers, I am also wondering if the sagetv-user-script.sh will be deleted or overlaid at some point by an update to the docker image. Also, I am not sure where the best place is to locate the python script that actually performs the power on function, so that it also does not go missing at some point in the future. Any docker gurus out there that could offer any guidance?
__________________
Server: MSI Z270 SLI Plus ATX Motherboard, Intel i7-7700T CPU, 32GB Memory, unRAID 6.9.2, SageTV & OpenDCT Dockers
Tuners: 2 x SiliconDust HDHomeRun Prime Cable TV Tuners
Clients: Multiple HD300 Extenders, Multiple Fire TV Stick 4K w/MiniClient
Miscellaneous: Multiple Sony RM-VLZ620 Universal Remote Controls
Reply With Quote
  #12  
Old 04-14-2021, 02:11 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,103
I am guessing that something else added Python to your docker as I am pretty sure that it is not installed by default. I am also pretty sure that the sagetv-user-script.sh should not be deleted by a docker upgrade as that was created by stuckless who built the docker and created the idea for this script.

You are probably responding because you read my other thread, but in case you haven't check out this thread that I created a few weeks ago.
https://forums.sagetv.com/forums/showthread.php?t=66696
__________________
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
  #13  
Old 04-14-2021, 04:00 PM
KeithAbbott KeithAbbott is online now
Sage Icon
 
Join Date: Oct 2009
Location: Southeastern Michigan
Posts: 1,177
I did see your other thread, but I was looking for a solution that did not require installing additional software. Sure wish I knew how Python made it's way into my docker. In any case, I will use it to my advantage.

I ended up figuring out how to put inline Python code into a bash script, so now my sagetv-user-script.sh is all I need to power up all of my extenders. I am not using your trick to put a 30 second delay prior to attempting to power up the extender, the extender keeps looking for the server and once it gets a response, completes the connection and goes to the home screen.
__________________
Server: MSI Z270 SLI Plus ATX Motherboard, Intel i7-7700T CPU, 32GB Memory, unRAID 6.9.2, SageTV & OpenDCT Dockers
Tuners: 2 x SiliconDust HDHomeRun Prime Cable TV Tuners
Clients: Multiple HD300 Extenders, Multiple Fire TV Stick 4K w/MiniClient
Miscellaneous: Multiple Sony RM-VLZ620 Universal Remote Controls
Reply With Quote
  #14  
Old 04-14-2021, 04:24 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,103
I had originally written this script in Python but then I realized that this would required Python to be installed in the docker - which I didn't think you had. That is why I rewrote it as a shell script, but then realized that you may now have to install telnet since that isn't installed in the pared down linux commands available in the docker.
__________________
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
Adding custom main menu item -Video Folder or Category wado1971 SageTV v7 Customizations 0 08-10-2010 02:58 PM
Adding a custom filter to Sage Movie Wall medwynd SageMC Custom Interface 0 04-25-2010 10:08 AM
Adding custom command for launching external program dinki SageMC Custom Interface 14 01-22-2010 08:16 AM
TIP: Adding automatic Wiz.bin backup to startup laurenglenn SageTV Linux 5 03-31-2006 11:52 AM
Adding a pause during close in custom xml menu... n3w813 SageTV Customizations 2 05-16-2005 01:37 PM


All times are GMT -6. The time now is 11:37 AM.


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