-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.txt
218 lines (188 loc) · 6.63 KB
/
install.txt
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
# Install script for the WireGarden browser plugin
# More information at Manylabs.org
#### Variables
# Replace line with version: i.e version="1.0.0.6"
installDir="/opt/WireGarden/WireGardenPlugin/$version"
pluginDir="/usr/lib/mozilla/plugins"
bit="32"
#### Functions
function checkCommand(){
local command_loc=""
if ! command_loc="$(type -p "$1")" || [ -z "$command_loc" ]; then
return 1
fi
return 0
}
function echoUsage(){
echo -e "
Usage: $0 [options] [Install Directory]
Install the WireGarden browser plugin.
Install Directory defaults to: /opt/WireGarden
Options:
-64\t\tInstall 64 bit Arduino toolchain. Defaults to 32 bit (which is probably what you want).
-h, --help\tShow this message and exit.
"
}
function install(){
# Check for make, cmake, gcc, and g++
if ! checkCommand "make"; then
echo "Error: Make is required. Please install Make and run this script again."
exit 1
fi
if ! checkCommand "cmake"; then
echo "Error: CMake is required. Please install CMake and run this script again."
exit 1
fi
if ! checkCommand "gcc"; then
echo "Error: gcc is required. Please install gcc and run this script again."
exit 1
fi
if ! checkCommand "g++"; then
echo "Error: g++ is required. Please install g++ and run this script again."
exit 1
fi
# cd to our own directory
scriptDir="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
cd $scriptDir
# Make sure the plugin has been built first
if [ ! -f "Build/bin/WireGardenPlugin/npWireGardenPlugin.so" ]; then
echo "Error: The plugin must be built first. Please run build.sh and then run this script again."
exit 1
fi
# Create install directory
if [ ! -d "$installDir" ]; then
# Create directory
echo "Creating installation directory: $installDir."
if ! mkdir -p "$installDir"; then
echo "Error: Could not create installation directory. You may need to run this script with sudo."
exit 1
fi
fi
# Create libraries directory
echo "Creating libraries directory under installation directory."
if ! mkdir -p "$installDir/libraries"; then
echo "Error: Could not create libraries directory under installation directory."
exit 1
fi
# Create hardware directory
echo "Creating hardware directory under installation directory."
if ! mkdir -p "$installDir/hardware"; then
echo "Error: Could not create hardware directory under installation directory."
exit 1
fi
# Copy Arduino Tools
echo "Copying hardware files to installation directory."
if ! cp -r "arduinoTools/hardware" "$installDir"; then
echo "Error: Could not copy hardware files."
exit 1
fi
echo "Copying Arduino tool files to installation directory. - $bit bit"
if ! cp -r "arduinoTools/$bit/hardware" "$installDir"; then
echo "Error: Could not copy Arduino tool files."
exit 1
fi
echo "Copying Arduino libraries to installation directory."
if ! cp -pr "arduinoTools/libraries" "$installDir"; then
echo "Error: Could not copy Arduino libraries."
exit 1
fi
# Copy domain whitelist
echo "Copying domain whitelist installation directory"
if ! cp "Source/WireGardenPlugin/whitelist.txt" "$installDir"; then
echo "Error: Could not copy domain whitelist."
exit 1
fi
# Copy plugin
echo "Copying plugin to installation directory"
if ! cp "Build/bin/WireGardenPlugin/npWireGardenPlugin.so" "$installDir"; then
echo "Error: Could not copy plugin."
exit 1
fi
# Create plugin directory if it doesn't exist
if [ ! -d "$pluginDir" ]; then
# Create directory
echo "Creating plugin directory: $pluginDir."
if ! mkdir -p "$pluginDir"; then
echo "Error: Could not create plugin directory. You may need to run this script with sudo."
exit 1
fi
fi
# Create plugin symlink
echo "Creating symlink for plugin in $pluginDir"
cd "$pluginDir"
if ! ln -sf "$installDir/npWireGardenPlugin.so" "npWireGardenPlugin.so"; then
echo "Error: Could not create symlink for plugin."
exit 1
fi
# Set permissions and access control
echo "Setting permissions for installation directory to 777"
if ! chmod -R a=rwx $installDir/../../; then
echo "Error: could not set permissions for installation directory. You may need to run this script with sudo."
exit 1
fi
echo "Setting access control for installation directory. Newly created files and folders will have permissions 777."
if ! setfacl -d -m u::rwx,g::rwx,o::rwx $installDir; then
echo "Error: could not set access control for installation directory. You may need to run this script with sudo."
exit 1
fi
# Add user to dialout group. This is usually required to use serial ports.
echo "Adding current user to 'dialout' group. IMPORTANT: You'll need to logout and login for this to take effect."
username = logname
if ! usermod -a -G dialout $username; then
echo "Could not add user to 'dialout' group. You may need to run this script with sudo."
exit 1
fi
return 0
}
#### Main
# Get our arguments
while :
do
case $1 in
-h | --help)
echoUsage
exit 0
;;
-64)
bit="64"
shift
break
;;
--) # End of all options
shift
break
;;
-*)
echo "Error: Unknown option: $1" >&2
echoUsage
exit 1
;;
*) # no more options. Stop while loop
break
;;
esac
done
# Check for an install directory
if [ "$#" -eq 1 ]; then
# Remove the trailing slash
installDir=`echo "${1}" | sed -e "s/\/*$//" `
# Add the version on to it
installDir="$installDir/WireGarden/WireGardenPlugin/$version"
fi
# Start installation
echo "Installing to: $installDir"
install
echo "Installation complete.
*************
* IMPORTANT *
*************
The last part of this script adds the current user to the 'dialout' group. This
is usually required to use serial ports and communicate with the Arduino. You
must logout and login again before this will take effect.
It's also possible that your distribution uses a different group. If you still
can't communicate with the Arduino after logging out and back in, attach your
Arduino and check the group that owns it. Then, add your user to that group if
you're not already a member.
"
exit 0