mirror of https://github.com/k3s-io/k3s
80 lines
2.6 KiB
Plaintext
80 lines
2.6 KiB
Plaintext
|
#!/bin/bash
|
||
|
set -ve
|
||
|
|
||
|
|
||
|
echo "Installing go $goversion"
|
||
|
curl -sL https://storage.googleapis.com/golang/go${goversion}.linux-${ARCH}.tar.gz | tar -xzf - -C /usr/local
|
||
|
# ---
|
||
|
cat <<EOF >/etc/profile.d/build.sh
|
||
|
export SELINUX=true
|
||
|
# export DQLITE=true
|
||
|
# export STATIC_BUILD=true
|
||
|
EOF
|
||
|
. /etc/profile.d/build.sh
|
||
|
# ---
|
||
|
sed -i 's|:/bin/ash$|:/bin/bash|g' /etc/passwd
|
||
|
cat <<EOF >/etc/profile.d/color.sh
|
||
|
alias ls='ls --color=auto'
|
||
|
export PS1='\033[31m[ \033[90m\D{%F %T}\033[31m ] \033[35m{\033[90m$OS\033[35m}\n\[\033[36m\]\u\[\033[m\]🐮\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ '
|
||
|
EOF
|
||
|
# ---
|
||
|
DQLITE_URL="https://github.com/$(grep dqlite-build Dockerfile.dapper | sed -e 's/^.*--from=\([^ ]*\).*$/\1/' -e 's|:|/releases/download/|')/dqlite-$ARCH.tgz"
|
||
|
echo "Downloading DQLITE from $DQLITE_URL"
|
||
|
mkdir -p /usr/src/
|
||
|
curl -sfL $DQLITE_URL -o /usr/src/dqlite.tgz
|
||
|
# ---
|
||
|
mkdir -p ${GOPATH}/bin
|
||
|
mkdir -p /go
|
||
|
ln -s $GOPATH/bin /go/bin
|
||
|
sed ':a;N;$!ba;s/\\\n/ /g' <Dockerfile.dapper | grep '^RUN ' | sed -e 's/^RUN //' >/tmp/docker-run
|
||
|
sed -E 's|apk( -U)?( --no-cache)?( --repository [^ ]*)? add( --allow-untrusted)?|yum install -y|g' -i /tmp/docker-run
|
||
|
sed -E 's/-dev/-devel/g' -i /tmp/docker-run
|
||
|
export BINDIR=/go/bin
|
||
|
export GOPATH=/go
|
||
|
export HOME=/tmp
|
||
|
( set +e && . /tmp/docker-run ) || true
|
||
|
# ---
|
||
|
go get -u github.com/go-delve/delve/cmd/dlv
|
||
|
# ---
|
||
|
# docker install instructions slightly changed from https://kubernetes.io/docs/setup/production-environment/container-runtimes/
|
||
|
# default "exec-opts": ["native.cgroupdriver=cgroupfs"], and set "selinux-enabled": true
|
||
|
yum remove -y docker docker-common
|
||
|
yum install -y yum-utils device-mapper-persistent-data lvm2
|
||
|
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||
|
yum update -y && yum install -y containerd.io-1.2.10 docker-ce-19.03.4 docker-ce-cli-19.03.4
|
||
|
mkdir -p /etc/docker
|
||
|
cat > /etc/docker/daemon.json <<EOF
|
||
|
{
|
||
|
"log-driver": "json-file",
|
||
|
"log-opts": {
|
||
|
"max-size": "100m"
|
||
|
},
|
||
|
"selinux-enabled": true,
|
||
|
"storage-driver": "overlay2",
|
||
|
"storage-opts": [
|
||
|
"overlay2.override_kernel_check=true"
|
||
|
]
|
||
|
}
|
||
|
EOF
|
||
|
# ---
|
||
|
systemctl daemon-reload
|
||
|
systemctl disable --now firewalld
|
||
|
systemctl disable --now docker
|
||
|
# ---
|
||
|
# set selinux to permissive for dev & testing purposes only
|
||
|
setenforce 0
|
||
|
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
|
||
|
# ---
|
||
|
cat <<\EOF >>/etc/motd
|
||
|
, ,
|
||
|
,-----------|'------'| |\ ____
|
||
|
/. '-'@ o|-' | | /___ \
|
||
|
|/| | .. | | | __ __) | ____
|
||
|
| .________.'----' | |/ /|__ < / __/
|
||
|
| || | || | < ___) |\__ \
|
||
|
\__|' \__|' |_|\_\_____/____/
|
||
|
|
||
|
EOF
|
||
|
# ---
|
||
|
set +v
|