summaryrefslogtreecommitdiff
blob: a8e35a781de626919592be281f6dcba6724c2332 (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
#!/bin/bash

declare -i cfgnum

if [ $1 = "install" ]; then
	FILE="${VHOST_CGIBINDIR}/webmo/interfaces/._cfg*_globals.int"

	sed -i \
		-e "s:^htmlBase.*:htmlBase=\"${VHOST_HTDOCSDIR}/webmo\":g" \
		-e "s:^cgiBase.*:cgiBase=\"${VHOST_CGIBINDIR}/webmo\" :g" \
		-e "s:userBase.*:userBase=\"${VHOST_ROOT}/webmo\":g" \
		${FILE}

	pushd ${VHOST_CGIBINDIR}/webmo/interfaces > /dev/null

	# If a program is enabled, install .int.disabled changes to .int
	for file in *.disabled; do
		enabled_file=${file%.disabled}
		echo -n "Checking for enabled interface '${enabled_file}' ... "
		if [[ -e ${enabled_file} ]]; then
			echo "yes"
			for (( cfgnum=10#0000; cfgnum < 10#9999; cfgnum++ )); do
				# A number can't be padded with zero's, but a string can
				cfgstr=$(printf "%.4d" ${cfgnum})
				enabled_cfgfile=._cfg${cfgstr}_${enabled_file}
				if [[ ! -e ${enabled_cfgfile} ]]; then
					mv ${file} ${enabled_cfgfile}
					break
				fi
			done
		else
			echo "no"
		fi
	done

	# Handle ._cfg* files properly, whether interfaces are enabled or not
	for file in ._cfg*disabled; do
		realfile=${file#._cfg*_}
		enabled_file=${realfile%.disabled}
		# If interface is enabled, then rename the config file
		# But be considerate of other unmerged config files
		if [[ -e ${enabled_file} ]]; then
			cfgnum=${file%.disabled}
			cfgnum=${cfgnum#._cfg}
			cfgnum=10#${cfgnum%%_*}
			for (( ; cfgnum < 10#9999; cfgnum++ )); do
				# A number can't be padded with zero's, but a string can
				cfgstr=$(printf "%.4d" ${cfgnum})
				enabled_cfgfile=._cfg${cfgstr}_${enabled_file}
				if [[ ! -e ${enabled_cfgfile} ]]; then
					mv ${file} ${enabled_cfgfile}
					break
				fi
			done
		fi
	done
	popd > /dev/null
else
	echo "done."
fi

if [ $1 = "clean" ]; then
	echo "Please examine the contents of the following directories"
	echo "and delete anything that is no longer necessary"
	echo
	echo ${VHOST_HTDOCSDIR}
	echo ${VHOST_CGIBINDIR}/webmo
	echo ${VHOST_ROOT}/webmo
fi