mirror of https://github.com/k3s-io/k3s
Cleanup vagrant provision scripts
parent
4b84b1f8b4
commit
89fa8afaa3
|
@ -12,24 +12,9 @@ export STATIC_BUILD=true
|
||||||
EOF
|
EOF
|
||||||
. /etc/profile.d/build.sh
|
. /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"
|
echo "Downloading DQLITE from $DQLITE_URL"
|
||||||
mkdir -p /usr/src/
|
|
||||||
curl -sfL $DQLITE_URL -o /usr/src/dqlite.tgz
|
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
|
|
||||||
export BINDIR=/go/bin
|
|
||||||
export GOPATH=/go
|
|
||||||
export HOME=/tmp
|
|
||||||
. /tmp/docker-run
|
. /tmp/docker-run
|
||||||
# ---
|
# ---
|
||||||
go get -u github.com/go-delve/delve/cmd/dlv
|
go get -u github.com/go-delve/delve/cmd/dlv
|
||||||
|
@ -39,21 +24,11 @@ export DOCKER_HOST=tcp://10.0.2.2:2375
|
||||||
EOF
|
EOF
|
||||||
. /etc/profile.d/docker.sh
|
. /etc/profile.d/docker.sh
|
||||||
# ---
|
# ---
|
||||||
cat <<\EOF >>/etc/motd
|
(
|
||||||
, ,
|
if ! docker version --format '{{.Server.Version}}' >/tmp/docker-server-version; then
|
||||||
,-----------|'------'| |\ ____
|
|
||||||
/. '-'@ o|-' | | /___ \
|
|
||||||
|/| | .. | | | __ __) | ____
|
|
||||||
| .________.'----' | |/ /|__ < / __/
|
|
||||||
| || | || | < ___) |\__ \
|
|
||||||
\__|' \__|' |_|\_\_____/____/
|
|
||||||
|
|
||||||
EOF
|
|
||||||
# ---
|
|
||||||
set +v
|
|
||||||
if ! docker version --format '{{.Server.Version}}' >/tmp/docker-server-version; then
|
|
||||||
echo "WARNING: Unable to connect to the docker socket, to enable docker in vagrant run the following command on the host:"
|
echo "WARNING: Unable to connect to the docker socket, to enable docker in vagrant run the following command on the host:"
|
||||||
echo "docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 alpine/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock"
|
echo "docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 alpine/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock"
|
||||||
else
|
else
|
||||||
echo "Using host docker server v$(cat /tmp/docker-server-version)"
|
echo "Using host docker server v$(cat /tmp/docker-server-version)"
|
||||||
fi
|
fi
|
||||||
|
)
|
|
@ -12,27 +12,9 @@ export SELINUX=true
|
||||||
EOF
|
EOF
|
||||||
. /etc/profile.d/build.sh
|
. /etc/profile.d/build.sh
|
||||||
# ---
|
# ---
|
||||||
sed -i 's|:/bin/ash$|:/bin/bash|g' /etc/passwd
|
sed -E 's|apk( -U)?( --no-cache)?( --repository [^ ]*)? add|yum install -y|g' -i /tmp/docker-run
|
||||||
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
|
sed -E 's/-dev/-devel/g' -i /tmp/docker-run
|
||||||
export BINDIR=/go/bin
|
. /tmp/docker-run
|
||||||
export GOPATH=/go
|
|
||||||
export HOME=/tmp
|
|
||||||
( set +e && . /tmp/docker-run ) || true
|
|
||||||
# ---
|
# ---
|
||||||
go get -u github.com/go-delve/delve/cmd/dlv
|
go get -u github.com/go-delve/delve/cmd/dlv
|
||||||
# ---
|
# ---
|
||||||
|
@ -64,16 +46,3 @@ systemctl disable --now docker
|
||||||
# set selinux to permissive for dev & testing purposes only
|
# set selinux to permissive for dev & testing purposes only
|
||||||
setenforce 0
|
setenforce 0
|
||||||
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
|
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
|
||||||
# ---
|
|
||||||
cat <<\EOF >>/etc/motd
|
|
||||||
, ,
|
|
||||||
,-----------|'------'| |\ ____
|
|
||||||
/. '-'@ o|-' | | /___ \
|
|
||||||
|/| | .. | | | __ __) | ____
|
|
||||||
| .________.'----' | |/ /|__ < / __/
|
|
||||||
| || | || | < ___) |\__ \
|
|
||||||
\__|' \__|' |_|\_\_____/____/
|
|
||||||
|
|
||||||
EOF
|
|
||||||
# ---
|
|
||||||
set +v
|
|
||||||
|
|
|
@ -14,21 +14,14 @@ if [[ $HOME == /go/* ]]; then
|
||||||
echo "Must not launch vagrant from /go/"
|
echo "Must not launch vagrant from /go/"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
cd
|
||||||
|
|
||||||
# --- Default to root user for vagrant ssh
|
# --- Default to root user for vagrant ssh
|
||||||
cat <<\EOF >/etc/profile.d/root.sh
|
cat <<\EOF >/etc/profile.d/root.sh
|
||||||
[ $EUID -ne 0 ] && exec sudo -i
|
[ $EUID -ne 0 ] && exec sudo -i
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# --- Setup basic env
|
# --- Setup go version
|
||||||
cat <<EOF >/etc/profile.d/env.sh
|
|
||||||
export GO111MODULE=off
|
|
||||||
export GOPATH="$GOPATH"
|
|
||||||
export PATH=/usr/local/bin:$PATH:/usr/local/go/bin:$GOPATH/bin
|
|
||||||
export HOME="$HOME" && cd
|
|
||||||
EOF
|
|
||||||
. /etc/profile.d/env.sh
|
|
||||||
|
|
||||||
if [ -z "${GOPATH}" ]; then
|
if [ -z "${GOPATH}" ]; then
|
||||||
GOPATH=$(realpath $HOME/../../../..)
|
GOPATH=$(realpath $HOME/../../../..)
|
||||||
echo "WARNING: Assuming GOPATH=$GOPATH"
|
echo "WARNING: Assuming GOPATH=$GOPATH"
|
||||||
|
@ -42,9 +35,50 @@ if [ -z "$goversion" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# clean go cache
|
# --- Setup basic env
|
||||||
|
cat <<EOF >/etc/profile.d/env.sh
|
||||||
|
export GO111MODULE=off
|
||||||
|
export GOPATH="$GOPATH"
|
||||||
|
export PATH=/usr/local/bin:$PATH:/usr/local/go/bin:$GOPATH/bin
|
||||||
|
export HOME="$HOME" && cd
|
||||||
|
EOF
|
||||||
|
. /etc/profile.d/env.sh
|
||||||
|
|
||||||
|
# --- Setup for dqlite download
|
||||||
|
DQLITE_URL="https://github.com/$(grep dqlite-build Dockerfile.dapper | sed -e 's/^.*--from=\([^ ]*\).*$/\1/' -e 's|:|/releases/download/|')/dqlite-$ARCH.tgz"
|
||||||
|
mkdir -p /usr/src/
|
||||||
|
|
||||||
|
# --- Clean go cache
|
||||||
rm -rf .cache/go-build || true
|
rm -rf .cache/go-build || true
|
||||||
|
|
||||||
|
# --- Set color prompt
|
||||||
|
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
|
||||||
|
|
||||||
|
# --- Setup install script from docker run commands
|
||||||
|
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
|
||||||
|
export BINDIR=/go/bin
|
||||||
|
export GOPATH=/go
|
||||||
|
export HOME=/tmp
|
||||||
|
|
||||||
|
# --- Add k3s motd
|
||||||
|
cat <<\EOF >/etc/motd
|
||||||
|
, ,
|
||||||
|
,-----------|'------'| |\ ____
|
||||||
|
/. '-'@ o|-' | | /___ \
|
||||||
|
|/| | .. | | | __ __) | ____
|
||||||
|
| .________.'----' | |/ /|__ < / __/
|
||||||
|
| || | || | < ___) |\__ \
|
||||||
|
\__|' \__|' |_|\_\_____/____/
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
# --- Run vagrant provision script if available
|
# --- Run vagrant provision script if available
|
||||||
if [ ! -f "${PROVISION}" ]; then
|
if [ ! -f "${PROVISION}" ]; then
|
||||||
echo 'WARNING: Unable to execute provision script "${PROVISION}"'
|
echo 'WARNING: Unable to execute provision script "${PROVISION}"'
|
||||||
|
|
Loading…
Reference in New Issue