1
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-11-28 06:14:38 +00:00
Lakka-LibreELEC/projects/L4T/packages/systemd/scripts/usercache-setup
2022-04-23 21:36:57 +02:00

28 lines
1017 B
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
# Fix bug in older versions creating file /storage/.cache/services
[ -f /storage/.cache/services ] && rm /storage/.cache/services && mkdir -p /storage/.cache/services
# Copy cache files, but don't overwrite
false | cp -iRp /usr/cache/* /storage/.cache/ &>/dev/null
# Merge default and custom shadow file details
if [ -f /storage/.cache/shadow -a -f /usr/cache/shadow ]; then
# Get existing root details (possibly user defined)
userroot="$(grep "^root:" /storage/.cache/shadow)"
# Overwrite users shadow file with default details, replacing root with any existing value
# If current file is garbage (ie. missing root) then replace it
if [ -n "${userroot}" ]; then
sed -e "s ^root:.* ${userroot} " /usr/cache/shadow >/storage/.cache/shadow
else
cp -fp /usr/cache/shadow /storage/.cache/shadow
fi
# Make sure we have the correct permission
chmod 000 /storage/.cache/shadow
fi