recipes: libs/fuse2: Minor update on the rc script
[dragora.git] / archive / fuse / rc.fuse
blob23a708eb1679ee876df93d1e9bd7305a27e26002
1 #! /bin/sh -
3 # Load the fuse module (if exists) and mount the fuse control file system
5 # Copyright (c) 2019-2020 Matias Fonzo, <selk@dragora.org>.
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 PROGRAM="${0##*/}"
21 # Sanity check
22 if ! command -v fusermount > /dev/null
23 then
24 echo "${0}: Error: fusermount(1) is not available." 1>&2
25 exit 127;
28 # Main functions
30 fuse_start()
32 if modinfo fuse > /dev/null 2>&1
33 then
34 echo "${PROGRAM}: Loading fuse (kernel) module ..."
35 modprobe fuse
38 if ! mountpoint -q /sys/fs/fuse/connections
39 then
40 echo "${PROGRAM}: Mounting fusectl filesystem ..."
41 mount -v -t fusectl fusectl /sys/fs/fuse/connections
42 else
43 echo "${PROGRAM}: FUSE filesystem already mounted at /sys/fs/fuse/connections" 1>&2
47 fuse_stop()
49 if mountpoint -q /sys/fs/fuse/connections
50 then
51 echo "${PROGRAM}: Unmounting FUSE filesystem ..."
52 umount -v /sys/fs/fuse/connections
53 else
54 echo "${PROGRAM}: FUSE filesystem not mounted." 1>&2
57 if grep -q -w ^fuse /proc/modules
58 then
59 echo "${PROGRAM}: Unloading fuse (kernel) module ..."
60 rmmod fuse
64 # Command line arguments
66 case $1 in
67 start)
68 fuse_start
70 stop)
71 fuse_stop
73 restart)
74 fuse_stop
75 fuse_start
78 echo "Usage: $0 (start|stop|restart)" 1>&2
79 exit 1
81 esac