-
Notifications
You must be signed in to change notification settings - Fork 7
/
installer
executable file
·77 lines (61 loc) · 1.93 KB
/
installer
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
#!/bin/bash
#
# Description: CloudStats Monitoring installer script
#
#
# installation folder
install_dir="/home/cloudstats_agent"
echo "CloudStats agent will be installed in: " $install_dir
if [ -x "$install_dir/cloudstats.py" ]; then
echo "Removing the old agent"
sed -i '/cloudstats/d' /etc/crontab &> /dev/null
killall -13 -r 'cloudstats' 2>/dev/null
rm -rf $install_dir
fi
if [ -x "/etc/init.d/cloudstats-agent" ]; then
echo "Stopping the agent"
/etc/init.d/cloudstats-agent stop
fi
echo "Attempting to install necessary package: tar gzip sysstat iproute2 net-tools"
if [ -e /etc/debian_version ]
then
apt-get update > /dev/null
apt-get install tar gzip sysstat net-tools procps -y > /dev/null
fi
if [ -e /etc/redhat-release ]
then
yum install tar gzip sysstat net-tools procps -y > /dev/null
fi
mkdir -p $install_dir
cd $install_dir
# downloading the package based on arch
archs=`uname -m`
echo "Downloading ... "
if [ ${archs} = 'x86_64' ]; then
curl -L -O --fail 'https://cloudstatsstorage.blob.core.windows.net/agent/cloudstats-agent-latest-linux-x86_64.tar.gz'
else
archs='x86'
curl -L -O --fail 'https://cloudstatsstorage.blob.core.windows.net/agent/cloudstats-agent-latest-linux-x86.tar.gz'
fi
# extracting and placing the files in the right location
echo "Extracting ... "
tar zxvf cloudstats-agent-latest-linux-$archs.tar.gz --strip-components 1 >/dev/null
cp init.d/cloudstats-agent /etc/init.d/
rm -rf cloudstats-agent-latest-linux-$archs.tar.gz
# set permissions and auto start at boot
echo "Installing ... "
chmod 755 /etc/init.d/cloudstats-agent
if [ -e /etc/debian_version ]
then
update-rc.d -f cloudstats-agent defaults > /dev/null
fi
if [ -e /etc/redhat-release ]
then
chkconfig cloudstats-agent on
fi
echo "Setting up the account key"
./cloudstats-agent --setup "$@"
/etc/init.d/cloudstats-agent start
echo "Installation finished."
echo "Running for the first time"
./cloudstats-agent --first-time