summaryrefstree
path: root/usr/bin/try-mount-mtd
blob: 59bab7a43e047c6a91945cfdabb6ca230b528c6f (plain)
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
47
48
49
#!/bin/sh

mount_mtd()
{
	id=$1;
	vol=$2;
	size=$3;
	path=$4;
	mountsize=$5

	success="YES"
	copy="NO"

	# if file exist
	if [ -e /dev/mtd$id ] ; then

		#try to mount
		ubiattach  -d $id -m $id   1>/dev/null 2>/dev/null

		mount -o sync -t ubifs /dev/ubi${id}_0 $path    1>/dev/null 2>/dev/null
		if [ $? -ne 0 ] ; then 
			success="NO"
		fi
	else
		success="NO"
	fi

	if [ $success = "NO" ] ;then
		mount -t tmpfs tmpfs $path
		copy="YES"
	fi
	
	if [ $copy = "YES" ] ;then
		cp -fR /opt/${path}_base/* $path 
	fi
}

install -d /var/log
install -d /var/database
install -d /etc/avnt
install -d /var/cache

mount_mtd  8  "log" "15MiB" "/var/log" "13MiB"
mount_mtd  9  "DataBase" "100MiB" "/var/database" "80MiB"
mount_mtd  10 "Configuration"  "5MiB" "/etc/avnt" "4MiB"
mount_mtd  11 "Cache" "50MiB" "/var/cache" "46MiB"

exit 0