From 42aa8def703b3d22a5b731b291e4ae00321d8c79 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Mon, 8 Apr 2019 14:45:15 +0100 Subject: [PATCH] New seqs --- seqs/kodi.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++++ seqs/tvheadend.sh | 59 ++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 seqs/kodi.sh create mode 100644 seqs/tvheadend.sh diff --git a/seqs/kodi.sh b/seqs/kodi.sh new file mode 100644 index 0000000..515b68a --- /dev/null +++ b/seqs/kodi.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +## Installing kodi on a raspberry pi +## Some measures are taken to prevent corrupting existing files +## but it's intendet use is for a blank rasperry pi. + +toolName="Kodi" +toolUser="kodi" +toolServiceFile="/etc/systemd/system/kodi.service" + +step_1_info() { echo "Installing $toolName via apt"; } +step_1_alias() { ALIAS="install"; } +step_1() { + apt update && apt install kodi +} + +step_2_info() { echo "Set localisation and keyboard layout"; } +step_2() { + echo "Goto \"Localisation Options\" in the following menu." + read -p "Press ENTER to continue..." + raspi-config + saveReturn $? + endReturn +} + +step_3_info() { echo "Adding $toolName user ($toolUser)"; } +step_3() { + id -u $toolUser >>/dev/null 2>&1 + if [ $? -eq 0 ] ; then + echo + echo "User $toolUser exists." + echo "Skipping user creation." + return 0 + fi + adduser \ + --disable-password \ + --gecos "User to run $toolName Media Center" \ + -G audio,video,plugdev,input,tty \ + $toolUser + saveReturn $? + endReturn + echo "User $toolUser details:" + id $tooLuser +} + + +step_4_info() { echo "Create systemd service"; } +step_4() { + if [ -f "$toolServiceFile" ] ; then + mv "$toolServiceFile" "$toolServiceFile".bck + echo -e "\n[WARN] existing service file renamed to $toolServiceFile.bck" + fi + echo "$toolServiceContent" > "$toolServiceFile" + + systemctl daemon reload + systemctl enable kodi.service + saveReturn $? + endReturn +} + +toolServiceContent="\ +[Unit] +Description = Kodi Media Center + +# if you don't need the MySQL DB backend, this should be sufficient +After = systemd-user-sessions.service network.target sound.target + +# if you need the MySQL DB backend, use this block instead of the previous +# After = systemd-user-sessions.service network.target sound.target mysql.service +# Wants = mysql.service + +[Service] +User = kodi +Group = kodi +Type = simple +ExecStart = /usr/bin/kodi-standalone +Restart = always +RestartSec = 15 + +[Install] +WantedBy = multi-user.target" + +step_5_info() { echo "Enabling text input for USB keyboards within $toolName"; } +step_5() { + local udevFile="/etc/udev/rules.d/99-kodi.rules" + local inputRule="KERNEL==\"tty[0-9]*\", GROUP=\"tty\", MODE=\"0660\"" + if [ -f "$udevFile" ] ; then + echo "udev rule ($udevFile) already exists." + else + echo "inputRule" >> udevFile + fi +} + +step_6_info() { "Increase raspberry pi GPU memory to 320"; } +step_6() { + local rpiBootConfig="/boot/config.txt" + echo " + # Modifications for $toolName + start_x=1 + gpu_mem=320" >> $rpiBootConfig +} + +step_7_info() { echo "Reboot is needed for all changes to take effect"; } +step_7() { + if [ $QUIET -eq "1" ] ; then + answer=n + else + read -p "Reboot now? y/n(default)" answer + fi + case $answer in + y|Y) + reboot + ;; + *) + echo + echo "To start $toolName anyway enter:" + echo "service start kodi" + ;; + esac +} + +VERSION_SEQREV=2 +. sequencer.sh diff --git a/seqs/tvheadend.sh b/seqs/tvheadend.sh new file mode 100644 index 0000000..82c7ca5 --- /dev/null +++ b/seqs/tvheadend.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +toolName="Tvheadend" + +step_1_info() { echo "Apt - setup $toolName repository"; } +step_1_alias() { ALIAS="install"; } +step_1() { + local sourceList="/etc/apt/sources.list.d/tvheadend.list" + local sourceEntry="deb https://apt.tvheadend.org/stable raspbian-stretch main" + + apt update + saveReturn $? + apt install coreutils wget apt-transport-https ca-certificates + saveReturn $? + endReturn + + wget -q0- https://doozer.io/keys/tvheadend/tvheadend/pgp | apt-key add - + saveReturn $? + endReturn + + if [ -f "$sourceList" ] ; then + echo "[WARN] Renaming existing source list to: ${sourceList}.bck" + mv "$sourceList" "$sourceList".bck + fi + + echo "$sourceEntry" > "$sourceList" +} + +step_2_info() { echo "Install/Upate $toolName"; } +step_2() { + apt update + saveReturn $? + apt install tvheadend + saveReturn $? + endReturn + + echo "More information on $toolName:" + echo "https://tvheadend.org/projects/tvheadend/wiki" +} + +step_99_info() { echo "Apt - setup \"old\" Bintray repository"; } +step_99() { + local sourceList="/etc/apt/sources.list.d/tvheadend.list" + local sourceEntry="deb https://dl.bintray.com/mpmc/deb raspbianstretch release-4.2" + + apt update && apt install dirmngr + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 + if [ -f "$sourceList" ] ; then + echo "Skipping creating of $sourceList; Already exists" + return + fi + echo "$sourceEntry" > "$sourceList" + apt update + saveReturn $? + endReturn +} + +VERSION_SEQREV=2 +. sequencer.sh