summaryrefslogtreecommitdiff
path: root/addons/x11infoscreen/etc/init.d/flashybrid.orig
blob: 9ea31d7d22f8a5dba89a8364847ba613553b876e (plain)
  1. #!/bin/sh
  2. # Set up/shutdown the flashybrid system, including the ramdisk and partial
  3. # directory bind mounts. This needs to run at the part of system bootup that
  4. # mounts all the disks. It should also run at shutdown right before
  5. # filesystems are unmounted.
  6. CONFDIR=/etc/flashybrid
  7. if [ -e $CONFDIR/config ]; then
  8. . $CONFDIR/config
  9. fi
  10. ENABLED=no
  11. if [ -e /etc/default/flashybrid ]; then
  12. . /etc/default/flashybrid
  13. fi
  14. if [ -z "$RAMMOUNT" ]; then
  15. exit 0
  16. fi
  17. is_mounted () {
  18. grep -q " $1 " /proc/mounts
  19. }
  20. case "$1" in
  21. start)
  22. if [ "$ENABLED" != yes ]; then
  23. echo "Not setting up flashybrid system: disabled."
  24. exit
  25. fi
  26. printf "Setting up flashybrid system..."
  27. # Set up partial directories and so on, make sure disk is
  28. # unmounted.
  29. fh-embed >/dev/null
  30. # Set up ram disk to hold variable data.
  31. if ! is_mounted $RAMMOUNT; then
  32. mount tmpfs -t tmpfs $RAMMOUNT
  33. fi
  34. # Temporary directories on ram disk.
  35. for dir in $(grep -v '^#' $CONFDIR/ramtmp); do
  36. mkdir -p -m 1777 $RAMMOUNT/$dir
  37. if is_mounted $dir; then
  38. umount $dir
  39. fi
  40. mount --bind $RAMMOUNT/$dir $dir
  41. done
  42. # Copy data from flash to ram disk for these directories.
  43. for dir in $(grep -v '^#' $CONFDIR/ramstore); do
  44. # Skip dirs that are not present.
  45. if [ -d $dir ]; then
  46. ramdir=$RAMMOUNT$dir
  47. if is_mounted $dir; then
  48. umount $dir
  49. fi
  50. if is_mounted $ramdir.flash; then
  51. umount $ramdir.flash
  52. fi
  53. if [ ! -d $ramdir ]; then
  54. mkdir -p ${ramdir%/*} # dirname
  55. cp -a $dir $ramdir
  56. fi
  57. mkdir -p $ramdir.flash
  58. mount --bind $dir $ramdir.flash
  59. mount --bind $ramdir $dir
  60. fi
  61. done
  62. echo "done."
  63. ;;
  64. stop)
  65. if [ "$ENABLED" != yes ]; then
  66. echo "Not shutting down flashybrid system: disabled."
  67. exit
  68. fi
  69. printf "Shutting down flashybrid system..."
  70. # Copy data to flash.
  71. # Remount the flash read-write so the copies to it will work.
  72. mount -o remount,rw /
  73. for dir in $(grep -v '^#' $CONFDIR/ramstore); do
  74. if [ -d $RAMMOUNT/$dir ] && [ -d $RAMMOUNT/$dir.flash ]; then
  75. # rsync is used to avoid churning the flash
  76. # unnecessarily. The trailing slashes are very
  77. # important..
  78. rsync --delete -a $RAMMOUNT/$dir/ $RAMMOUNT/$dir.flash/
  79. fi
  80. done
  81. for dir in $(grep -v '^#' $CONFDIR/ramtmp); do
  82. if is_mounted $dir; then
  83. umount $dir
  84. fi
  85. done
  86. for dir in $(grep -v '^#' $CONFDIR/ramstore); do
  87. ramdir=$RAMMOUNT$dir
  88. if is_mounted $ramdir.flash; then
  89. umount $ramdir.flash
  90. fi
  91. if is_mounted $dir; then
  92. umount $dir
  93. fi
  94. done
  95. if is_mounted $RAMMOUNT; then
  96. umount $RAMMOUNT
  97. fi
  98. echo "done."
  99. ;;
  100. restart|force-reload)
  101. $0 stop
  102. $0 start
  103. ;;
  104. *)
  105. echo "Usage: $0 {start|stop|restart|force-reload}"
  106. exit 1
  107. ;;
  108. esac