summaryrefslogtreecommitdiff
path: root/multitech/recipes/multitech/config/config.init
blob: 98bbf35ccb314a87a729ad954bd832f7c37255b6 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh

CONFIG_MTDC=/dev/mtd6
CONFIG_DIR=/var/config
OEM_MTDC=/dev/mtd7
OEM_DIR=/var/oem

FILES="network/interfaces \
ppp/options \
ppp/pap-secrets \
ppp/chap-secrets \
ppp/peers \
passwd \
group"

case $1 in
	start)
		echo "Mounting ${CONFIG_DIR}"
		mkdir -p ${CONFIG_DIR}
		mount ${CONFIG_DIR}

		# Prepare flash for JFFS2 if mount fails
		if [ $? -ne 0 ]; then
			echo "Creating ${CONFIG_DIR}"
			flash_eraseall -j ${CONFIG_MTDC}
			mount ${CONFIG_DIR}
		fi

		echo "Mounting ${OEM_DIR}"
		mkdir -p ${OEM_DIR}
		mount ${OEM_DIR}

		# Prepare flash for JFFS2 if mount fails
		if [ $? -ne 0 ]; then
			echo "Creating ${OEM_DIR}"
			flash_eraseall -j ${OEM_MTDC}
			mount ${OEM_DIR}
		fi

		# Default all config files if requested
		cd ${CONFIG_DIR}
		if [ -f force_defaults ]; then
			echo "Extracting default config files"
			tar -xvf /etc/defaults.tar.gz
			rm -f force_defaults
		fi

		# Extract any missing files
		TARFILES=`tar -tf /etc/defaults.tar.gz`
		for file in $TARFILES; do
			if [ ! -e $file ]; then
				tar -xvf /etc/defaults.tar.gz $file
			fi
		done

		# Create links in /etc
		for file in $FILES; do
			if [ ! -L /etc/$file ]; then
				echo "Creating link to ${CONFIG_DIR}/$file"
				rm -rf /etc/$file
				ln -sf ${CONFIG_DIR}/$file /etc/$file
			fi
		done

	;;

	*)
		echo "Usage: $0 {start}"
		exit 2
	;;

esac