File: fh-embed

package info (click to toggle)
flashybrid 0.002
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 120 kB
  • ctags: 5
  • sloc: sh: 194; makefile: 44
file content (46 lines) | stat: -rwxr-xr-x 1,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# Enter embedded mode.
# This program should be fully idempotent.

set -e

CONFDIR=/etc/flashybrid
. $CONFDIR/config

# Trim trailing slash from FLASHMOUNT; this is necessary so I can use
# $FLASHMOUNT$dir below when building up mount points, and not get extra
# slashes.
FLASHMOUNT=${FLASHMOUNT%%/}

is_mounted () {
	grep -q " $1 " /proc/mounts
}

if [ -e $CONFDIR/partial ]; then
	for file in $(grep -v '^#' $CONFDIR/partial); do
		dir=${file%/*}
		if [ ! -e $FLASHMOUNT$dir/.partial ]; then
			if is_mounted $FLASHMOUNT$dir; then
				umount $FLASHMOUNT$dir
			fi
			mount --bind $FLASHMOUNT$dir.partial $FLASHMOUNT$dir
		fi
	done
fi

if [ -e $CONFDIR/diskstore ]; then
	for dir in $(grep -v '^#' $CONFDIR/diskstore); do
		if [ -d $FLASHMOUNT$dir ]; then
			if is_mounted $FLASHMOUNT$dir; then
				umount $FLASHMOUNT$dir
			fi
			mount --bind /lib/flashybrid/ondisk_dir $FLASHMOUNT$dir
		fi
	done
fi

if [ -n "$DISKMOUNT" ] && is_mounted $DISKMOUNT; then
	umount $DISKMOUNT
fi

eval $EMBED_CMDS || true