some fixes and enhancements

preparation for verbose output of commands
This commit is contained in:
2019-04-10 12:32:23 +01:00
parent 3b23840277
commit 4c50382428

View File

@@ -8,31 +8,31 @@ toolName="Kodi"
toolUser="kodi" toolUser="kodi"
toolServiceFile="/etc/systemd/system/kodi.service" toolServiceFile="/etc/systemd/system/kodi.service"
step_1_info() { echo "Installing $toolName via apt"; } step_1_info() { echo "Install $toolName via apt"; }
step_1_alias() { ALIAS="install"; } step_1_alias() { ALIAS="install"; }
step_1() { step_1() {
apt update && apt install kodi exe apt update && apt install kodi
} }
step_2_info() { echo "Set localisation and keyboard layout"; } step_2_info() { echo "Set localisation and keyboard layout"; }
step_2() { step_2() {
echo "Goto \"Localisation Options\" in the following menu." echo "Goto \"Localisation Options\" in the following menu."
read -p "Press ENTER to continue..." read -p "Press ENTER to continue..."
raspi-config exe raspi-config
saveReturn $? saveReturn $?
endReturn endReturn
} }
step_3_info() { echo "Adding $toolName user ($toolUser)"; } step_3_info() { echo "Add $toolName user ($toolUser)"; }
step_3() { step_3() {
id -u $toolUser >>/dev/null 2>&1 exe id -u $toolUser >>/dev/null 2>&1
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
echo echo
echo "User $toolUser exists." echo "User $toolUser exists."
echo "Skipping user creation." echo "Skipping user creation."
return 0 return 0
fi fi
adduser \ exe adduser \
--disable-password \ --disable-password \
--gecos "User to run $toolName Media Center" \ --gecos "User to run $toolName Media Center" \
-G audio,video,plugdev,input,tty \ -G audio,video,plugdev,input,tty \
@@ -40,22 +40,22 @@ step_3() {
saveReturn $? saveReturn $?
endReturn endReturn
echo "User $toolUser details:" echo "User $toolUser details:"
id $tooLuser exe id $tooLuser
} }
step_4_info() { echo "Create systemd service"; } step_4_info() { echo "Create systemd service"; }
step_4() { step_4() {
if [ -f "$toolServiceFile" ] ; then addConf "$toolServiceContent" "$toolServiceFile"
mv "$toolServiceFile" "$toolServiceFile".bck
echo -e "\n[WARN] existing service file renamed to $toolServiceFile.bck"
fi
echo "$toolServiceContent" > "$toolServiceFile"
systemctl daemon reload if [ $? -eq 0 ] ; then
systemctl enable kodi.service exe systemctl daemon reload
saveReturn $? exe systemctl enable kodi.service
endReturn saveReturn $?
endReturn
else
echo "[ERROR] failed to setup systemd service"
fi
} }
toolServiceContent="\ toolServiceContent="\
@@ -80,25 +80,33 @@ RestartSec = 15
[Install] [Install]
WantedBy = multi-user.target" WantedBy = multi-user.target"
step_5_info() { echo "Enabling text input for USB keyboards within $toolName"; } step_5_info() { echo "Enable text input for USB keyboards within $toolName"; }
step_5() { step_5() {
local udevFile="/etc/udev/rules.d/99-kodi.rules" local udevFile="/etc/udev/rules.d/99-kodi.rules"
local inputRule="KERNEL==\"tty[0-9]*\", GROUP=\"tty\", MODE=\"0660\"" local inputRule="KERNEL==\"tty[0-9]*\", GROUP=\"tty\", MODE=\"0660\""
if [ -f "$udevFile" ] ; then
echo "udev rule ($udevFile) already exists." 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 else
echo "inputRule" >> udevFile echo "[ERROR] modifying boot configuration. Kodi may not work properly"
fi fi
} }
step_6_info() { "Increase raspberry pi GPU memory to 320"; } bootConfigLoc="/boot/config.txt"
step_6() { bootConfig="
local rpiBootConfig="/boot/config.txt" # Modifications for $toolName
echo " start_x=1
# Modifications for $toolName gpu_mem=320"
start_x=1
gpu_mem=320" >> $rpiBootConfig
}
step_7_info() { echo "Reboot is needed for all changes to take effect"; } step_7_info() { echo "Reboot is needed for all changes to take effect"; }
step_7() { step_7() {
@@ -113,7 +121,7 @@ step_7() {
;; ;;
*) *)
echo echo
echo "To start $toolName anyway enter:" echo "Start $toolName manually:"
echo "service start kodi" echo "service start kodi"
;; ;;
esac esac