summaryrefslogtreecommitdiff
path: root/sysutils/fusefs-kmod/files/setup.sh
blob: eb7c403fcc7068171690627ecd3b34e8d2f74a05 (plain) (blame)
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
#!/bin/sh
#
# Automatically setup the loading of the module without polluting /boot/modules
SYSCTL_CONFIG=/etc/sysctl.conf
LOADER_CONFIG=/etc/rc.conf

sysctl kern.module_path | grep "[:space:;=]@@PREFIX@@/modules[;]\?\b" > /dev/null 2>&1; RESULT=$?
if [ ${RESULT} -eq 1 ]; then
	MODULE_PATH="`sysctl -n kern.module_path`;@@PREFIX@@/modules"
	sysctl "kern.module_path=${MODULE_PATH}"
else
	MODULE_PATH=`sysctl -n kern.module_path`
fi

grep "kern\.module_path" ${SYSCTL_CONFIG} > /dev/null 2>&1; RESULT=$?
if [ ${RESULT} -eq 0 ]; then
	# Variable present
	grep "kern\.module_path" ${SYSCTL_CONFIG} | grep "[:space:;=]@@PREFIX@@/modules[;]\?\b" ${SYSCTL_CONFIG} > /dev/null 2>&1; RESULT=$?
	if [ ${RESULT} -eq 1 ]; then
		# Not present in variable, so add
		ESC_PREFIX=`echo '@@PREFIX@@' | sed -e 's/\//\\\\\//g'`
		sed -i .orig -e 's/kern\.module_path[:space:]*=[:space:]*["]*\([[:alnum:][:space:]\.,;\/_-]*\)["]*/kern\.module_path="\1;'${ESC_PREFIX}'\/modules"/g' ${SYSCTL_CONFIG}
	fi
else
	# Not present.
	echo kern.module_path="${MODULE_PATH}" >> ${SYSCTL_CONFIG}
fi


kldstat -n fuse > /dev/null 2>&1; RESULT=$?
if [ ${RESULT} -eq 0 ]; then
	kldunload -n fuse > /dev/null 2>&1; RESULT=$?
	if [ ${RESULT} -ne 0 ]; then
		echo 'NOTICE: Failed to unload the Fuse module!'
		echo 'NOTICE: Is fuse.ko in use?'
	fi
fi

grep fusefs_enable ${LOADER_CONFIG} > /dev/null 2>&1; RESULT=$?
if [ ${RESULT} -eq 0 ]; then
	# Present, we should leave it alone
#	sed -e s/fusefs_enable.*/fuse_load=\"YES\"/g -i.orig ${LOADER_CONFIG}
else
	# Not present. First time install, so lets start it up
	echo 'fusefs_enable="YES"' >> ${LOADER_CONFIG}
fi

@@PREFIX@@/etc/rc.d/fusefs start > /dev/null 2>&1 ; RESULT=$?
if [ ${RESULT} -ne 0 ]; then
	echo 'NOTICE: Failed to load the Fuse module!'
	echo 'NOTICE: Unload and load Fuse module manually, or reboot.'
fi