1- #! /bin/bash
2-
1+ #! /usr/bin/env sh
32# DTS playback restoration script for LG OLED CX
43# Copyright (c) 2022-2023 Pete Batard <pete@akeo.ie>
54# See https://github.com/RootMyTV/RootMyTV.github.io/issues/72#issuecomment-1343204028
65
7- # Set the following to the directory where you have the GST plugins
8- GST_SRC=/home/root/gst
6+ # Get the path where the script is located.
7+ # Adapted from https://github.com/rmyorston/busybox-w32/issues/154
8+ LAST_COMMAND=" $_ " # IMPORTANT: This must be the first command in the script
9+ ps_output=" $( ps -o pid,comm | grep -Fw $$ ) "
10+ for cs in $ps_output ; do
11+ CURRENT_SHELL=$cs
12+ done ;
13+ if [[ -n " $BASH_SOURCE " ]]; then
14+ SCRIPT=" ${BASH_SOURCE[0]} "
15+ elif [[ " $0 " != " $CURRENT_SHELL " ]] && [[ " $0 " != " -$CURRENT_SHELL " ]]; then
16+ SCRIPT=" $0 "
17+ elif [[ -n " $LAST_COMMAND " ]]; then
18+ SCRIPT=" $LAST_COMMAND "
19+ else
20+ echo " Could not get script path - Aborting" ;
21+ exit 1
22+ fi ;
23+
24+ SCRIPT=$( realpath " $SCRIPT " 2>& -)
25+ SCRIPT_DIR=$( dirname " $SCRIPT " )
26+
27+ # Set the directory where the GST plugins are located
28+ GST_SRC=$SCRIPT_DIR /gst
929
1030# Validate that we have the relevant init.d directory
1131INIT_DIR=/var/lib/webosbrew/init.d
@@ -15,8 +35,12 @@ if [[ ! -d $INIT_DIR ]]; then
1535fi
1636
1737# Validate that there is a GStreamer registry to override
18- if [[ -z $GST_REGISTRY_1_0 ]] || [[ ! -f $GST_REGISTRY_1_0 ]]; then
19- echo ' Could not locate GStreamer registry on this environment - Aborting'
38+ if [[ -z " $GST_REGISTRY_1_0 " ]] || [[ ! -f " $GST_REGISTRY_1_0 " ]]; then
39+ echo " Could not locate the GStreamer registry on this environment - Aborting"
40+ echo
41+ echo " If needed, please make sure that you use an ssh session and not a"
42+ echo " telnet session when running this installer, as telnet is missing the"
43+ echo " required environmental variables and is known to cause this issue..."
2044 exit 1
2145fi
2246
@@ -63,10 +87,9 @@ if [[ "$GST_VERSION" != "1.14.4" || "${WEBOS_VERSION::1}" != "5" || "${MODEL_NAM
6387 esac
6488fi
6589
66- echo " Installing $INIT_DIR /restore_dts"
67-
68- # The script must *NOT* have a .sh extension
69- cat << EOS > $INIT_DIR /restore_dts
90+ # Create the init script
91+ echo " Creating $SCRIPT_DIR /init_dts.sh"
92+ cat << EOS > $SCRIPT_DIR /init_dts.sh
7093#!/bin/bash
7194
7295# Override the GST plugins that were nerfed by LG
@@ -105,10 +128,15 @@ EOT
105128 fi
106129fi
107130EOS
131+ chmod 755 $SCRIPT_DIR /init_dts.sh
132+
133+ # Install/link the init script into the webosbrew init directory
134+ echo " Creating $INIT_DIR /restore_dts symbolic link"
135+ # The $INIT_DIR script must *NOT* have a .sh extension
136+ ln -s $SCRIPT_DIR /init_dts.sh $INIT_DIR /restore_dts
108137
109- chmod 755 $INIT_DIR /restore_dts
110138if [[ ! -f /tmp/gstcool.conf ]]; then
111139 echo " Running $INIT_DIR /restore_dts"
112- source $INIT_DIR /restore_dts
140+ source $INIT_DIR /restore_dts || exit 1
113141 echo " DTS playback has been permanently re-enabled - Enjoy!"
114142fi
0 commit comments