Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
trying to make an initscript for get_iplayer Web PVR Manager
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1166
Location: Edinburgh, UK

PostPosted: Sat Feb 18, 2012 7:23 pm    Post subject: trying to make an initscript for get_iplayer Web PVR Manager Reply with quote

Hello,

Title says it all really. I'm often using get_iplayer (I dunno if a link is entirely cool here, but Google is your friend) for my BBC viewing needs, and wanted to make an initscript to launch the web PVR Manager that comes with it. Previously I was just launching it from a script in /etc/local.d/, but I'd be happier if I could integrate it with the proper init system and that might make it more useful for others.

CAVEAT: this app comes with a great big warning that it is not at all secure, so I'll just reiterate that: it should *not* be exposed to untrusted networks. There, I warned you.

Now, the get_iplayer.cgi script is a Perl CGI script that acts as a wrapper for the main Perl script get_iplayer that does the work. It has ffmpeg, rtmpdump and a couple of Perl modules as dependencies (you'll be told what you need when you try to run it). If you run get_iplayer.cgi from the commandline, it stays in foreground and logs to the console. No problem, start-stop-daemon has options to make such scripts daemonise nicely, so here's the script I came up with:
Code:
#!/sbin/runscript

GIP_USER="myname"
GIP_DIR="/home/${GIP_USER}/iplayer"
GIP_BIN="${GIP_DIR}/get_iplayer.cgi"
GIP_PORT="1999"
GIP_PIDFILE="${GIP_DIR}/gip.pid"
GIP_LOGFILE="${GIP_DIR}/gip.log"


depend() {
   need net
}

start() {
   ebegin "Starting get_iplayer"
   start-stop-daemon \
      --start --exec ${GIP_BIN} \
      --interpreted \
      --user ${GIP_USER} \
      --chdir ${GIP_DIR} \
      --background \
      --pidfile ${GIP_PIDFILE} \
      --make-pidfile ${GIP_PIDFILE} \
      --stdout ${GIP_LOGFILE} \
      --stderr ${GIP_LOGFILE} \
      --verbose \
      --wait 1000 \
      -- \
      -p ${GIP_PORT} \
   eend $?
}

stop() {
   ebegin "Stopping get_iplayer"
   start-stop-daemon --stop --pidfile ${GIP_PIDFILE}
   eend $?
}


Note: yes this is far from perfect, it breaks a lot of rules for a "good" initscript, but it seems it should work all the same, yet it doesn't. Can anyone suggest where I've gone wrong?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum