update_system.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #! /bin/sh
  2. TEMPROOT=${1:-/usr/local/storage/dest/temproot/`uname -m`}
  3. # Check that the temproot is there
  4. if [ ! -d "${TEMPROOT}" ]; then
  5. echo "Temproot ${TEMPROOT} missing"
  6. exit 1
  7. fi
  8. cd "${TEMPROOT}"
  9. # First we must copy the /usr/lib content to /usr/lib so that all copied
  10. # binaries will find their libs
  11. if [ -d "usr/lib" ]; then
  12. tar cf - "usr/lib" | tar -C / -p -h -x -f -
  13. fi
  14. # Now copy everything over
  15. for DIR in /usr/{X11R6,bin,games,include,lib,libdata,libexec,mdec,sbin,share} ; do
  16. echo "${DIR}"
  17. if [ ! -d "${DIR}" ]; then
  18. echo "Ignoring directory ${DIR}"
  19. elif [ ! -d "${TEMPROOT}${DIR}" ]; then
  20. echo "Ignoring directory ${DIR}, source dir is missing"
  21. else
  22. RELDIR=`echo ${DIR} | sed 's/^\/*//g'`;
  23. mount | awk '{ print $3; }' | grep "^${DIR}$" >/dev/null
  24. let ISMOUNTPOINT=$?
  25. if [[ ${ISMOUNTPOINT} -eq 0 ]]; then
  26. mkdir "${DIR}/.old" \
  27. && mv "${DIR}"/* "${DIR}/.old" \
  28. && tar cf - ${RELDIR} | tar -C / -p -h -x -f - \
  29. && rm -rf "${DIR}/.old"
  30. else
  31. mv "${DIR}" "${DIR}.old" \
  32. && tar cf - ${RELDIR} | tar -C / -p -h -x -f - \
  33. && rm -rf "${DIR}.old"
  34. fi
  35. sync
  36. fi
  37. done