Files
shell_sequencer/seqs/kodi.sh
2019-05-14 13:42:40 +02:00

132 lines
3.1 KiB
Bash

#!/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 "Install $toolName via apt"; }
step_1_alias() { ALIAS="install"; }
step_1() {
exe 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..."
exe raspi-config
saveReturn $?
endReturn
}
step_3_info() { echo "Add $toolName user ($toolUser)"; }
step_3() {
exe id -u $toolUser >>/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo
echo "User $toolUser exists."
echo "Skipping user creation."
return 0
fi
exe adduser \
--disable-password \
--gecos "User to run $toolName Media Center" \
-G audio,video,plugdev,input,tty \
$toolUser
saveReturn $?
endReturn
echo "User $toolUser details:"
exe id $tooLuser
}
step_4_info() { echo "Create systemd service"; }
step_4() {
addConf "$toolServiceContent" "$toolServiceFile"
if [ $? -eq 0 ] ; then
exe systemctl daemon reload
exe systemctl enable kodi.service
saveReturn $?
endReturn
else
echo "[ERROR] failed to setup systemd service"
fi
}
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 "Enable 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\""
addConf "$inputRule" "$udevFile"
}
step_6_info() { echo "Increase raspberry pi GPU memory to 320"; }
step_6() {
exe grep -e '^[ ]*gpu_mem' "$bootConfigLoc" >>/dev/null 2>&1
if [ -f "$bootConfigLoc" ] && [ $? -ne 0 ] ; then
# attach settings to raspberry boot configuration
exe mount -o remount,rw /boot
echo -n "Modifying boot configuration ... "
echo "$bootConfig" >> "$bootConfigLoc" && echo "ok"
exe mount -o remount,ro /boot
else
echo "[ERROR] modifying boot configuration. Kodi may not work properly"
fi
}
bootConfigLoc="/boot/config.txt"
bootConfig="
# Modifications for $toolName
start_x=1
gpu_mem=320"
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 "Start $toolName manually:"
echo "service kodi start"
;;
esac
}
VERSION_SEQREV=2
. sequencer.sh