From 86530218420dd4518a494de4fb435c513f2a562a Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Fri, 8 Dec 2017 03:17:36 +0000 Subject: [PATCH] shadow: add usercache-setup and usercache service --- packages/sysutils/systemd/package.mk | 2 ++ .../sysutils/systemd/scripts/usercache-setup | 33 +++++++++++++++++++ .../systemd/system.d/usercache.service | 12 +++++++ 3 files changed, 47 insertions(+) create mode 100755 packages/sysutils/systemd/scripts/usercache-setup create mode 100644 packages/sysutils/systemd/system.d/usercache.service diff --git a/packages/sysutils/systemd/package.mk b/packages/sysutils/systemd/package.mk index 7cbbc42f03..6b8ebb6dbd 100644 --- a/packages/sysutils/systemd/package.mk +++ b/packages/sysutils/systemd/package.mk @@ -202,6 +202,7 @@ post_makeinstall_target() { mkdir -p $INSTALL/usr/bin cp $PKG_DIR/scripts/systemd-machine-id-setup $INSTALL/usr/bin cp $PKG_DIR/scripts/userconfig-setup $INSTALL/usr/bin + cp $PKG_DIR/scripts/usercache-setup $INSTALL/usr/bin mkdir -p $INSTALL/usr/sbin cp $PKG_DIR/scripts/kernel-overlays-setup $INSTALL/usr/sbin @@ -255,6 +256,7 @@ post_install() { enable_service machine-id.service enable_service debugconfig.service enable_service userconfig.service + enable_service usercache.service enable_service kernel-overlays.service enable_service hwdb.service } diff --git a/packages/sysutils/systemd/scripts/usercache-setup b/packages/sysutils/systemd/scripts/usercache-setup new file mode 100755 index 0000000000..1f57204283 --- /dev/null +++ b/packages/sysutils/systemd/scripts/usercache-setup @@ -0,0 +1,33 @@ +#!/bin/sh +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2017-present Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +# 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, but replacing root with any existing value + [ -n "${userroot}" ] && sed -e "s ^root:.* ${userroot} " /usr/cache/shadow >/storage/.cache/shadow + + # Make sure we have the correct permission + chmod 000 /storage/.cache/shadow +fi diff --git a/packages/sysutils/systemd/system.d/usercache.service b/packages/sysutils/systemd/system.d/usercache.service new file mode 100644 index 0000000000..26e9b5836c --- /dev/null +++ b/packages/sysutils/systemd/system.d/usercache.service @@ -0,0 +1,12 @@ +[Unit] +Description=Setup User cache dir +DefaultDependencies=no +After=systemd-tmpfiles-setup.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/usercache-setup +RemainAfterExit=yes + +[Install] +WantedBy=sysinit.target