-
Notifications
You must be signed in to change notification settings - Fork 97
/
install.sh
86 lines (67 loc) · 1.86 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
#!/bin/bash
set -e
: ${BINARY_NAME:="c3os"}
: ${INSTALL_DIR:="/usr/local/bin"}
: ${USE_SUDO:="true"}
: ${INSTALL_K3S:="true"}
: ${INSTALL_EDGEVPN:="true"}
: ${DOWNLOADER:="curl"}
install_k3s() {
export INSTALL_K3S_VERSION=${K3S_VERSION}
export INSTALL_K3S_BIN_DIR="/usr/bin"
export INSTALL_K3S_SKIP_START="true"
export INSTALL_K3S_SKIP_ENABLE="true"
curl -sfL https://get.k3s.io | sh -
}
c3os_github_version() {
set +e
curl -s https://api.github.com/repos/mudler/c3os/releases/latest | \
grep tag_name | \
awk '{ print $2 }' | \
sed -e 's/\"//g' -e 's/,//g' || echo "v0.8.5"
set -e
}
install_edgevpn() {
curl -sfL https://raw.githubusercontent.com/mudler/edgevpn/master/install.sh | sh -
}
download() {
[ $# -eq 2 ] || fatal 'download needs exactly 2 arguments'
case $DOWNLOADER in
curl)
curl -o $1 -sfL $2
;;
wget)
wget -qO $1 $2
;;
*)
fatal "Incorrect executable '$DOWNLOADER'"
;;
esac
# Abort if download command failed
[ $? -eq 0 ] || fatal 'Download failed'
}
SUDO=sudo
if [ $(id -u) -eq 0 ]; then
SUDO=
fi
c3os_version="${C3OS_VERSION:-$(c3os_github_version)}"
echo "Downloading c3os $c3os_version"
if [ "${INSTALL_EDGEVPN}" == "true" ]; then
install_edgevpn
fi
if [ "${INSTALL_K3S}" == "true" ]; then
install_k3s
fi
TMP_DIR=$(mktemp -d -t c3os-install.XXXXXXXXXX)
download $TMP_DIR/out.tar.gz https://github.com/c3os-io/c3os/releases/download/$c3os_version/c3os-$c3os_version-Linux-x86_64.tar.gz
# TODO verify w/ checksum
tar xvf $TMP_DIR/out.tar.gz -C $TMP_DIR
$SUDO cp -rf $TMP_DIR/c3os $INSTALL_DIR/
# TODO trap
rm -rf $TMP_DIR
if [ ! -d "/etc/systemd/system.conf.d/" ]; then
$SUDO mkdir -p /etc/systemd/system.conf.d
fi
if [ ! -d "/etc/sysconfig" ]; then
$SUDO mkdir -p /etc/sysconfig
fi