aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2020-10-22 13:13:39 +0100
committerDaniel Golle <daniel@makrotopia.org>2020-10-22 14:25:55 +0100
commitde7ca7dafadfd650d031e0379ce0c002868d5936 (patch)
tree2b43e648ba33657b36de92319d496d68895ef58d /package/base-files/files/lib
parent2812ea3acb88c7e3649c912d6ad761bf8818fc51 (diff)
downloadupstream-de7ca7dafadfd650d031e0379ce0c002868d5936.tar.gz
upstream-de7ca7dafadfd650d031e0379ce0c002868d5936.tar.bz2
upstream-de7ca7dafadfd650d031e0379ce0c002868d5936.zip
base-files: merge /etc/passwd et al at sysupgrade config restore
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/base-files/files/lib')
-rw-r--r--package/base-files/files/lib/preinit/80_mount_root16
1 files changed, 16 insertions, 0 deletions
diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root
index 265a3f18df..56d3fa3797 100644
--- a/package/base-files/files/lib/preinit/80_mount_root
+++ b/package/base-files/files/lib/preinit/80_mount_root
@@ -2,6 +2,19 @@
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
+missing_lines() {
+ local file1 file2 line
+ file1="$1"
+ file2="$2"
+ oIFS="$IFS"
+ IFS=":"
+ while read line; do
+ set -- $line
+ grep -q "^$1:" "$file2" || echo "$*"
+ done < "$file1"
+ IFS="$oIFS"
+}
+
do_mount_root() {
mount_root
boot_run_hook preinit_mount_root
@@ -9,6 +22,9 @@ do_mount_root() {
echo "- config restore -"
cd /
tar xzf /sysupgrade.tgz
+ missing_lines /rom/etc/passwd /etc/passwd >> /etc/passwd
+ missing_lines /rom/etc/group /etc/group >> /etc/group
+ missing_lines /rom/etc/shadow /etc/shadow >> /etc/shadow
# Prevent configuration corruption on a power loss
sync
}