-
Notifications
You must be signed in to change notification settings - Fork 2
/
stime.sh
82 lines (65 loc) · 1.82 KB
/
stime.sh
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
#!/bin/sh
# Installer:
#
# installConfig/
# config.txt
# hive.tf
# installSTime.sh --> Will just work over installConfig folder
# 1. Read properties of config.txt and create variables
# 2. Parse/Prepare hive.tf
# 3. Use terraform to deploy hive to VPS
# Check if an installation already exists
case "$1" in
"remove" )
cd ./installConfig/
rm stclient
rm -rf electronGUI
rm -rf go*
rm -rf vpskeys/*
rm -rf reports/*
rm -rf downloads/*
rm -rf ../src/github.com/
rm -rf ../src/golang.org/
rm -rf ../src/google.golang.org/
rm -rf ../src/go.opencensus.io/
rm -rf ../src/cloud.google.com/
rm -rf ../pkg
rm -rf npm-debug.log
;;
"install" )
#Prepare User inputs to install client
USERNAME=$2
PASSWORD=$3
HASH=$(htpasswd -bnBC 14 "" ${PASSWORD} | tr -d ':\n')
HIVIP=$4
HIVPORT=$5
CLIENTPORT=$6
HIVTLSHASH=$7
#Required Software to compile client
sudo apt-get update
sudo apt-get install gcc unzip
# Download GO and Compile Hive
wget https://golang.org/dl/go1.16.linux-amd64.tar.gz -P ./installConfig/
tar xvf ./installConfig/go1.16.linux-amd64.tar.gz -C ./installConfig/
export GOROOT="$(pwd)/installConfig/go/"
export GOPATH="$(pwd)"
#Compile client with target variables and prepare electron front-end
cd ./installConfig
GO111MODULE=off ./go/bin/go get "github.com/gorilla/mux"
GO111MODULE=off GOOS=linux GOARCH=amd64 ./go/bin/go build --ldflags "-X main.username=${USERNAME} -X main.password=${PASSWORD} -X main.roasterString=${HIVIP}:${HIVPORT} -X main.fingerPrint=${HIVTLSHASH} -X main.clientPort=${CLIENTPORT}" -o stclient client
cp -r ../src/client/electronGUI/ .
cd electronGUI/
find . -type f | xargs sed -i "s/127\.0\.0\.1:8000/127\.0\.0\.1:${CLIENTPORT}/g"
sudo apt-get install -y npm
npm install
exit 1
;;
*) cd ./installConfig/
./stclient &
sleep 20s
cd electronGUI
npm start
pkill stclient
exit 1
;;
esac