You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
688 B

  1. #!/bin/bash
  2. orig=$0.diverted
  3. if [ -z "$APP_LOCATION" ]; then
  4. echo "Error: APP_LOCATION was not defined."
  5. exit 1
  6. fi
  7. app=/srv/app
  8. root=$app/root
  9. changes=$app/changes/0000
  10. mnt=$app/mnt
  11. ## All these should be in the root image
  12. #mkdir -p $root $mnt
  13. #mkdir -p "$(dirname "$APP_LOCATION")"
  14. if [ -d "$changes" ]; then
  15. clean_all() {
  16. cd /
  17. mountpoint "$mnt" 2>/dev/null && umount "$mnt"
  18. }
  19. trap "clean_all" EXIT
  20. mount -t aufs -o br=$changes:$root -o udba=none none "$mnt"
  21. if [ "$?" != 0 ]; then
  22. echo "Error: aufs mount failed."
  23. exit 1
  24. fi
  25. ln -sf "$mnt" "$APP_LOCATION"
  26. else
  27. ln -sf "$root" "$APP_LOCATION"
  28. fi
  29. "$orig" "$@"