-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·175 lines (156 loc) · 4.52 KB
/
install.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
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
#!/bin/bash
# Cloud Child Node Server Setup
# Installation script for Ubuntu
# @author Muhammad Dadu
export DEBIAN_FRONTEND=noninteractive
export PORJECT_NAME="Clout - Cloud Technology"
export INSTALL_DIR="/usr/local/lib/"
export PACKAGE_NAME="clout-services-child"
export PACKAGE_REPO="https://github.com/clout-stack/clout-services-child"
echo "------------------------------------------------"
echo "------------------------------------------------"
echo " " $PORJECT_NAME "Server Setup"
echo "------------------------------------------------"
echo "------------------------------------------------"
echo ""
echo "Checking server state..."
# load functions
source ./functions.sh
echo "NodeJS: $(echo_if $(is_installed node))"
echo "Docker: $(echo_if $(is_installed docker))"
echo "SQLite3: $(echo_if $(is_installed sqlite3))"
# echo "Redis: $(echo_if $(is_installed redis-server))"
# echo "MySQL: $(echo_if $(is_installed mysql))"
# echo "Nginx: $(echo_if $(is_installed nginx))"
echo "initd-forever: $(echo_if $(is_installed initd-forever))"
echo ""
if [ -e $INSTALL_DIR""$PACKAGE_NAME ];
then
echo $PORJECT_NAME "provisioning already completed. Skipping..."
exit 0
else
echo "Installation Starting..."
fi
##
# Core Componenets
##
echo "Updating/Installing Core Componenets..."
apt-get update > /dev/null
# Install build tools
apt-get install -y make g++ git curl vim libcairo2-dev libav-tools nfs-common portmap software-properties-common > /dev/null
echo "Updated/Installed!"
##
# NodeJS installation
##
if [ $(is_installed node) == 1 ];
then
echo "Skipping NodeJS installation"
else
echo "Installing NodeJS..."
# Modified from https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
apt-get install -y python-software-properties python g++ make > /dev/null
add-apt-repository -y ppa:chris-lea/node.js > /dev/null
apt-get update > /dev/null
apt-get install -y nodejs > /dev/null
# apt-get install npm > /dev/null # PI
npm install n -g > /dev/null # node package manager
# n 0.12 > /dev/null # install node 0.12
n 5.0 > /dev/null # PI
echo "Installed!"
fi
##
# Docker installation
##
if [ $(is_installed docker) == 1 ];
then
echo "Skipping Docker installation"
else
echo "Installing Docker..."
# Update Kernal
# http://blog.hypriot.com/post/run-docker-rpi3-with-wifi/ # PI
apt-get install -y linux-image-generic-lts-vivid linux-headers-generic-lts-vivid > /dev/null
curl https://get.docker.com/ | sh > /dev/null
echo "Installed!"
fi
##
# sqlite3 Installation
##
if [ $(is_installed sqlite3) == 1 ];
then
echo "Skipping SQLite3 installation"
else
sudo apt-get install sqlite3 libsqlite3-dev -y
echo "Installed!"
fi
# ##
# # Redis Server
# ##
# if [ $(is_installed redis-server) == 1 ];
# then
# echo "Skipping Redis installation"
# else
# echo "Installing Redis..."
# add-apt-repository -y ppa:chris-lea/redis-server > /dev/null
# apt-get update > /dev/null
# apt-get install -y redis-server > /dev/null
# echo "Installed!"
# fi
# ##
# # MySQL Server
# ##
# if [ $(is_installed mysql) == 1 ];
# then
# echo "Skipping MySQL installation"
# else
# echo "Installing MySQL..."
# # Install unattended
# sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password '$DEFAULT_PASSWORD''
# sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password '$DEFAULT_PASSWORD''
# apt-get install -y mysql-server > /dev/null
# echo "Installed!"
# fi
# ##
# # Nginx
# ##
# if [ $(is_installed nginx) == 1 ];
# then
# echo "Skipping Nginx installation"
# else
# echo "Installing Nginx..."
# # Install unattended
# apt-get install -y nginx > /dev/null
# echo "Installed!"
# fi
# service nginx restart > /dev/null # restart nginx
##
# initd-forever
##
if [ $(is_installed initd-forever) == 1 ];
then
echo "Skipping initd-forever installation"
else
echo "Installing initd-forever..."
npm install -g initd-forever forever > /dev/null
echo "Installed!"
fi
##
# clout-services-child
##
cd $INSTALL_DIR
git clone $PACKAGE_REPO
cd $PACKAGE_NAME
npm install
mkdir logs && chmod 777 logs
# Create database
cd db && sqlite3 ./default.db .databases
# Link Service
echo "$PACKAGE_NAME: Link Service"
initd-forever --app $INSTALL_DIR""$PACKAGE_NAME --name $PACKAGE_NAME --env development
chmod +x $PACKAGE_NAME
mv $PACKAGE_NAME /etc/init.d/$PACKAGE_NAME
cd /etc/init.d/ && update-rc.d $PACKAGE_NAME defaults
service $PACKAGE_NAME start
echo ""
echo "------------------------------------------------"
echo "Server is connected @" $(hostname -I)
echo "------------------------------------------------"