forked from skyrings/skyring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skyring-setup.sh
executable file
·76 lines (61 loc) · 1.93 KB
/
skyring-setup.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
#!/bin/bash
# Configure and setting up the system to use skyring
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
CWD=`pwd`
function info {
printf "${GREEN}$1${NC}\n"
}
function createUser {
/opt/influxdb/influx -execute "CREATE USER admin WITH PASSWORD 'admin'"
# Grant the privileges
/opt/influxdb/influx -execute "GRANT ALL ON collectdInfluxDB TO admin"
}
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
info "Configure and setting up the system to use skyring"
info "Disabling firewalld"
systemctl stop firewalld && systemctl disable firewalld
info "Starting services"
# Enable and start the salt-master:
systemctl enable salt-master
systemctl start salt-master
#Enable and start InfluxDB:
systemctl enable influxdb
systemctl start influxdb
# Enable and start MongoDB
systemctl enable mongod
systemctl start mongod
# Need to wait for 3 to 5 sec for the services to comes up
sleep 5
info "Creating time series database"
# Create influxdb Database
/opt/influxdb/influx -execute "CREATE DATABASE IF NOT EXISTS collectd"
# Create InfluxDB User
/opt/influxdb/influx -execute 'SHOW USERS' -format column | awk '{print $1}' | grep -Fxq 'admin' || createUser
info "Creating skyring database"
# Configuring MongoDB
mongo <<EOF
use skyring
db.leads.findOne()
show collections
db.createUser( { "user" : "admin", "pwd": "admin", "roles" : ["readWrite", "dbAdmin", "userAdmin"] })
show users
EOF
# Start the skyring server
systemctl enable skyringd
systemctl start skyringd
info "\n\n\n-------------------------------------------------------"
info "Now the host setup is ready!"
info "You can start the server by executing 'skyring'"
info "Skyring log directory: /var/log/skyring"
info "Influxdb user name: admin"
info "Influxdb password: admin"
info "Mongodb user name: admin"
info "Mongodb password: admin"
info "-------------------------------------------------------"
info "Done!"