forked from buildkite/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·135 lines (103 loc) · 3.74 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
#!/bin/bash
#
# You can install the Buildbox Agent with the following:
#
# bash -c "`curl -sL https://raw.github.com/buildboxhq/buildbox-agent/master/install.sh`"
#
# For more information, see: https://github.com/buildboxhq/buildbox-agent
COMMAND="bash -c \"\`curl -sL https://raw.github.com/buildboxhq/buildbox-agent/master/install.sh\`\""
VERSION="0.1"
set -e
echo -e "\033[33m
_ _ _ _ _ _
| | (_) | | | | | |
| |__ _ _ _| | __| | |__ _____ __ __ _ __ _ ___ _ __ | |_
| '_ \| | | | | |/ _\` | '_ \ / _ \ \/ / / _\` |/ _\` |/ _ \ '_ \| __|
| |_) | |_| | | | (_| | |_) | (_) > < | (_| | (_| | __/ | | | |_
|_.__/ \__,_|_|_|\__,_|_.__/ \___/_/\_\ \__,_|\__, |\___|_| |_|\__|
__/ |
|___/\033[0m
-- https://buildbox.io
Latest Version: \033[35mv$VERSION\033[0m"
UNAME=`uname -sp | awk '{print tolower($0)}'`
if [[ ($UNAME == *"mac os x"*) || ($UNAME == *darwin*) ]]
then
PLATFORM="darwin"
else
PLATFORM="linux"
fi
if [[ ($UNAME == *x86_64*) || ($UNAME == *amd64*) ]]
then
ARCH="amd64"
else
ARCH="386"
fi
# Allow custom setting of the destination
if [ -z "$DESTINATION" ]; then
# But default to the home directory
DESTINATION="$HOME/.buildbox"
mkdir -p $DESTINATION
fi
if [ ! -w "$DESTINATION" ]
then
echo -e "\n\033[31mUnable to write to destination \`$DESTINATION\`\n\nYou can change the destination by running:\n\nDESTINATION=/my/path $COMMAND\033[0m\n"
exit 1
fi
echo -e "Destination: \033[35m$DESTINATION\033[0m"
# Download and unzip the file to the destination
DOWNLOAD="buildbox-agent-$PLATFORM-$ARCH.tar.gz"
URL="https://github.com/buildboxhq/buildbox-agent/releases/download/v$VERSION/$DOWNLOAD"
echo -e "\nDownloading $URL"
# Remove the download if it already exists
rm -f $DESTINATION/$DOWNLOAD
# If the file already exists in a folder called pkg, just use that. :)
if [[ -e pkg/$DOWNLOAD ]]
then
cp pkg/$DOWNLOAD $DESTINATION/$DOWNLOAD
else
# Boo, we don't have it. Download the file then.
if command -v wget >/dev/null
then
wget -q $URL -O $DESTINATION/$DOWNLOAD
else
curl -L -s -o $DESTINATION/$DOWNLOAD $URL
fi
fi
# Extract the download to the destination folder
tar -C $DESTINATION -zxf $DESTINATION/$DOWNLOAD
# Make sure it's exectuable
chmod +x $DESTINATION/buildbox-agent
chmod +x $DESTINATION/buildbox-artifact
# Clean up the download
rm -f $DESTINATION/$DOWNLOAD
# Copy the bootstrap sample and make sure it's writable
if [[ -e $DESTINATION/bootstrap.sh ]]
then
echo -e "\n\033[34mSkipping bootstrap.sh installation as it already exists\033[0m"
else
BOOTSTRAP_URL=https://raw.github.com/buildboxhq/buildbox-agent/master/templates/bootstrap.sh
BOOTSTRAP_DESTINATION=$DESTINATION/bootstrap.sh
echo -e "Downloading $BOOTSTRAP_URL"
if command -v wget >/dev/null
then
wget -q $BOOTSTRAP_URL -O $BOOTSTRAP_DESTINATION
else
curl -L -s -o $BOOTSTRAP_DESTINATION $BOOTSTRAP_URL
fi
chmod +x $DESTINATION/bootstrap.sh
fi
echo -e "\n\033[32mSuccessfully installed to $DESTINATION\033[0m
You can now run the Buildbox agent like so:
$DESTINATION/buildbox-agent start --access-token token123
You can find your agent's Access Token on your Account Settings
page under \"Agents\".
To customize how builds are run on your server, you can edit:
$DESTINATION/bootstrap.sh
This file is run for every build and it's responsible for checking out
the source code and running the build script.
The source code of the agent is available here:
https://github.com/buildboxhq/buildbox-agent
If you have any questions or need a help getting things setup,
please email us at: [email protected]
Happy Building!
<3 Buildbox"