Recipe for NASA TV Satellite Receiver

  • base netinst install of jessie - deselect everything from tasksel
    • hostname satellite – domain mcp.lcl
    • root on SSD (discard, noatime)
    • RAID-1 across two 1 TB drives, LVM with swap and video partitions
  • > /etc/motd
  • apt-get --no-install-recommends install aptitude
  • aptitude install ssh (this will pull in xauth, but that's okay)
  • aptitude install less fbset screen rsync psmisc file patch ethtool strace tcpdump vim bzip2 xz-utils
  • aptitude --without-recommends install dnsutils
  • adduser tdobes adm
  • adduser tdobes systemd-journal
  • aptitude install dbus
  • sed -i -e 's/^deb.* main$/& contrib non-free/g' /etc/apt/sources.list
  • aptitude update && aptitude forget-new
  • aptitude install intel-microcode
  • aptitude install firmware-realtek # for r8169 NIC's
  • aptitude install firmware-linux-nonfree # for ATI video card
  • adjust /etc/udev/rules.d/70-persistent-net.rules to set NIC with main network as eth0
    • if it was necessary to swap eth0/eth1, update etc/network/interfaces as well
  • aptitude install ifplugd
  • sed -i -e 's/^INTERFACES=""/INTERFACES="eth0"/g' /etc/default/ifplugd
  • sed -i -e 's/^allow-hotplug eth0/#allow-hotplug eth0/g' /etc/network/interfaces
  • aptitude --without-recommends install ntp
    echo '[Unit]' > /etc/systemd/system/ntp.service
    echo 'Description=Network Time Protocol daemon' >> /etc/systemd/system/ntp.service
    echo 'After=network.target' >> /etc/systemd/system/ntp.service
    echo >> /etc/systemd/system/ntp.service
    echo '[Service]' >> /etc/systemd/system/ntp.service
    echo 'ExecStart=/usr/sbin/ntpd -n -g -u ntp:ntp' >> /etc/systemd/system/ntp.service
    echo >> /etc/systemd/system/ntp.service
    echo '[Install]' >> /etc/systemd/system/ntp.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ntp.service
    systemctl enable ntp.service
  • mkdir -p /etc/systemd/system/ssh.socket.d
    echo '[Socket]' > /etc/systemd/system/ssh.socket.d/port-2222.conf
    echo 'ListenStream=2222' >> /etc/systemd/system/ssh.socket.d/port-2222.conf
    systemctl disable ssh.service && systemctl enable ssh.socket
  • mkdir -p /etc/systemd/system/getty\@tty1.service.d
    echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
    echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf
  • systemctl mask networking.service # we use ifplugd instead
    echo 'D /run/network 0755 root root' > /etc/tmpfiles.d/debian-networking.conf
    echo 'F /run/network/ifstate 0644 root root - lo=lo' >> /etc/tmpfiles.d/debian-networking.conf
  • aptitude purge acpid acpi-support-base # systemd-logind takes care of this
  • sed -i -e 's/^GRUB_CMDLINE_LINUX_DEFAULT="quiet"$/GRUB_CMDLINE_LINUX_DEFAULT="quiet panic=5"/g' /etc/default/grub && update-grub
  • systemctl mask keyboard-setup.service
    systemctl mask console-setup.service
    systemctl mask rc-local.service
  • aptitude --without-recommends install irqbalance
  • echo '/dev/mapper/raid-video        /mnt/video     ext4     rw,noatime     0       2' >> /etc/fstab
    mkdir -p /mnt/video
    mount /mnt/video
  • aptitude install xserver-xorg-video-nouveau xserver-xorg-input-evdev xserver-xorg-input-void
  • aptitude install xinit xinput evilwm xdotool x11vnc unclutter x11-xserver-utils
  • sed -i 's/START_UNCLUTTER="true"/START_UNCLUTTER="false"/g' /etc/default/unclutter
    sed -i -e 's/^use-ssh-agent$/#use-ssh-agent/g' /etc/X11/Xsession.options
  • dpkg-reconfigure x11-common – set “Users allowed to start the X server” to “Anybody”
  • aptitude install alsa-utils fonts-freefont-ttf
  • adduser player # Name: Video Player (no password)
  • adduser player audio
  • adduser player video
  • adduser tdobes audio
  • adduser tdobes video
  • obtain satellite card firmware, then:
    # (old pci card)
    #cp -a dvb-fe-cx24116-1.23.86.1.fw /lib/firmware/
    #ln -s dvb-fe-cx24116-1.23.86.1.fw /lib/firmware/dvb-fe-cx24116.fw
    
    # (new pcie card with loopthrough does not need firmware)
    
    # (new pcie card without loopthrough)
    cp -a dvb-fe-ds3000.fw.fw /lib/firmware/
  • aptitude install dvb-apps dvbsnoop
  • wget -O- "http://apt.tvheadend.org/repo.gpg.key" | apt-key add -
    echo 'deb http://apt.tvheadend.org/release jessie main' > /etc/apt/sources.list.d/tvheadend.list
    aptitude update && aptitude forget-new && aptitude install tvheadend
    ** you'll be asked to create a root user for tvheadend.  username: root  **
    
    systemctl stop tvheadend
    
    echo '[Unit]' > /etc/systemd/system/tvheadend.service
    echo 'Description=tvheadend' >> /etc/systemd/system/tvheadend.service
    echo 'After=network.target' >> /etc/systemd/system/tvheadend.service
    echo >> /etc/systemd/system/tvheadend.service
    echo '[Service]' >> /etc/systemd/system/tvheadend.service
    echo 'ExecStart=/usr/bin/tvheadend -f -u hts -g video' >> /etc/systemd/system/tvheadend.service
    echo 'Type=forking' >> /etc/systemd/system/tvheadend.service
    echo 'Restart=always' >> /etc/systemd/system/tvheadend.service
    echo 'RestartSec=1' >> /etc/systemd/system/tvheadend.service
    echo >> /etc/systemd/system/tvheadend.service
    echo '[Install]' >> /etc/systemd/system/tvheadend.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/tvheadend.service
    
    systemctl daemon-reload && systemctl enable tvheadend && systemctl start tvheadend
  • mkdir -p /mnt/video/recordings
    chown -R hts:video /mnt/video/recordings && chmod 0775 /mnt/video/recordings && chmod g+s /mnt/video/recordings
  • Configure tvheadend – http://satellite.mcp.lcl:9981/
    • Configuration → DVB Inputs → TV adapters
      • Select tuner card (Conexant CX24116/CX24118 : DVB-S #0) - check “Enabled”, SatConfig “Advanced (Non-Universal LNBs, Rotors, etc.)”, click Save (old pci card)
      • Select tuner card (STV090x Multistandard : DVB-S #0) - check “Enabled”, SatConfig “Advanced (Non-Universal LNBs, Rotors, etc.)”, click Save (new pcie card with loopthrough)
      • Select tuner card (Montage Technology DS3000 : DVB-S #0) - check “Enabled”, SatConfig “Advanced (Non-Universal LNBs, Rotors, etc.)”, click Save (new pcie card without loopthrough)
      • Select tuner card - check “Power Save”, click Save (Note: According to tvheadend bug tracker, power save makes it re-open the file descriptor for linuxdvb on each tune request.)
      • Select “Advanced (Non-universal LNBs, Rotors, etc.)” - set orbital positions to 1, set init rotor time to 0, click Save
      • Select “Position #1” - check “Enabled, set name to “C band”, set LNB type to “C-Band”
    • Configuration → DVB Inputs → Networks
      • Add - DVB-S network - network name “AMC-18C”, check service ID's as channel numbers, orbital position “105W : AMC 15/18”
      • Add - DVB-S network - network name “Galaxy 13”, check service ID's as channel numbers, orbital position “127W : Galaxy 13/Horizons 1”
    • Configuration → DVB Inputs → TV adapters
      • Select “C band” - select “AMC-18C” for networks, click Save
      • Select “C band” - select “Galaxy 13” for networks, click Save
    • Configuration → DVB Inputs → Muxes
      • Add - AMC-18C - frequency 3760000, symbol rate 28068100, polarisation V, modulation QPSK, FEC 3/4
      • Select 3760V, click Edit, and change scan status to ACTIVE (or maybe PEND?)
      • Add - Galaxy 13 - frequency 3920000, symbol rate 28068100, polarisation V, modulation QPSK, FEC 3/4
      • Select 3920V, click Edit, and change scan status to ACTIVE (or maybe PEND?)
      • Wait for scan status to say IDLE and scan result to say OK
    • Configuration → DVB Inputs → Services
      • you should see four services
      • Click on Map All button, then Map button in pop-up window
    • Configuration → Channel / EPG → Channels
      • For each channel, assign a channel number which matches service ID (we turned on an option to do that automatically, but apparently it doesn't work - argh)
      • 101 - set name to “NTV-1 (Public)”
      • 102 - set name to “NTV-2 (Education)”
      • 103 - set name to “NTV-3 (Media)”
      • 104 - set name to “NTV-4 (UHD)”
    • Configuration → Recording → Digital Video Recorder Profiles
      • Select ”(Default Profile)“ - set stream profile to matroska, set recording system path to /mnt/video/recordings, click Save
      • Note: After clicking Save, the “Parameters” section might disappear and the UI will become unresponsive. Apparently, this is a bug. Reload the web UI and it'll work again.
    • Configuration → Access Entries
      • Click Add - check Enabled, Web Interface, Streaming, HTSP Streaming, Video Recorder, HTSP DVR, All DVR, and All DVR (rw) - leave username and password blank, set comment to “Allow All to Stream”, click Save
  • aptitude install mpv
  • GPU-accelerated video decoding:
    aptitude install mesa-vdpau-drivers vainfo
    # obtain firmware -- see http://nouveau.freedesktop.org/wiki/VideoAcceleration/#firmware
    
    # RUN AS USER ACCOUNT:
    mkdir /tmp/nouveau
    pushd /tmp/nouveau
    wget --no-check-certificate https://raw.github.com/imirkin/re-vp2/master/extract_firmware.py
    wget http://us.download.nvidia.com/XFree86/Linux-x86/325.15/NVIDIA-Linux-x86-325.15.run
    sh NVIDIA-Linux-x86-325.15.run --extract-only
    python2 extract_firmware.py
    
    su
    # RUN AS ROOT:
    mkdir -p /lib/firmware/nouveau
    cp -d nv* vuc-* /lib/firmware/nouveau/
    
    popd
    rm -r /tmp/nouveau
  • echo 'deb http://ftp.us.debian.org/debian/ testing main' > /etc/apt/sources.list.d/testing.list
    echo 'Package: livestreamer' > /etc/apt/preferences.d/livestreamer-testing
    echo 'Pin: release a=testing' >> /etc/apt/preferences.d/livestreamer-testing
    echo 'Pin-Priority: 999' >> /etc/apt/preferences.d/livestreamer-testing
    echo >> /etc/apt/preferences.d/livestreamer-testing
    echo 'Package: python-livestreamer' >> /etc/apt/preferences.d/livestreamer-testing
    echo 'Pin: release a=testing' >> /etc/apt/preferences.d/livestreamer-testing
    echo 'Pin-Priority: 999' >> /etc/apt/preferences.d/livestreamer-testing
    
    echo 'Package: *' > /etc/apt/preferences.d/testing
    echo 'Pin: release a=testing' >> /etc/apt/preferences.d/testing
    echo 'Pin-Priority: 99' >> /etc/apt/preferences.d/testing
    
    aptitude update && aptitude forget-new && aptitude install livestreamer
  • temporary patch to fix ustream plugin
    • cat > /root/livestreamer-ustream.patch, then paste in:
      --- livestreamer/plugins/ustreamtv.py.old       2016-01-04 21:13:48.232391953 -0600
      +++ livestreamer/plugins/ustreamtv.py   2016-01-04 19:20:55.761168574 -0600
      @@ -71,25 +71,31 @@
               }]
           )
       })
      -_stream_schema = validate.Schema({
      -    "name": validate.text,
      -    "url": validate.text,
      -    "streams": validate.all(
      -        _amf3_array,
      -        [{
      -            "chunkId": validate.any(int, float),
      -            "chunkRange": {validate.text: validate.text},
      -            "chunkTime": validate.any(int, float),
      -            "offset": validate.any(int, float),
      -            "offsetInMs": validate.any(int, float),
      -            "streamName": validate.text,
      -            validate.optional("bitrate"): validate.any(int, float),
      -            validate.optional("height"): validate.any(int, float),
      -            validate.optional("description"): validate.text,
      -            validate.optional("isTranscoded"): bool
      -        }],
      -    )
      -})
      +_stream_schema = validate.Schema(
      +    validate.any({
      +        "name": validate.text,
      +        "url": validate.text,
      +        "streams": validate.all(
      +            _amf3_array,
      +            [{
      +                "chunkId": validate.any(int, float),
      +                "chunkRange": {validate.text: validate.text},
      +                "chunkTime": validate.any(int, float),
      +                "offset": validate.any(int, float),
      +                "offsetInMs": validate.any(int, float),
      +                "streamName": validate.text,
      +                validate.optional("bitrate"): validate.any(int, float),
      +                validate.optional("height"): validate.any(int, float),
      +                validate.optional("description"): validate.text,
      +                validate.optional("isTranscoded"): bool
      +            }],
      +        )
      +    },
      +    {
      +        "name": validate.text,
      +        "varnishUrl": validate.text
      +    })
      +)
       _channel_schema = validate.Schema({
           validate.optional("stream"): validate.any(
               validate.all(
      @@ -502,6 +508,8 @@
       
               streams = {}
               for provider in channel["stream"]:
      +            if "varnishUrl" in provider:
      +                continue
                   provider_url = provider["url"]
                   provider_name = provider["name"]
                   for stream_index, stream_info in enumerate(provider["streams"]):
    • pushd /usr/lib/python2.7/dist-packages && patch -p0 < /root/livestreamer-ustream.patch && rm /root/livestreamer-ustream.patch && popd
  • echo '#!/bin/sh' > /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    echo 'pkill -9 evilwm' >> /usr/local/bin/player-xsession.sh
    echo 'pkill -9 x11vnc' >> /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    # old (with second video card, we can end up with DVI-I-1 or DVI-I-2, so split this up):
    # echo 'xrandr --output DVI-I-1 --mode 1920x1080 --output HDMI-1 --mode 1920x1080 --right-of DVI-I-1' >> /usr/local/bin/player-xsession.sh
    # echo 'xrandr --output DVI-I-1 --mode 1080p --output HDMI-1 --mode 1080p --right-of DVI-I-1' >> /usr/local/bin/player-xsession.sh
    echo 'xrandr --output HDMI-1 --mode 1080p' >> /usr/local/bin/player-xsession.sh
    echo 'xrandr --output DVI-I-1 --mode 1080p --left-of HDMI-1' >> /usr/local/bin/player-xsession.sh
    echo 'xrandr --output DVI-I-2 --mode 1080p --left-of HDMI-1' >> /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    echo 'x11vnc -rfbport 5900 -q -usepw -N -ncache 0 -shared -forever &' >> /usr/local/bin/player-xsession.sh
    echo 'x11vnc -clip xinerama0 -rfbport 5901 -q -usepw -N -ncache 0 -shared -forever &' >> /usr/local/bin/player-xsession.sh
    echo 'x11vnc -clip xinerama1 -rfbport 5902 -q -usepw -N -ncache 0 -shared -forever &' >> /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    echo 'xset s off #disable screensaver' >> /usr/local/bin/player-xsession.sh
    echo 'xset -dpms #disable automatic power saving' >> /usr/local/bin/player-xsession.sh
    echo 'unclutter -grab -idle 2 & #daemon to auto-hide mouse' >> /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    echo '#SHELL=/bin/bash xterm &' >> /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    echo "# for some reason, this doesn't work unless you do it twice:" >> /usr/local/bin/player-xsession.sh
    echo 'systemd-notify READY=1' >> /usr/local/bin/player-xsession.sh
    echo 'systemd-notify READY=1' >> /usr/local/bin/player-xsession.sh
    echo >> /usr/local/bin/player-xsession.sh
    echo "exec evilwm -fn '*-clean-*'" >> /usr/local/bin/player-xsession.sh
    chmod +x /usr/local/bin/player-xsession.sh
    ln -s /usr/local/bin/player-xsession.sh /home/player/.xsession
    
    echo '[Unit]' > /etc/systemd/system/startx\@.service
    echo 'Description=Start Xorg for %I' >> /etc/systemd/system/startx\@.service
    echo >> /etc/systemd/system/startx\@.service
    echo '[Service]' >> /etc/systemd/system/startx\@.service
    echo 'ExecStart=-/usr/bin/startx -- -layout satellite -nolisten tcp -sharevts' >> /etc/systemd/system/startx\@.service # when you specify additional Xorg parameters, you have to include "-nolisten tcp" since it overrides the Debian defaults
    echo 'ExecStopPost=-/usr/bin/pkill -9 -U %I evilwm' >> /etc/systemd/system/startx\@.service
    echo 'User=%I' >> /etc/systemd/system/startx\@.service
    echo 'Type=notify' >> /etc/systemd/system/startx\@.service
    echo 'NotifyAccess=all' >> /etc/systemd/system/startx\@.service
    echo 'Restart=always' >> /etc/systemd/system/startx\@.service
    echo 'RestartSec=1' >> /etc/systemd/system/startx\@.service
    echo >> /etc/systemd/system/startx\@.service
    echo '[Install]' >> /etc/systemd/system/startx\@.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/startx\@.service
    # systemctl enable startx\@player.service # doesn't work on old systemd releases
    ln -s /etc/systemd/system/startx\@.service /etc/systemd/system/multi-user.target.wants/startx\@player.service
    
    echo '#!/bin/sh' > /usr/local/bin/satellite_stream.sh
    echo >> /usr/local/bin/satellite_stream.sh
    echo 'case "$1" in' >> /usr/local/bin/satellite_stream.sh
    echo '  "101")' >> /usr/local/bin/satellite_stream.sh
    echo '    URL="http://satellite:9981/play/stream/channel/02d962c2d0c01577c551f16cac9e493c?profile=matroska" ;;' >> /usr/local/bin/satellite_stream.sh
    echo '  "102")' >> /usr/local/bin/satellite_stream.sh
    echo '    URL="http://satellite:9981/play/stream/channel/495add853a77aea57471a31390f8c628?profile=matroska" ;;' >> /usr/local/bin/satellite_stream.sh
    echo '  "103")' >> /usr/local/bin/satellite_stream.sh
    echo '    URL="http://satellite:9981/play/stream/channel/4c08372c41b8f19f27b15facb2af7d5f?profile=matroska" ;;' >> /usr/local/bin/satellite_stream.sh
    echo '  "104")' >> /usr/local/bin/satellite_stream.sh
    echo '    URL="--framedrop=decoder http://satellite:9981/play/stream/channel/7159cffb70efd5a67a2b854e41c51e5f?profile=pass" ;;' >> /usr/local/bin/satellite_stream.sh # temporary hack since we can't decode HEVC in realtime
    echo '  *)' >> /usr/local/bin/satellite_stream.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /usr/local/bin/satellite_stream.sh
    echo '    exit 1' >> /usr/local/bin/satellite_stream.sh
    echo '    ;;' >> /usr/local/bin/satellite_stream.sh
    echo 'esac' >> /usr/local/bin/satellite_stream.sh
    echo >> /usr/local/bin/satellite_stream.sh
    echo 'if [ `hostname -s` = "satellite" ]; then' >> /usr/local/bin/satellite_stream.sh
    echo '  # on satellite receiver' >> /usr/local/bin/satellite_stream.sh
    echo '  echo -n waiting for tvheadend' >> /usr/local/bin/satellite_stream.sh
    echo -n "  while netstat -lnt | awk '" >> /usr/local/bin/satellite_stream.sh
    echo -n '$4 ~ /:9981$/ {exit 1}' >> /usr/local/bin/satellite_stream.sh
    echo "'; do" >> /usr/local/bin/satellite_stream.sh
    echo '    echo -n .' >> /usr/local/bin/satellite_stream.sh
    echo '  done' >> /usr/local/bin/satellite_stream.sh
    echo '  echo done!' >> /usr/local/bin/satellite_stream.sh
    echo 'else' >> /usr/local/bin/satellite_stream.sh
    echo '  # on other computers (e.g. atsc tuner)' >> /usr/local/bin/satellite_stream.sh
    echo '  echo -n waiting for network/server' >> /usr/local/bin/satellite_stream.sh
    echo '  while ! ping -c 1 satellite > /dev/null 2> /dev/null ; do' >> /usr/local/bin/satellite_stream.sh
    echo '    echo -n .' >> /usr/local/bin/satellite_stream.sh
    echo '  done' >> /usr/local/bin/satellite_stream.sh
    echo '  echo done!' >> /usr/local/bin/satellite_stream.sh
    echo 'fi' >> /usr/local/bin/satellite_stream.sh
    echo >> /usr/local/bin/satellite_stream.sh
    echo '. set_audio_hdmi.sh' >> /usr/local/bin/satellite_stream.sh
    echo 'move_player.sh &' >> /usr/local/bin/satellite_stream.sh
    echo >> /usr/local/bin/satellite_stream.sh
    echo '# disabled for now: --hwdec=vdpau --hwdec-codecs=h264,mpeg2video,mpeg4,vc1' >> /usr/local/bin/satellite_stream.sh
    echo 'exec mpv --cache 2048 --demuxer-lavf-analyzeduration=0.1 --geometry=100%x100% --fs --no-osc --quiet --title=player$PLAYER $AUDIO $URL' >> /usr/local/bin/satellite_stream.sh
    chmod +x /usr/local/bin/satellite_stream.sh
    
    echo '#!/bin/sh' > /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo 'case "$1" in' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-public")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/nasahdtv" ;;' >> /usr/local/bin/web_stream.sh
    echo '  #"ustream-edu")' >> /usr/local/bin/web_stream.sh
    echo '  #  URL="http://www.ustream.tv/channel/nasa-educational" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-media")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/channel/nasa-media-channel" ;;' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo '  "youtube-public")' >> /usr/local/bin/web_stream.sh
    echo '    #URL="https://www.youtube.com/watch?v=HDh4uK9PvJU" ;;' >> /usr/local/bin/web_stream.sh
    echo '    URL="https://www.youtube.com/watch?v=UdmHHpAsMVw" ;;' >> /usr/local/bin/web_stream.sh
    echo '  #"youtube-edu")' >> /usr/local/bin/web_stream.sh
    echo '  #  URL="https://www.youtube.com/watch?v=nhORZ6Ep_jE" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "youtube-media")' >> /usr/local/bin/web_stream.sh
    echo '    #URL="https://www.youtube.com/watch?v=OX9I1KyNa8M" ;;' >> /usr/local/bin/web_stream.sh
    echo '    URL="https://www.youtube.com/watch?v=Fih5Wpe6ac4" ;;' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo '  "ustream-iss")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/channel/iss-hdev-payload" ;;' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo '  "ustream-csbf")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/channel/nas-csbf-operations" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-ssc")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/channel/nasa-stennis" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-msfc")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/channel/nasa-msfc" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-wallops")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/channel/nasa-tv-wallops" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-jpl")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/nasajpl" ;;' >> /usr/local/bin/web_stream.sh
    echo '  "ustream-jpl2")' >> /usr/local/bin/web_stream.sh
    echo '    URL="http://www.ustream.tv/nasajpl2" ;;' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo '  *)' >> /usr/local/bin/web_stream.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /usr/local/bin/web_stream.sh
    echo '    exit 1' >> /usr/local/bin/web_stream.sh
    echo '    ;;' >> /usr/local/bin/web_stream.sh
    echo 'esac' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo 'echo -n waiting for network/server' >> /usr/local/bin/web_stream.sh
    echo 'while ! ping -c 1 router.mcp.lcl > /dev/null 2> /dev/null ; do' >> /usr/local/bin/web_stream.sh
    echo '  echo -n .' >> /usr/local/bin/web_stream.sh
    echo '  sleep 1' >> /usr/local/bin/web_stream.sh
    echo 'done' >> /usr/local/bin/web_stream.sh
    echo 'echo done!' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo '. set_audio_hdmi.sh' >> /usr/local/bin/web_stream.sh
    echo 'move_player.sh &' >> /usr/local/bin/web_stream.sh
    echo >> /usr/local/bin/web_stream.sh
    echo '# disabled for now: --hwdec=vdpau --hwdec-codecs=h264,mpeg2video,mpeg4,vc1' >> /usr/local/bin/web_stream.sh
    echo 'exec livestreamer -v --player "mpv --cache 2048 --demuxer-lavf-analyzeduration=0.1 --geometry=100%x100% --fs --no-osc --quiet --title=player$PLAYER $AUDIO" --player-no-close $URL best' >> /usr/local/bin/web_stream.sh
    chmod +x /usr/local/bin/web_stream.sh
    
    echo '#!/bin/sh' > /usr/local/bin/set_audio_hdmi.sh
    echo >> /usr/local/bin/set_audio_hdmi.sh
    echo 'case "$PLAYER" in' >> /usr/local/bin/set_audio_hdmi.sh
    echo -n '  "1") export AUDIO=' >> /usr/local/bin/set_audio_hdmi.sh
    echo "'--ao=alsa:device=[hw:1,3]' ;;" >> /usr/local/bin/set_audio_hdmi.sh
    echo -n '  "2") export AUDIO=' >> /usr/local/bin/set_audio_hdmi.sh
    echo "'--ao=alsa:device=[hw:1,8]' ;;" >> /usr/local/bin/set_audio_hdmi.sh
    echo '  *)' >> /usr/local/bin/set_audio_hdmi.sh
    echo '    export AUDIO=' >> /usr/local/bin/set_audio_hdmi.sh
    echo "    echo 'WARNING: Unknown display; not setting ALSA output variables.'" >> /usr/local/bin/set_audio_hdmi.sh
    echo '    ;;' >> /usr/local/bin/set_audio_hdmi.sh
    echo 'esac' >> /usr/local/bin/set_audio_hdmi.sh
    chmod +x /usr/local/bin/set_audio_hdmi.sh
    
    echo '#!/bin/sh' > /usr/local/bin/move_player.sh
    echo >> /usr/local/bin/move_player.sh
    echo 'case "$PLAYER" in' >> /usr/local/bin/move_player.sh
    echo '  "1")' >> /usr/local/bin/move_player.sh
    echo '    POS_X=0' >> /usr/local/bin/move_player.sh
    echo '    POS_Y=0' >> /usr/local/bin/move_player.sh
    echo '    SIZE_X=1920' >> /usr/local/bin/move_player.sh
    echo '    SIZE_Y=1080' >> /usr/local/bin/move_player.sh
    echo '    ;;' >> /usr/local/bin/move_player.sh
    echo '  "2")' >> /usr/local/bin/move_player.sh
    echo '    POS_X=1920' >> /usr/local/bin/move_player.sh
    echo '    POS_Y=0' >> /usr/local/bin/move_player.sh
    echo '    SIZE_X=1920' >> /usr/local/bin/move_player.sh
    echo '    SIZE_Y=1080' >> /usr/local/bin/move_player.sh
    echo '    ;;' >> /usr/local/bin/move_player.sh
    echo '  *)' >> /usr/local/bin/move_player.sh
    echo '    echo "WARNING: Unknown display; not moving playback window."' >> /usr/local/bin/move_player.sh
    echo '    exit 0' >> /usr/local/bin/move_player.sh
    echo '    ;;' >> /usr/local/bin/move_player.sh
    echo 'esac' >> /usr/local/bin/move_player.sh
    echo >> /usr/local/bin/move_player.sh
    echo 'WINDOW_ID=' >> /usr/local/bin/move_player.sh
    echo 'while [ -z "$WINDOW_ID" ]; do' >> /usr/local/bin/move_player.sh
    echo -n '  WINDOW_ID=`xwininfo -name player$PLAYER 2>/dev/null | grep "Window id" | awk ' >> /usr/local/bin/move_player.sh
    echo -n "'" >> /usr/local/bin/move_player.sh
    echo -n '{print $4}' >> /usr/local/bin/move_player.sh
    echo -n "'" >> /usr/local/bin/move_player.sh
    echo '`' >> /usr/local/bin/move_player.sh
    echo 'done' >> /usr/local/bin/move_player.sh
    echo >> /usr/local/bin/move_player.sh
    echo 'xdotool set_window --overrideredirect 1 $WINDOW_ID windowunmap $WINDOW_ID windowmap $WINDOW_ID' >> /usr/local/bin/move_player.sh
    echo >> /usr/local/bin/move_player.sh
    echo "# try this three times to ensure window doesn't move again:" >> /usr/local/bin/move_player.sh
    echo 'for i in $(seq 1 3); do' >> /usr/local/bin/move_player.sh
    echo '  CUR_POS=' >> /usr/local/bin/move_player.sh
    echo '  CUR_SIZE=' >> /usr/local/bin/move_player.sh
    echo '  while [ "${POS_X},${POS_Y}" != "$CUR_POS" -o "${SIZE_X}x${SIZE_Y}" != "$CUR_SIZE" ]; do' >> /usr/local/bin/move_player.sh
    echo '    xdotool windowmove $WINDOW_ID $POS_X $POS_Y windowsize $WINDOW_ID $SIZE_X $SIZE_Y' >> /usr/local/bin/move_player.sh
    echo '    sleep 1' >> /usr/local/bin/move_player.sh
    echo -n '    CUR_POS=`xdotool getwindowgeometry $WINDOW_ID | grep Position | awk ' >> /usr/local/bin/move_player.sh
    echo -n "'" >> /usr/local/bin/move_player.sh
    echo -n '{print $2}' >> /usr/local/bin/move_player.sh
    echo -n "'" >> /usr/local/bin/move_player.sh
    echo '`' >> /usr/local/bin/move_player.sh
    echo -n '    CUR_SIZE=`xdotool getwindowgeometry $WINDOW_ID | grep Geometry | awk ' >> /usr/local/bin/move_player.sh
    echo -n "'" >> /usr/local/bin/move_player.sh
    echo -n '{print $2}' >> /usr/local/bin/move_player.sh
    echo -n "'" >> /usr/local/bin/move_player.sh
    echo '`' >> /usr/local/bin/move_player.sh
    echo '  done' >> /usr/local/bin/move_player.sh
    echo '  sleep 2' >> /usr/local/bin/move_player.sh
    echo 'done' >> /usr/local/bin/move_player.sh
    chmod +x /usr/local/bin/move_player.sh
    
    echo '#!/bin/sh' > /home/player/player1.sh
    echo 'exec satellite_stream.sh 101' >> /home/player/player1.sh
    chown www-data:root /home/player/player1.sh
    chmod +x /home/player/player1.sh
    
    echo '#!/bin/sh' > /home/player/player2.sh
    echo 'exec satellite_stream.sh 103' >> /home/player/player2.sh
    chown www-data:root /home/player/player2.sh
    chmod +x /home/player/player2.sh
    
    echo '[Unit]' > /etc/systemd/system/player1.service
    echo 'Description=Player 1' >> /etc/systemd/system/player1.service
    echo 'After=startx@player.service' >> /etc/systemd/system/player1.service
    echo 'Requires=startx@player.service' >> /etc/systemd/system/player1.service
    echo >> /etc/systemd/system/player1.service
    echo '[Service]' >> /etc/systemd/system/player1.service
    echo 'ExecStart=-/home/player/player1.sh' >> /etc/systemd/system/player1.service
    echo 'User=player' >> /etc/systemd/system/player1.service
    echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/player1.service
    echo 'Environment=PLAYER=1' >> /etc/systemd/system/player1.service
    echo 'Restart=always' >> /etc/systemd/system/player1.service
    echo 'RestartSec=1' >> /etc/systemd/system/player1.service
    echo >> /etc/systemd/system/player1.service
    echo '[Install]' >> /etc/systemd/system/player1.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/player1.service
    systemctl enable player1.service
    
    echo '[Unit]' > /etc/systemd/system/player2.service
    echo 'Description=Player 2' >> /etc/systemd/system/player2.service
    echo 'After=startx@player.service' >> /etc/systemd/system/player2.service
    echo 'Requires=startx@player.service' >> /etc/systemd/system/player2.service
    echo >> /etc/systemd/system/player2.service
    echo '[Service]' >> /etc/systemd/system/player2.service
    echo 'ExecStart=-/home/player/player2.sh' >> /etc/systemd/system/player2.service
    echo 'User=player' >> /etc/systemd/system/player2.service
    echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/player2.service
    echo 'Environment=PLAYER=2' >> /etc/systemd/system/player2.service
    echo 'Restart=always' >> /etc/systemd/system/player2.service
    echo 'RestartSec=1' >> /etc/systemd/system/player2.service
    echo >> /etc/systemd/system/player2.service
    echo '[Install]' >> /etc/systemd/system/player2.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/player2.service
    systemctl enable player2.service
    
    echo '[Unit]' > /etc/systemd/system/xterm.service
    echo 'Description=xterm for troubleshooting' >> /etc/systemd/system/xterm.service
    echo 'After=startx@player.service' >> /etc/systemd/system/xterm.service
    echo 'Requires=startx@player.service' >> /etc/systemd/system/xterm.service
    echo >> /etc/systemd/system/xterm.service
    echo '[Service]' >> /etc/systemd/system/xterm.service
    echo 'ExecStart=-/usr/bin/xterm' >> /etc/systemd/system/xterm.service
    echo 'User=player' >> /etc/systemd/system/xterm.service
    echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/xterm.service
  • sed -i -e 's/^GRUB_CMDLINE_LINUX_DEFAULT="quiet panic=5"$/GRUB_CMDLINE_LINUX_DEFAULT="quiet panic=5 drm_kms_helper.edid_firmware=DVI-I-1:edid\/1920x1080.bin"/g' /etc/default/grub && update-grub
  • run alsamixer and unmute 1st and 3rd S/PDIF outputs on nVidia card
  • mkdir ~player/.vnc
    x11vnc -storepasswd **PASSWORD** ~player/.vnc/passwd
    chown -R player:player ~player/.vnc
    chmod 0600 ~player/.vnc/passwd
  • Paste into /etc/X11/xorg.conf:
    Section "ServerLayout"
      Identifier     "satellite"
      Screen      0  "satellite-screen" 0 0
      InputDevice    "Void" "CorePointer"
      InputDevice    "Void" "CoreKeyboard"
      Option         "AutoAddDevices" "Off"
    EndSection
    
    Section "InputDevice"
      Identifier  "Void"
      Driver      "void"
    EndSection
    
    Section "Monitor"
      Identifier   "DVI-I-1"
      Option "LeftOf" "HDMI-1"
      ModeLine "1080p" 148.35 1920 2008 2052 2200 1080 1084 1089 1125 +HSync +VSync
      Option "PreferredMode" "1080p"
    EndSection
    
    Section "Monitor"
      Identifier   "DVI-I-2"
      Option "LeftOf" "HDMI-1"
      ModeLine "1080p" 148.35 1920 2008 2052 2200 1080 1084 1089 1125 +HSync +VSync
      Option "PreferredMode" "1080p"
    EndSection
    
    Section "Monitor"
      Identifier "HDMI-1"
      ModeLine "1080p" 148.35 1920 2008 2052 2200 1080 1084 1089 1125 +HSync +VSync
      Option "PreferredMode" "1080p"
    EndSection
    
    Section "Device"
      Identifier  "nVidia"
      Driver      "nouveau"
      BusID       "PCI:1:0:0"
      Option      "Monitor-DVI-I-1" "DVI-I-1"
      Option      "Monitor-DVI-I-2" "DVI-I-2"
      Option      "Monitor-HDMI-1" "HDMI-1"
    EndSection
    
    Section "Screen"
      Identifier "satellite-screen"
      Device     "nVidia"
      #Monitor specified in Device section
      DefaultDepth 24
      SubSection "Display"
        Modes "1920x1080"
        Virtual 3840 1080
        Depth 24
      EndSubSection
    EndSection
  • systemctl start startx@player && systemctl start player1 && systemctl start player2
  • aptitude --without-recommends install mini-httpd
    sed -i -e 's/^START=0$/START=1/g' /etc/default/mini-httpd
    sed -i -e 's/^host=localhost$/#host=localhost/g; s/^user=nobody$/user=www-data/g' /etc/mini-httpd.conf
    
    echo '[Unit]' > /etc/systemd/system/mini-httpd.service
    echo 'Description=mini_httpd - small HTTP server' >> /etc/systemd/system/mini-httpd.service
    echo 'After=network.target' >> /etc/systemd/system/mini-httpd.service
    echo >> /etc/systemd/system/mini-httpd.service
    echo '[Service]' >> /etc/systemd/system/mini-httpd.service
    echo 'ExecStart=/usr/sbin/mini_httpd -C /etc/mini-httpd.conf' >> /etc/systemd/system/mini-httpd.service
    echo 'Type=forking' >> /etc/systemd/system/mini-httpd.service
    echo 'Restart=always' >> /etc/systemd/system/mini-httpd.service
    echo 'RestartSec=1' >> /etc/systemd/system/mini-httpd.service
    echo >> /etc/systemd/system/mini-httpd.service
    echo '[Install]' >> /etc/systemd/system/mini-httpd.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/mini-httpd.service
    
    systemctl restart mini-httpd.service
  • aptitude install sudo
    echo >> /etc/sudoers
    echo 'www-data ALL=(ALL:ALL) NOPASSWD:/bin/systemctl' >> /etc/sudoers
    
    adduser www-data video # for dvbsnoop
    
    aptitude --without-recommends install vncsnapshot libjpeg-turbo-progs
    
    mkdir /var/www/html/cgi-bin
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/screenshot.sh
    echo >> /var/www/html/cgi-bin/screenshot.sh
    echo 'case "$1" in' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  "1thumb")' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    DISPLAY=:1' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    SCALE='1/4'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  "2thumb")' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    DISPLAY=:2' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    SCALE='1/4'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  "boththumb")' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    DISPLAY=:0' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    SCALE='1/4'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  "1")' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    DISPLAY=:1' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    SCALE='1'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  "2")' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    DISPLAY=:2' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    SCALE='1'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  "both")' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    DISPLAY=:0' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    SCALE='1'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  *)' >> /var/www/html/cgi-bin/screenshot.sh
    echo "    echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/screenshot.sh
    echo '    echo' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    exit 1' >> /var/www/html/cgi-bin/screenshot.sh
    echo '    ;;' >> /var/www/html/cgi-bin/screenshot.sh
    echo 'esac' >> /var/www/html/cgi-bin/screenshot.sh
    echo >> /var/www/html/cgi-bin/screenshot.sh
    echo "echo 'Content-Type: image/jpeg'" >> /var/www/html/cgi-bin/screenshot.sh
    echo 'echo' >> /var/www/html/cgi-bin/screenshot.sh
    echo 'if [ $SCALE = "1" ] ; then' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  vncsnapshot -quiet -passwd /var/www/vnc-passwd localhost$DISPLAY - 2>/dev/null' >> /var/www/html/cgi-bin/screenshot.sh
    echo 'else' >> /var/www/html/cgi-bin/screenshot.sh
    echo '  vncsnapshot -quiet -passwd /var/www/vnc-passwd localhost$DISPLAY - 2>/dev/null | djpeg -scale $SCALE | cjpeg' >> /var/www/html/cgi-bin/screenshot.sh
    echo 'fi' >> /var/www/html/cgi-bin/screenshot.sh
    chmod +x /var/www/html/cgi-bin/screenshot.sh
    
    x11vnc -storepasswd **PASSWORD** /var/www/vnc-passwd
    chown root:www-data /var/www/vnc-passwd
    chmod 0640 /var/www/vnc-passwd
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/restart.sh
    echo >> /var/www/html/cgi-bin/restart.sh
    echo 'case "$1" in' >> /var/www/html/cgi-bin/restart.sh
    echo '  "all")' >> /var/www/html/cgi-bin/restart.sh
    echo '    sudo systemctl restart player1 player2 ;;' >> /var/www/html/cgi-bin/restart.sh
    echo '  "1")' >> /var/www/html/cgi-bin/restart.sh
    echo '    sudo systemctl restart player1 ;;' >> /var/www/html/cgi-bin/restart.sh
    echo '  "2")' >> /var/www/html/cgi-bin/restart.sh
    echo '    sudo systemctl restart player2 ;;' >> /var/www/html/cgi-bin/restart.sh
    echo '  "tvheadend")' >> /var/www/html/cgi-bin/restart.sh
    echo '    sudo systemctl restart tvheadend ;;' >> /var/www/html/cgi-bin/restart.sh
    echo '  *)' >> /var/www/html/cgi-bin/restart.sh
    echo "    echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/restart.sh
    echo '    echo' >> /var/www/html/cgi-bin/restart.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/restart.sh
    echo '    exit 1' >> /var/www/html/cgi-bin/restart.sh
    echo '    ;;' >> /var/www/html/cgi-bin/restart.sh
    echo 'esac' >> /var/www/html/cgi-bin/restart.sh
    echo >> /var/www/html/cgi-bin/restart.sh
    echo 'if [ "$GATEWAY_INTERFACE" = "CGI/1.1" ] ; then' >> /var/www/html/cgi-bin/restart.sh
    echo "  echo 'Location: about:blank'" >> /var/www/html/cgi-bin/restart.sh
    echo 'fi' >> /var/www/html/cgi-bin/restart.sh
    chmod +x /var/www/html/cgi-bin/restart.sh
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/uptime.sh
    echo "echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/uptime.sh
    echo 'echo' >> /var/www/html/cgi-bin/uptime.sh
    echo >> /var/www/html/cgi-bin/uptime.sh
    echo 'dvbsnoop -s signal -n 1 | tail -n 1' >> /var/www/html/cgi-bin/uptime.sh
    echo 'echo' >> /var/www/html/cgi-bin/uptime.sh
    echo 'uptime' >> /var/www/html/cgi-bin/uptime.sh
    echo 'echo' >> /var/www/html/cgi-bin/uptime.sh
    echo 'vmstat' >> /var/www/html/cgi-bin/uptime.sh
    echo 'echo' >> /var/www/html/cgi-bin/uptime.sh
    echo 'ps auxO-C | head -n 11' >> /var/www/html/cgi-bin/uptime.sh
    chmod +x /var/www/html/cgi-bin/uptime.sh
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/set_channel.sh
    echo >> /var/www/html/cgi-bin/set_channel.sh
    echo 'if [ "$GATEWAY_INTERFACE" = "CGI/1.1" ] ; then' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  IFS="&"' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  set -- $QUERY_STRING' >> /var/www/html/cgi-bin/set_channel.sh
    echo 'fi' >> /var/www/html/cgi-bin/set_channel.sh
    echo >> /var/www/html/cgi-bin/set_channel.sh
    echo 'case "$1" in' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  "1")' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    FILE=/home/player/player1.sh' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    SERVICE=player1' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  "2")' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    FILE=/home/player/player2.sh' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    SERVICE=player2' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  *)' >> /var/www/html/cgi-bin/set_channel.sh
    echo "    echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/set_channel.sh
    echo '    echo' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    exit 1' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo 'esac' >> /var/www/html/cgi-bin/set_channel.sh
    echo >> /var/www/html/cgi-bin/set_channel.sh
    echo 'case "$2" in' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  "satellite")' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    PROG=satellite_stream.sh' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    case $3 in' >> /var/www/html/cgi-bin/set_channel.sh
    echo '      10[1-4])' >> /var/www/html/cgi-bin/set_channel.sh
    echo '        CHAN=$3 ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo '      *)' >> /var/www/html/cgi-bin/set_channel.sh
    echo "        echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/set_channel.sh
    echo '        echo' >> /var/www/html/cgi-bin/set_channel.sh
    echo '        echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/set_channel.sh
    echo '        exit 1' >> /var/www/html/cgi-bin/set_channel.sh
    echo '        ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    esac' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  "web")' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    PROG=web_stream.sh' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    CHAN=$3' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo '  *)' >> /var/www/html/cgi-bin/set_channel.sh
    echo "    echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/set_channel.sh
    echo '    echo' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    exit 1' >> /var/www/html/cgi-bin/set_channel.sh
    echo '    ;;' >> /var/www/html/cgi-bin/set_channel.sh
    echo 'esac' >> /var/www/html/cgi-bin/set_channel.sh
    echo >> /var/www/html/cgi-bin/set_channel.sh
    echo -n "echo '" >> /var/www/html/cgi-bin/set_channel.sh
    echo -n '#!/bin/sh' >> /var/www/html/cgi-bin/set_channel.sh
    echo "' > \$FILE" >> /var/www/html/cgi-bin/set_channel.sh
    echo 'echo "exec $PROG $CHAN" >> $FILE' >> /var/www/html/cgi-bin/set_channel.sh
    echo 'sudo /bin/systemctl restart $SERVICE' >> /var/www/html/cgi-bin/set_channel.sh
    echo >> /var/www/html/cgi-bin/set_channel.sh
    echo 'if [ "$GATEWAY_INTERFACE" = "CGI/1.1" ] ; then' >> /var/www/html/cgi-bin/set_channel.sh
    echo "  echo 'Location: about:blank'" >> /var/www/html/cgi-bin/set_channel.sh
    echo 'fi' >> /var/www/html/cgi-bin/set_channel.sh
    chmod +x /var/www/html/cgi-bin/set_channel.sh
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/playing-css.sh
    echo >> /var/www/html/cgi-bin/playing-css.sh
    echo 'case "$1" in' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  "1") OUTPUT=1 ;;' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  "2") OUTPUT=2 ;;' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  *)' >> /var/www/html/cgi-bin/playing-css.sh
    echo "    echo 'Content-type: text/plain'" >> /var/www/html/cgi-bin/playing-css.sh
    echo '    echo' >> /var/www/html/cgi-bin/playing-css.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/playing-css.sh
    echo '    exit 1' >> /var/www/html/cgi-bin/playing-css.sh
    echo '    ;;' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'esac' >> /var/www/html/cgi-bin/playing-css.sh
    echo >> /var/www/html/cgi-bin/playing-css.sh
    echo "echo 'Content-type: text/css'" >> /var/www/html/cgi-bin/playing-css.sh
    echo 'echo' >> /var/www/html/cgi-bin/playing-css.sh
    echo >> /var/www/html/cgi-bin/playing-css.sh
    echo 'LINE=`grep satellite_stream.sh /home/player/player$OUTPUT.sh`' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'if [ $? -eq 0 ]; then' >> /var/www/html/cgi-bin/playing-css.sh
    echo -n '  CHANNEL=satellite-`echo $LINE | awk ' >> /var/www/html/cgi-bin/playing-css.sh
    echo -n "'" >> /var/www/html/cgi-bin/playing-css.sh
    echo -n '{print $3}' >> /var/www/html/cgi-bin/playing-css.sh
    echo -n "'" >> /var/www/html/cgi-bin/playing-css.sh
    echo '`' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'else' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  LINE=`grep web_stream.sh /home/player/player$OUTPUT.sh`' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  if [ $? -eq 0 ]; then' >> /var/www/html/cgi-bin/playing-css.sh
    echo -n '    CHANNEL=web-`echo $LINE | awk ' >> /var/www/html/cgi-bin/playing-css.sh
    echo -n "'" >> /var/www/html/cgi-bin/playing-css.sh
    echo -n '{print $3}' >> /var/www/html/cgi-bin/playing-css.sh
    echo -n "'" >> /var/www/html/cgi-bin/playing-css.sh
    echo '`' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  else' >> /var/www/html/cgi-bin/playing-css.sh
    echo '    echo "/* unidentified source for output $OUTPUT */"' >> /var/www/html/cgi-bin/playing-css.sh
    echo '    exit 0' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  fi' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'fi' >> /var/www/html/cgi-bin/playing-css.sh
    echo >> /var/www/html/cgi-bin/playing-css.sh
    echo 'systemctl is-active player$OUTPUT > /dev/null' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'if [ $? -eq 0 ]; then' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  COLOR="#0f0"' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'else' >> /var/www/html/cgi-bin/playing-css.sh
    echo '  COLOR="#ff0"' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'fi' >> /var/www/html/cgi-bin/playing-css.sh
    echo >> /var/www/html/cgi-bin/playing-css.sh
    echo 'echo "ul.output$OUTPUT li.$CHANNEL a {"' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'echo "  border: 2px dotted $COLOR;"' >> /var/www/html/cgi-bin/playing-css.sh
    echo 'echo "}"' >> /var/www/html/cgi-bin/playing-css.sh
    chmod +x /var/www/html/cgi-bin/playing-css.sh
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/status.sh
    echo "echo 'Content-type: text/plain; charset=UTF-8'" >> /var/www/html/cgi-bin/status.sh
    echo 'echo' >> /var/www/html/cgi-bin/status.sh
    echo >> /var/www/html/cgi-bin/status.sh
    echo 'case "$1" in' >> /var/www/html/cgi-bin/status.sh
    echo '  "player1") sudo systemctl -l -n 1000 status player1 ;;' >> /var/www/html/cgi-bin/status.sh
    echo '  "player2") sudo systemctl -l -n 1000 status player2 ;;' >> /var/www/html/cgi-bin/status.sh
    echo '  "tvheadend") sudo systemctl -l -n 1000 status tvheadend ;;' >> /var/www/html/cgi-bin/status.sh
    echo '  "dmesg") dmesg | tail -n 1000 ;;' >> /var/www/html/cgi-bin/status.sh
    echo '  *)' >> /var/www/html/cgi-bin/status.sh
    echo '    echo "ERROR: Invalid parameter!"' >> /var/www/html/cgi-bin/status.sh
    echo '    exit 1' >> /var/www/html/cgi-bin/status.sh
    echo '    ;;' >> /var/www/html/cgi-bin/status.sh
    echo 'esac' >> /var/www/html/cgi-bin/status.sh
    chmod +x /var/www/html/cgi-bin/status.sh
    
    echo '<html>' > /var/www/html/index.html
    echo '<head>' >> /var/www/html/index.html
    echo '<title>Satellite Receiver Control</title>' >> /var/www/html/index.html
    echo '<style type="text/css">' >> /var/www/html/index.html
    echo 'body {' >> /var/www/html/index.html
    echo '  background: #000;' >> /var/www/html/index.html
    echo '  color: #ff0;' >> /var/www/html/index.html
    echo '}' >> /var/www/html/index.html
    echo 'a {' >> /var/www/html/index.html
    echo '  color: #0f9;' >> /var/www/html/index.html
    echo '}' >> /var/www/html/index.html
    echo 'table tr td {' >> /var/www/html/index.html
    echo '  text-align: center;' >> /var/www/html/index.html
    echo '  border: 1px solid #fff;' >> /var/www/html/index.html
    echo '}' >> /var/www/html/index.html
    echo 'table tr td li {' >> /var/www/html/index.html
    echo '  text-align: left;' >> /var/www/html/index.html
    echo '}' >> /var/www/html/index.html
    echo '</style>' >> /var/www/html/index.html
    echo '<link rel="stylesheet" type="text/css" href="cgi-bin/playing-css.sh?1" />' >> /var/www/html/index.html
    echo '<link rel="stylesheet" type="text/css" href="cgi-bin/playing-css.sh?2" />' >> /var/www/html/index.html
    echo '</head>' >> /var/www/html/index.html
    echo '<body>' >> /var/www/html/index.html
    echo '<h1>Satellite Receiver Control</h1>' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '<table><tr>' >> /var/www/html/index.html
    echo '  <td>Output 1:<ul class="output1">' >> /var/www/html/index.html
    echo '<li class="satellite-101"><a href="cgi-bin/set_channel.sh?1&amp;satellite&amp;101" target="action">NTV-1&nbsp;(Public)</a></li>' >> /var/www/html/index.html
    echo '<li class="satellite-102"><a href="cgi-bin/set_channel.sh?1&amp;satellite&amp;102" target="action">NTV-2&nbsp;(Education)</a></li>' >> /var/www/html/index.html
    echo '<li class="satellite-103"><a href="cgi-bin/set_channel.sh?1&amp;satellite&amp;103" target="action">NTV-3&nbsp;(Media)</a></li>' >> /var/www/html/index.html
    echo '<li class="satellite-104"><a href="cgi-bin/set_channel.sh?1&amp;satellite&amp;104" target="action">NASA UHD</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-iss"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;ustream-iss" target="action">ISS via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-public"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;ustream-public" target="action">Public via. Ustream</a></li>' >> /var/www/html/index.html
    #echo '<li class="web-ustream-edu"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;ustream-edu" target="action">Education via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-media"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;ustream-media" target="action">Media via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-youtube-public"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;youtube-public" target="action">Public via. YouTube</a></li>' >> /var/www/html/index.html
    #echo '<li class="web-youtube-edu"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;youtube-edu" target="action">Education via. YouTube</a></li>' >> /var/www/html/index.html
    echo '<li class="web-youtube-media"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;youtube-media" target="action">Media via. YouTube</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-csbf"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;ustream-csbf" target="action">Columbia Scientific Balloon Facility via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-ssc"><a href="cgi-bin/set_channel.sh?1&amp;web&amp;ustream-ssc" target="action">Stennis Space Center via. Ustream</a></li>' >> /var/www/html/index.html
    echo '</ul></td>' >> /var/www/html/index.html
    echo '  <td>Output 2:<ul class="output2">' >> /var/www/html/index.html
    echo '<li class="satellite-101"><a href="cgi-bin/set_channel.sh?2&amp;satellite&amp;101" target="action">NTV-1&nbsp;(Public)</a></li>' >> /var/www/html/index.html
    echo '<li class="satellite-102"><a href="cgi-bin/set_channel.sh?2&amp;satellite&amp;102" target="action">NTV-2&nbsp;(Education)</a></li>' >> /var/www/html/index.html
    echo '<li class="satellite-103"><a href="cgi-bin/set_channel.sh?2&amp;satellite&amp;103" target="action">NTV-3&nbsp;(Media)</a></li>' >> /var/www/html/index.html
    echo '<li class="satellite-104"><a href="cgi-bin/set_channel.sh?2&amp;satellite&amp;104" target="action">NASA UHD</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-iss"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;ustream-iss" target="action">ISS via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-public"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;ustream-public" target="action">Public via. Ustream</a></li>' >> /var/www/html/index.html
    #echo '<li class="web-ustream-edu"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;ustream-edu" target="action">Education via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-media"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;ustream-media" target="action">Media via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-youtube-public"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;youtube-public" target="action">Public via. YouTube</a></li>' >> /var/www/html/index.html
    #echo '<li class="web-youtube-edu"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;youtube-edu" target="action">Education via. YouTube</a></li>' >> /var/www/html/index.html
    echo '<li class="web-youtube-media"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;youtube-media" target="action">Media via. YouTube</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-csbf"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;ustream-csbf" target="action">Columbia Scientific Balloon Facility via. Ustream</a></li>' >> /var/www/html/index.html
    echo '<li class="web-ustream-ssc"><a href="cgi-bin/set_channel.sh?2&amp;web&amp;ustream-ssc" target="action">Stennis Space Center via. Ustream</a></li>' >> /var/www/html/index.html
    echo '</ul></td>' >> /var/www/html/index.html
    echo '</tr><tr>' >> /var/www/html/index.html
    echo '<td><a href="cgi-bin/screenshot.sh?1"><img src="cgi-bin/screenshot.sh?1thumb" alt="Output 1 Screenshot" /></a></td>' >> /var/www/html/index.html
    echo '<td><a href="cgi-bin/screenshot.sh?2"><img src="cgi-bin/screenshot.sh?2thumb" alt="Output 2 Screenshot" /></a></td>' >> /var/www/html/index.html
    echo '</tr><tr>' >> /var/www/html/index.html
    echo '  <td><a href="cgi-bin/restart.sh?1" target="action">Restart Output 1</a></td>' >> /var/www/html/index.html
    echo '  <td><a href="cgi-bin/restart.sh?2" target="action">Restart Output 2</a></td>' >> /var/www/html/index.html
    echo '</tr><tr>' >> /var/www/html/index.html
    echo '  <td colspan="2" style="background: #900;"><a href="cgi-bin/restart.sh?all" target="action">Restart BOTH</a> &middot; <a href="cgi-bin/restart.sh?tvheadend" target="action">Restart Tvheadend</a></td>' >> /var/www/html/index.html
    echo '</tr></table>' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '<iframe src="about:blank" name="action" width="0" height="0" style="display: none;"></iframe>' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '<hr />' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '<h3><a href="/extjs.html" onclick="javascript:event.target.port=9981">DVR Control</a></h3>' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '<h3><a href="cgi-bin/vlc.sh">Watch in VLC</a></h3>' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '<hr />' >> /var/www/html/index.html
    echo '<iframe src="cgi-bin/uptime.sh" style="height: 25em; width: 100%; background: #0f0;" scrolling="no"></iframe>' >> /var/www/html/index.html
    echo 'Status reports: <a href="cgi-bin/status.sh?player1">Player 1</a> &middot; <a href="cgi-bin/status.sh?player2">Player 2</a> &middot; <a href="cgi-bin/status.sh?tvheadend">Tvheadend</a> &middot; <a href="cgi-bin/status.sh?dmesg">Kernel</a>' >> /var/www/html/index.html
    echo >> /var/www/html/index.html
    echo '</body>' >> /var/www/html/index.html
    echo '</html>' >> /var/www/html/index.html
    
    echo '#!/bin/sh' > /var/www/html/cgi-bin/vlc.sh
    echo "echo 'Content-Type: application/videolan'" >> /var/www/html/cgi-bin/vlc.sh
    echo -n "echo 'Content-Disposition: attachment; filename=" >> /var/www/html/cgi-bin/vlc.sh
    echo -n '"satellite.vlc"' >> /var/www/html/cgi-bin/vlc.sh
    echo "'" >> /var/www/html/cgi-bin/vlc.sh
    echo 'echo' >> /var/www/html/cgi-bin/vlc.sh
    echo "echo 'http://satellite.mcp.lcl:9981/playlist/channels'" >> /var/www/html/cgi-bin/vlc.sh
    chmod +x /var/www/html/cgi-bin/vlc.sh

See also: https://tvheadend.org/projects/tvheadend/wiki/AptRepository#Debian-Apt-Repository (tvheadend apt repo)

http://www.linuxtv.org/wiki/index.php/Hauppauge_WinTV-HVR-4000 (old pci satellite card firmware)

(new pcie satellite card with loopthrough does not need firmware)

https://www.linuxtv.org/wiki/index.php/TeVii_S470 (new pcie satellite card without loopthrough firmware)

HTSP in VLC (unmaintained?):

wget https://ci.btbn.de/job/vlc-htsp-plugin/PLATFORM=linux_x64,label=linux/lastSuccessfulBuild/artifact/libhtsp_plugin.so
chown root:root libhtsp_plugin.so && chmod 644 libhtsp_plugin.so && mv libhtsp_plugin.so /usr/lib/vlc/plugins/

See also: https://ci.btbn.de/job/vlc-htsp-plugin/ and https://github.com/BtbN/vlc-htsp-plugin/

Buggy cx88 device hack: http://linux-dvb.linuxtv.narkive.com/PQv9fYss/pci-abort-messages-from-cx88-driver

computer/nasa_tv_satellite_receiver.txt · Last modified: 2016/09/10 21:07 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS