-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall
More file actions
215 lines (161 loc) · 4.95 KB
/
install
File metadata and controls
215 lines (161 loc) · 4.95 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
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
#!/bin/bash
#
#===========================================================
# CloudCone - Installer v2.0
#===========================================================
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
clear
LOG=/tmp/cloudcone.log
echo "--------------------------------------"
echo " Welcome to CloudCone Agent Installer"
echo "--------------------------------------"
echo " "
if [ $(id -u) != "0" ]; then
echo "CloudCone Agent installer needs to be installed with root priviliges"
echo "Try again with root privilileges"
exit 1;
fi
if [ $# -lt 1 ]; then
echo "The CloudCone server key is missing"
echo "Exiting installer"
exit 1;
fi
echo "Installing Dependencies"
if [ -n "$(command -v yum)" ]; then
yum -y install cronie gzip curl >> $LOG 2>&1
service crond start >> $LOG 2>&1
chkconfig crond on >> $LOG 2>&1
if ! type "perl" >> $LOG 2>&1; then
yum -y install perl >> $LOG 2>&1
fi
if ! type "unzip" >> $LOG 2>&1; then
yum -y install unzip >> $LOG 2>&1
fi
if ! type "curl" >> $LOG 2>&1; then
yum -y install curl >> $LOG 2>&1
fi
fi
if [ -n "$(command -v apt-get)" ]; then
apt-get update -y >> $LOG 2>&1
apt-get install -y cron curl gzip >> $LOG 2>&1
service cron start >> $LOG 2>&1
if ! type "perl" >> $LOG 2>&1; then
apt-get install -y perl >> $LOG 2>&1
fi
if ! type "unzip" >> $LOG 2>&1; then
apt-get install -y unzip >> $LOG 2>&1
fi
if ! type "curl" >> $LOG 2>&1; then
apt-get install -y curl >> $LOG 2>&1
fi
fi
if [ -n "$(command -v pacman)" ]; then
pacman -Sy >> $LOG 2>&1
pacman -S --noconfirm cronie curl gzip >> $LOG 2>&1
systemctl start cronie >> $LOG 2>&1
systemctl enable cronie >> $LOG 2>&1
if ! type "perl" >> $LOG 2>&1; then
pacman -S --noconfirm perl >> $LOG 2>&1
fi
if ! type "unzip" >> $LOG 2>&1; then
pacman -S --noconfirm unzip >> $LOG 2>&1
fi
if ! type "curl" >> $LOG 2>&1; then
pacman -S --noconfirm curl >> $LOG 2>&1
fi
fi
if [ -n "$(command -v zypper)" ]; then
zypper --non-interactive install cronie curl gzip >> $LOG 2>&1
service cron start >> $LOG 2>&1
if ! type "perl" >> $LOG 2>&1; then
zypper --non-interactive install perl >> $LOG 2>&1
fi
if ! type "unzip" >> $LOG 2>&1; then
zypper --non-interactive install unzip >> $LOG 2>&1
fi
if ! type "curl" >> $LOG 2>&1; then
zypper --non-interactive install curl >> $LOG 2>&1
fi
fi
if [ -n "$(command -v emerge)" ]; then
if ! type "crontab" >> $LOG 2>&1; then
emerge cronie >> $LOG 2>&1
/etc/init.d/cronie start >> $LOG 2>&1
rc-update add cronie default >> $LOG 2>&1
fi
if ! type "perl" >> $LOG 2>&1; then
emerge perl >> $LOG 2>&1
fi
if ! type "unzip" >> $LOG 2>&1; then
emerge unzip >> $LOG 2>&1
fi
if ! type "curl" >> $LOG 2>&1; then
emerge net-misc/curl >> $LOG 2>&1
fi
if ! type "gzip" >> $LOG 2>&1; then
emerge gzip >> $LOG 2>&1
fi
fi
if [ -f "/etc/slackware-version" ]; then
if [ -n "$(command -v slackpkg)" ]; then
if ! type "crontab" >> $LOG 2>&1; then
slackpkg -dialog=off -batch=on -default_answer=y install dcron >> $LOG 2>&1
fi
if ! type "perl" >> $LOG 2>&1; then
slackpkg -dialog=off -batch=on -default_answer=y install perl >> $LOG 2>&1
fi
if ! type "unzip" >> $LOG 2>&1; then
slackpkg -dialog=off -batch=on -default_answer=y install infozip >> $LOG 2>&1
fi
if ! type "curl" >> $LOG 2>&1; then
slackpkg -dialog=off -batch=on -default_answer=y install curl >> $LOG 2>&1
fi
if ! type "gzip" >> $LOG 2>&1; then
slackpkg -dialog=off -batch=on -default_answer=y install gzip >> $LOG 2>&1
fi
else
echo "Please install slackpkg and re-run installation."
exit 1;
fi
fi
if [ ! -n "$(command -v crontab)" ]; then
echo "Cron is required but we could not install it."
echo "Exiting installer"
exit 1;
fi
if [ ! -n "$(command -v curl)" ]; then
echo "CURL is required but we could not install it."
echo "Exiting installer"
exit 1;
fi
if [ -f /opt/cloudcone/agent.sh ]; then
# Remove folder
rm -rf /opt/cloudcone
# Remove crontab
crontab -r -u ccagent >> $LOG 2>&1
# Remove user
userdel ccagent >> $LOG 2>&1
fi
mkdir -p /opt/cloudcone >> $LOG 2>&1
wget --no-check-certificate -O /opt/cloudcone/agent.sh https://raw.githubusercontent.com/Cloudcone/cloud-view/master/agent.sh >> $LOG 2>&1
echo "$1" > /opt/cloudcone/serverkey
echo "http://watch.cloudc.one/agent" > /opt/cloudcone/gateway
if ! [ -f /opt/cloudcone/agent.sh ]; then
echo "Unable to install!"
echo "Exiting installer"
exit 1;
fi
useradd ccagent -r -d /opt/cloudcone -s /bin/false >> $LOG 2>&1
groupadd ccagent >> $LOG 2>&1
if [ -f /usr/sbin/cagefsctl ]; then
/usr/sbin/cagefsctl --disable ccagent >> $LOG 2>&1
fi
chown -R ccagent:ccagent /opt/cloudcone && chmod -R 700 /opt/cloudcone >> $LOG 2>&1
crontab -u ccagent -l 2>/dev/null | { cat; echo "* * * * * bash /opt/cloudcone/agent.sh > /opt/cloudcone/cron.log 2>&1"; } | crontab -u ccagent -
echo " "
echo "-------------------------------------"
echo " Installation Completed "
echo "-------------------------------------"
if [ -f $0 ]; then
rm -f $0
fi