This repository was archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·68 lines (59 loc) · 1.51 KB
/
setup.sh
File metadata and controls
executable file
·68 lines (59 loc) · 1.51 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
#!/usr/bin/env bash
# User runtime configuration
PORT=8443;
# Environment Variables
MANIFEST=manifest.xml
PROTOCOL=https:\\/\\/;
HOST=0.0.0.0;
FP="$PROTOCOL$HOST:$PORT";
# Delims
T_HOST='<?bash $ip ?>';
T_PORT='<?bash $port ?>';
# Cleans any previously generated manifests
function clean {
echo "Cleaning project files"
[[ -f "$MANIFEST" ]] && rm $MANIFEST;
}
# Install dependencies
function exec_bundler {
echo "Checking dependencies"
if hash bundler 2>/dev/null; then
echo "Bundler already installed. Hooray."
else
echo "Bundler not installed - installing requires sudoer status."
echo "Enter password to proceed with Bundler installation"
sudo gem install bundler;
fi
echo "Verifying gems."
bundle install;
}
# Generates an app manifest for this machine
function generate_manifest {
echo "Generating add-in manifest"
sed "s/$T_HOST/$FP/g" .template/manifest/manifest.xml > manifest.xml;
}
# Generates a Sinatra script listening on the same port for which the manifest
# was generated
function generate_sinatra {
echo "Generating server script"
sed "s/$T_PORT/$PORT/g" .template/serv/app.rb > app.rb
}
function inform_cert {
# Check if they have a cert - do they?
# If they don't tell them to run the script...
if [ ! -f cert/server.crt ] && [ ! -f cert/server.key ]; then
echo "No certificate installed. Generating..";
cd cert;
./ss_certgen.sh;
fi
}
## Main
clean
sleep 1
exec_bundler
sleep 1
generate_manifest
sleep 1
generate_sinatra
sleep 1
inform_cert;