Skip to content
42 changes: 42 additions & 0 deletions lib/rdk/gstCleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
##############################################################################
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################

CDLFILE=`cat /opt/cdl_flashed_file_name`
PREV_CDLFILE=`cat /opt/previous_flashed_file_name`


if [[ ! -f /opt/previous_flashed_file_name || ! -f /opt/cdl_flashed_file_name ]]; then
echo "Likely FSR done don't remove gstreamer registry, if still present"
if [ ! -f /opt/.gstreamer/registry.bin ]; then
echo "Gstreamer registry empty after FSR, clear /opt/.gstreamer"
rm -rf /opt/.gstreamer
GST_REGISTRY_UPDATE=yes
sleep 15
gst-inspect-1.0 >/dev/null 2>&1
fi
elif [ ! -f /opt/.gstreamer/registry.bin ] || [[ ${CDLFILE} != *"${PREV_CDLFILE}"* ]]; then
echo "Removing gstreamer registry on bootup after CDL"
rm -rf /opt/.gstreamer
GST_REGISTRY_UPDATE=yes
sleep 15
gst-inspect-1.0 >/dev/null 2>&1
else
echo "gstreamer registry is not removed, previous reboot is not due to CDL"
fi
4 changes: 3 additions & 1 deletion systemd_units/gstreamer-cleanup.service
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
[Unit]
Description=Cleans up Gstreamer Registry

After=local-fs.target nvram.service
After=nxserver.service local-fs.target nvram.service
Before=wpeframework.service
Requires=nxserver.service

[Service]
Type=oneshot
Expand All @@ -30,6 +31,7 @@ Environment="CDLFILE=$(cat /opt/cdl_flashed_file_name)"
Environment="PREV_CDLFILE=$(cat /opt/previous_flashed_file_name)"
Environment="GST_REGISTRY=/opt/.gstreamer/registry.bin"
ExecStartPre=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_START"; fi;'
#ExecStart=/lib/rdk/gstCleanup.sh
ExecStart=-/bin/sh -c 'if [[ ! -f /opt/previous_flashed_file_name || ! -f /opt/cdl_flashed_file_name || ${CDLFILE} != *"${PREV_CDLFILE}"* ]]; then echo "Removing gstreamer registry on bootup after CDL"; rm -rf /opt/.gstreamer;GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1; elif [ ! -f /opt/.gstreamer/registry.bin ]; then echo "Gstreamer registry empty"; rm -rf /opt/.gstreamer; GST_REGISTRY_UPDATE=yes gst-inspect-1.0 >/dev/null 2>&1; else echo "gstreamer registry is not removed, previous reboot is not due to CDL"; fi'
ExecStartPost=/bin/sh -c 'if [ -f /lib/rdk/logMilestone.sh ];then sh /lib/rdk/logMilestone.sh "GST_CLEANUP_COMPLETE"; fi;'
ExecStop=/bin/sh -c 'FW_UPDATE_STATE=$(cat /opt/fwdnldstatus.txt | grep FwUpdateState | cut -d "|" -f2); echo "FW_UPDATE_STATE: $FW_UPDATE_STATE"; if [ "$FW_UPDATE_STATE" == "Preparing to reboot" ]; then echo "Removing gstreamer registry after firmware update"; rm -rf /opt/.gstreamer; fi;'
Expand Down