-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig
More file actions
executable file
·114 lines (106 loc) · 3.55 KB
/
config
File metadata and controls
executable file
·114 lines (106 loc) · 3.55 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/bash
echo
echo "COMMAND : fire/config $@ # FireREST/FireFUSE configuration utility"
if [ ! -L "config-default.json" ]; then
echo "STATUS : setting default to www/config.json"
ln -sTf www/config.json config-default.json;
fi
echo "DEFAULT : "`ls -l config-default.json | grep -o config.*json`
function help() {
echo "SYNOPSIS: fire/config [-d]"
echo " : fire/config "`tput smul`"config.json"`tput rmul`
echo " : fire/config -e "`tput smul`"edit.json"`tput rmul`
echo " : fire/config -D "`tput smul`"default.json"`tput rmul`
echo "EXAMPLES: Apply default configuration file:"
echo " : fire/config -d"
echo "EXAMPLES: Set default configuration file:"
echo " : fire/config -D myconfig.json"
echo "EXAMPLES: Edit current configuration file to use 400x400 camera:"
echo " : fire/config -e examples/400x400.json"
echo "EXAMPLES: Apply custom configuration file:"
echo " : fire/config custom/myconfig.json"
echo " : Print this documentation:"
echo " : fire/config -h"
echo "SEE ALSO: https://github.com/firepick1/FireREST/wiki/config.json"
}
if [ "$1" == "" ] || [ "$1" == "-h" ]; then help; exit 0; fi
if [ "$1" == "-e" ]; then EDIT=1; shift; else EDIT=0; fi
if [ "$1" == "-D" ]; then
if [ "$2" == "" ]; then
ln -sfT www/config.json config-default.json
elif [ -e "$2" ]; then
ln -sfT "$2" config-default.json
else
echo "ERROR : $2 not found"
exit -1
fi
echo "STATUS : changed default configuration file"
echo "SUCCESS : "`ls -l config-default.json | grep -o config.*json`
exit 0;
fi
CONFIG_FILE=$1
if [ "$1" == "-d" ] || [ "$1" == "DEFAULT" ]; then CONFIG_FILE=config-default.json; fi
if [ ! -e "$CONFIG_FILE" ]; then
echo "ERROR : $CONFIG_FILE not found"
exit -1;
fi
echo "STATUS : Applying configuration "`ls -l $CONFIG_FILE | grep -o config.*json`
sudo -k
ls /dev | grep firefuse > /dev/null
if [ $? -ne 0 ]; then
echo "ERROR : FireFUSE is not installed and cannot be configured"
exit -1;
fi
if [ -e /dev/firefuse/status ]; then
echo "FireFUSE: Unmounting running instance: /dev/firefuse..."
sudo fusermount -u /dev/firefuse
if [ $? -ne 0 ]; then
echo "ERROR : /dev/firefuse could not be unmounted"
exit -1
fi
else
ls /dev/firefuse > /dev/null
if [ $? -ne 0 ]; then
echo "WARNING : FireFUSE may have crashed. Attempting to unmount /dev/firefuse..."
sudo fusermount -u /dev/firefuse
if [ $? -ne 0 ]; then
echo "ERROR : /dev/firefuse could not be unmounted"
exit -1
fi
else
echo "FireFUSE: No existing instance detected at /dev/firefuse"
fi
fi
if [ $EDIT -ne 0 ]; then
echo "CONFIG : /var/firefuse/config.json + $CONFIG_FILE"
sudo grunt cfg-custom:/var/firefuse/config.json:$CONFIG_FILE
else
echo "CONFIG : $CONFIG_FILE"
sudo cp $CONFIG_FILE /var/firefuse/config.json
fi
if [ $? -ne 0 ]; then
echo "ERROR : could not update /var/firefuse/config.json"
exit -1
fi
pushd ~/FireREST/FireFUSE > /dev/null
if [ -e target/firefuse ]; then
echo "STATUS : will use locally built firefuse"
echo "COMMAND : sudo target/firefuse -o allow_other /dev/firefuse"
sudo target/firefuse -o allow_other /dev/firefuse
RC=$?
else
echo "COMMAND : sudo firefuse -o allow_other /dev/firefuse"
sudo firefuse -o allow_other /dev/firefuse
RC=$?
fi
if [ $RC -ne 0 ]; then
echo "ERROR : /dev/firefuse could not be mounted"
echo "TRY : rebooting Raspberry Pi."
exit -1
fi
popd > /dev/null
echo "SUCCESS : Configuration installed"
echo "LOG : To monitor FireFUSE activity, see /var/log/firefuse.log"
echo "------------------------------"
echo
tail /var/log/firefuse.log