80_mount_root 809 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2006 OpenWrt.org
  2. # Copyright (C) 2010 Vertical Communications
  3. missing_lines() {
  4. local file1 file2 line
  5. file1="$1"
  6. file2="$2"
  7. oIFS="$IFS"
  8. IFS=":"
  9. while read line; do
  10. set -- $line
  11. grep -q "^$1:" "$file2" || echo "$*"
  12. done < "$file1"
  13. IFS="$oIFS"
  14. }
  15. do_mount_root() {
  16. mount_root
  17. boot_run_hook preinit_mount_root
  18. [ -f /sysupgrade.tgz ] && {
  19. echo "- config restore -"
  20. cp /etc/passwd /etc/group /etc/shadow /tmp
  21. cd /
  22. tar xzf /sysupgrade.tgz
  23. missing_lines /tmp/passwd /etc/passwd >> /etc/passwd
  24. missing_lines /tmp/group /etc/group >> /etc/group
  25. missing_lines /tmp/shadow /etc/shadow >> /etc/shadow
  26. rm /tmp/passwd /tmp/group /tmp/shadow
  27. # Prevent configuration corruption on a power loss
  28. sync
  29. }
  30. }
  31. [ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root