-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun
More file actions
116 lines (85 loc) · 3.16 KB
/
Copy pathrun
File metadata and controls
116 lines (85 loc) · 3.16 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
#!/bin/sh
# set -x
DOCKER=`which docker`
if [ $? -ne 0 ]; then
echo "ERROR: Cannot fine Docker, please visit https://docs.docker.com/engine/installation" >&2
exit 1
fi
SUDO=`which sudo`
if [ $? -ne 0 ]; then
echo "ERROR: Cannot find sudo" >&2
exit 1
fi
CURL=`which curl`
if [ $? -ne 0 ]; then
WGET=`which wget`
if [ $? -ne 0 ]; then
echo "ERROR: Cannot find curl or wget" >&2
exit 1
fi
fi
GIT=`which git`
if [ $? -ne 0 ]; then
echo "ERROR: Cannot find git" >&2
exit 1
fi
INSTALLDIR=/usr/local
sudo -- sh -c "if [ ! -d /usr/local ] || [ ! -w /usr/local ]; then exit 1; fi"
if [ $? -ne 0 ]; then
sudo -- sh -c "if [ ! -d /opt ] || [ ! -w /opt ]; then exit 1; fi"
if [ $? -ne 0 ]; then
echo "ERROR: Cannot write to /usr/local or /opt"
exit 1
fi
INSTALLDIR=/opt
fi
DOCKER_COMPOSE=`which docker-compose`
if [ $? -ne 0 ]; then
DOCKER_COMPOSE=$INSTALLDIR/bin/docker-compose
if [ ! -f $DOCKER_COMPOSE ]; then
echo "Docker Compose does not exist, getting it"
sudo mkdir -p $INSTALLDIR/bin
if [ ! -z $CURL ]; then
$CURL -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` | sudo tee $DOCKER_COMPOSE > /dev/null
else
$WGET -O - https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` | sudo tee $DOCKER_COMPOSE > /dev/null
fi
sudo chmod +x $DOCKER_COMPOSE
fi
fi
# clone the repo to $INSTALLDIR/docker-uptime
if [ ! -d $INSTALLDIR/docker-uptime ]; then
echo "Cloning https://github.com/IFSight/uptime.git"
# seen some issues of minimal distros not being able to validate github cert
sudo GIT_SSL_NO_VERIFY=true $GIT clone https://github.com/IFSight/uptime.git $INSTALLDIR/docker-uptime
else
echo "Updating from https://github.com/IFSight/uptime.git"
cd $INSTALLDIR/docker-uptime
# some minimal Linux installs don't have the proper certs
sudo $GIT config --global http.sslVerify false
sudo $GIT pull
echo "Stopping and removing containers if they exist, then pulling"
sudo -- sh -c "INSTALLDIR=$INSTALLDIR $DOCKER_COMPOSE --file $INSTALLDIR/docker-uptime/docker-compose.yml stop"
sudo -- sh -c "INSTALLDIR=$INSTALLDIR $DOCKER_COMPOSE --file $INSTALLDIR/docker-uptime/docker-compose.yml rm -f"
sudo -- sh -c "INSTALLDIR=$INSTALLDIR $DOCKER_COMPOSE --file $INSTALLDIR/docker-uptime/docker-compose.yml pull"
fi
echo "Starting everything up"
sudo -- sh -c "INSTALLDIR=$INSTALLDIR $DOCKER_COMPOSE --file $INSTALLDIR/docker-uptime/docker-compose.yml up -d"
echo
echo
sudo -- sh -c "INSTALLDIR=$INSTALLDIR $DOCKER_COMPOSE --file $INSTALLDIR/docker-uptime/docker-compose.yml ps"
if [ ! -z $CURL ]; then
MYIP=$(curl -s -L raw.ip.ifsight.net)
else
MYIP=$(wget -q -O - raw.ip.ifsight.net)
fi
echo
echo "docker-uptime is now installed, visit the uptime web interface: http://uptime:givemestats@$MYIP:8082/"
echo
echo "NOTE: This is a default install, it is password protected"
echo " username: uptime"
echo " password: givemestats"
echo
echo "Configuration file: $INSTALLDIR/docker-uptime/production.yml"
echo
echo "Restart command: INSTALLDIR=$INSTALLDIR $DOCKER_COMPOSE --file $INSTALLDIR/docker-uptime/docker-compose.yml restart"