From 1cd28bcc2ba552efbb0195d84011f991d758c305 Mon Sep 17 00:00:00 2001 From: weishanshan1084 Date: Mon, 29 Apr 2024 14:22:20 +0800 Subject: [PATCH] add rootfs-chown package Signed-off-by: weishanshan1084 --- package/Config.in | 1 + package/rootfs-chown/Config.in | 2 + package/rootfs-chown/rootfs-chown.mk | 23 ++++++++ package/rootfs-chown/src/S60rootfs-chown | 54 +++++++++++++++++++ .../src/systemd-rootfs-chown.service | 11 ++++ 5 files changed, 91 insertions(+) create mode 100644 package/rootfs-chown/Config.in create mode 100644 package/rootfs-chown/rootfs-chown.mk create mode 100755 package/rootfs-chown/src/S60rootfs-chown create mode 100644 package/rootfs-chown/src/systemd-rootfs-chown.service diff --git a/package/Config.in b/package/Config.in index c677c3ff..0acc2466 100644 --- a/package/Config.in +++ b/package/Config.in @@ -253,6 +253,7 @@ menu "Filesystem and flash utilities" source "package/xfsprogs/Config.in" source "package/zerofree/Config.in" source "package/zfs/Config.in" + source "package/rootfs-chown/Config.in" endmenu menu "Fonts, cursors, icons, sounds and themes" diff --git a/package/rootfs-chown/Config.in b/package/rootfs-chown/Config.in new file mode 100644 index 00000000..f88d5075 --- /dev/null +++ b/package/rootfs-chown/Config.in @@ -0,0 +1,2 @@ +config BR2_PACKAGE_ROOTFS_CHOWN + bool "rootfs_chown" diff --git a/package/rootfs-chown/rootfs-chown.mk b/package/rootfs-chown/rootfs-chown.mk new file mode 100644 index 00000000..f3b46f7b --- /dev/null +++ b/package/rootfs-chown/rootfs-chown.mk @@ -0,0 +1,23 @@ +################################################################################ +# +# rootfs-chown +# +################################################################################ + +ROOTFS_CHOWN_VERSION = 0.1 +ROOTFS_CHOWN_SITE = package/rootfs-chown/src +ROOTFS_CHOWN_SITE_METHOD = local +ROOTFS_CHOWN_INSTALL_TARGET_CMDS = YES + +define ROOTFS_CHOWN_INSTALL_INIT_SYSV + $(INSTALL) -m 755 -D $(@D)/S60rootfs-chown $(TARGET_DIR)/etc/init.d/ +endef + +define ROOTFS_CHOWN_INSTALL_TARGET_CMDS + mkdir -p $(TARGET_DIR)/etc/init.d/ + mkdir -p $(TARGET_DIR)/lib/systemd/system/ + $(INSTALL) -m 755 -D $(@D)/S60rootfs-chown $(TARGET_DIR)/etc/init.d/ + $(INSTALL) -m 644 -D $(@D)/systemd-rootfs-chown.service $(TARGET_DIR)/lib/systemd/system/ +endef + +$(eval $(generic-package)) diff --git a/package/rootfs-chown/src/S60rootfs-chown b/package/rootfs-chown/src/S60rootfs-chown new file mode 100755 index 00000000..d48f46e0 --- /dev/null +++ b/package/rootfs-chown/src/S60rootfs-chown @@ -0,0 +1,54 @@ +#!/bin/sh +# +# rootfs-chown Starts rootfs-chown. +# +rootfs_chown() { + printf "\t chown folder in the rootfs: " + + [ -d /var/cache/man ] && chown -R man:root /var/cache/man + [ -d /var/lib/sddm ] && chown -R sddm:sddm /var/lib/sddm + if [ -d /var/lib/lightdm ]; then + chown -R lightdm:lightdm /var/lib/lightdm || true + chmod 0750 /var/lib/lightdm + fi + + chown -R user:user /home/user + if [ $? -eq 0 ] + then + echo "OK" + else + echo "Failed" + exit 1 + fi + echo 0 +} + +start() { + printf "Starting rootfs-chown: \n" + rootfs_chown +} + +stop() { + printf "Stopping rootfs-chown: " + echo "OK" +} +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac +exit $? diff --git a/package/rootfs-chown/src/systemd-rootfs-chown.service b/package/rootfs-chown/src/systemd-rootfs-chown.service new file mode 100644 index 00000000..b5dbd3a5 --- /dev/null +++ b/package/rootfs-chown/src/systemd-rootfs-chown.service @@ -0,0 +1,11 @@ +[Unit] +Description=chown folder +DefaultDependencies=no +After=getty.target + +[Service] +Type=oneshot +ExecStart=/etc/init.d/S60rootfs-chown start + +[Install] +WantedBy=multi-user.target