-
Notifications
You must be signed in to change notification settings - Fork 6
/
bootstrap
executable file
·195 lines (167 loc) · 4.87 KB
/
bootstrap
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
#!/bin/sh
# Installs minikube, kubectl, and reactionetes into a minikube cluster
: ${R8S_DIR:=$HOME/.r8s}
: ${R8S_BIN:=$R8S_DIR/bin}
: ${VERBOSITY:=0}
# Check for config env file
if [ -e $R8S_DIR/env ]; then
source $R8S_DIR/env
if [ $VERBOSITY -gt '0' ]; then
ls -al $R8S_DIR/env
env file found and sourced
fi
fi
errror () {
echo "-------------------------------------------------------------"
echo -e "\n \n "
echo "ERROR!!! -- "
}
# Check if a command exists
check_cmd () {
if ! type "$1" > /dev/null; then
errror
echo "$1 was not found in your path!"
echo "To proceed please install $1 to your path and try again!"
exit 1
fi
}
warrrn () {
sleep 1
echo -n "(ctrl-c now to stop if this is not what you intend)!"
sleep 1; echo -n "!"; sleep 1; echo -n "!"
sleep 1; echo -n "!"
sleep 1; echo "!"
sleep 1; echo "--"
sleep 1
}
chkdir () {
if [ ! -w $1 ] ; then
sudo mkdir -p $1
sudo chown $USER. $1
fi
if [ ! -w $1 ] ; then
errror
echo "Cannot write to $1, please check your permissions"
exit 2
fi
}
# these vars are used by the following functions
LINE_TO_ADD=''
TARGET_FILE_FOR_ADD=~/.profile
check_if_line_exists()
{
echo "Checking for '$LINE_TO_ADD' in $TARGET_FILE_FOR_ADD"
grep -qsFx "$LINE_TO_ADD" $TARGET_FILE_FOR_ADD
}
add_line_to()
{
echo "Adding '$LINE_TO_ADD' to $TARGET_FILE_FOR_ADD"
TARGET_FILE=$TARGET_FILE_FOR_ADD
[ -w "$TARGET_FILE" ] || TARGET_FILE=$TARGET_FILE_FOR_ADD
printf "%s\n" "$LINE_TO_ADD" >> "$TARGET_FILE"
}
# taking some cues directly from the meteor install script
# We wrap this whole script in a function, so that we won't execute
# until the entire script is downloaded.
# That's good because it prevents our output overlapping with curl's.
# It also means that we can't run a partially downloaded script.
# We don't indent because it would be really confusing with the heredocs.
run_it () {
# Now, on to the actual installer!
## NOTE sh NOT bash. This script should be POSIX sh only, since we don't
## know what shell the user has. Debian uses 'dash' for 'sh', for
## example.
set -e
set -u
# Let's display everything on stderr.
exec 1>&2
UNAME=$(uname)
# Check to see if it starts with MINGW.
if [ "$UNAME" = "CYGWIN_NT-10.0" ] ; then
check_cmd choco
check_cmd helm
PLATFORM="os.cygwin.x86_64"
echo "WARNING: Cygwin is not supported for this installer at this time!"
exit 1
fi
if [ "$UNAME" == "Linux" -o "$UNAME" == "Darwin" ] ; then
echo " $UNAME is a Supported OS"
elif [ "$UNAME" ">" "MINGW" -a "$UNAME" "<" "MINGX" ] ; then
echo " $UNAME is a Supported OS"
else
echo " $UNAME is not a Supported OS"
echo "Sorry, this OS is not supported yet via this installer."
exit 1
fi
if [ "$UNAME" ">" "MINGW" -a "$UNAME" "<" "MINGX" ] ; then
check_cmd choco
check_cmd helm
PLATFORM="os.windows.x86_64"
echo "WARNING: Windows is experimental for this installer at this time!"
fi
if [ "$UNAME" = "Darwin" ] ; then
check_cmd brew
### OSX ###
if [ "i386" != "$(uname -p)" -o "1" != "$(sysctl -n hw.cpu64bit_capable 2>/dev/null || echo 0)" ] ; then
# Can't just test uname -m = x86_64, because Snow Leopard can
# return other values.
echo "Only 64-bit Intel processors are supported at this time in OSX."
exit 1
fi
PLATFORM="os.osx.x86_64"
echo "WARNING: OSX is experimental for this installer at this time!"
elif [ "$UNAME" = "Linux" ] ; then
### Linux ###
LINUX_ARCH=$(uname -m)
if [ "${LINUX_ARCH}" = "x86_64" ] ; then
PLATFORM="os.linux.x86_64"
else
echo "Unusable architecture: ${LINUX_ARCH}"
echo "Reactionetes only supports x86_64 for now."
exit 1
fi
fi
echo "Warning!"
sleep 1
echo -e "This script will install minikube, kubectl and helm,
and then install reactionetes into the local minikube cluster.
This is not for production use, but the elements within can be adapted for such.
\nDISCLAIMER: This software is highly experimental!
It can set fire to your computer, and might possibly open an interdimensional portal of unknown origin.
\nYou are responsible for what comes through the portal.
\nSoftware bugs should be noted in a github issue at https://github.com/joshuacox/reactionetes/issues"
warrrn
TMP_DIR=$(mktemp -d --suffix='.reactionetes')
cd $TMP_DIR
echo 'Cloning the latest reactionetes repo'
git clone --depth 1 https://github.com/joshuacox/reactionetes.git
cd reactionetes
make run_dotfiles
# make reqs
if [ "$PLATFORM" = "os.linux.x86_64" ] ; then
make linuxreqs
elif [ "$PLATFORM" = "os.osx.x86_64" ] ; then
make osxreqs
elif [ "$PLATFORM" = "os.windows.x86_64" ] ; then
make windowsreqs
fi
check_cmd helm
check_cmd kubectl
check_cmd minikube
check_cmd nsenter
make -e autopilot
cd
rm -Rf $TMP_DIR
trap - EXIT
# End run it wrapper
}
chkdir /etc/kubernetes
chkdir /var/lib/localkube
chkdir /var/lib/localkube/certs
check_cmd make
check_cmd mktemp
check_cmd git
check_cmd curl
check_cmd uname
check_cmd socat
run_it