|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
scheme="$1"
|
|
|
|
|
|
|
|
retry() {
|
|
|
|
retries=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
count=0
|
|
|
|
until "$@"; do
|
|
|
|
exit=$?
|
|
|
|
wait="$(echo "2^$count" | bc)"
|
|
|
|
count="$(echo "$count + 1" | bc)"
|
|
|
|
if [ "$count" -lt "$retries" ]; then
|
|
|
|
echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
|
|
|
|
sleep "$wait"
|
|
|
|
else
|
|
|
|
echo "Retry $count/$retries exited $exit, no more retries left."
|
|
|
|
return "$exit"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# --------custom repos -------
|
|
|
|
# alpine edit 4 ubuntu
|
|
|
|
#cp /root/repositories /etc/apk/repositories
|
|
|
|
|
|
|
|
echo "==> Install system packages"
|
|
|
|
apk --no-cache add \
|
|
|
|
bash \
|
|
|
|
gnupg \
|
|
|
|
tar \
|
|
|
|
wget \
|
|
|
|
make \
|
|
|
|
xz \
|
|
|
|
git \
|
|
|
|
flex \
|
|
|
|
bison \
|
|
|
|
tcptraceroute \
|
|
|
|
curl \
|
|
|
|
lynx \
|
|
|
|
|
|
|
|
&& apk add --virtual .build-dependencies \
|
|
|
|
build-base \
|
|
|
|
ruby-dev \
|
|
|
|
libressl-dev \
|
|
|
|
&& gem install bundler || apk add ruby-bundler \
|
|
|
|
&& bundle config build.nokogiri --use-system-libraries \
|
|
|
|
&& bundle config git.allow_insecure true \
|
|
|
|
&& gem install json \
|
|
|
|
\
|
|
|
|
&& gem cleanup \
|
|
|
|
&& apk del .build-dependencies \
|
|
|
|
&& rm -rf /usr/lib/ruby/gems/*/cache/* \
|
|
|
|
/var/cache/apk/* \
|
|
|
|
/tmp/* \
|
|
|
|
/var/tmp/*
|
|
|
|
|
|
|
|
|
|
|
|
extrap=/root/extrapackages
|
|
|
|
if [ -f $extrap ]; then
|
|
|
|
|
|
|
|
while read -r line; do
|
|
|
|
extrapackages="$extrapackages $line"
|
|
|
|
done < $extrap
|
|
|
|
|
|
|
|
apk --no-cache add $extrapackages
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "No extrapackages file"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "==> Install pm2"
|
|
|
|
|
|
|
|
npm install pm2@latest -g
|
|
|
|
|
|
|
|
echo "==> create dir"
|
|
|
|
mkdir -p /var/log-in
|
|
|
|
mkdir -p /home/docker/.gem
|
|
|
|
mkdir -p /fluentd/etc
|
|
|
|
mkdir -p /fluentd/plugins
|
|
|
|
|
|
|
|
chown -R node.node /var/log-in
|
|
|
|
chown -R node.node /home/docker/.gem
|
|
|
|
chown -R node.node /fluentd/etc
|
|
|
|
chown -R node.node /fluentd/plugins
|
|
|
|
|
|
|
|
|
|
|
|
echo "==> Clean up"
|
|
|
|
rm -rf \
|
|
|
|
/root/.gnupg \
|
|
|
|
/setup.sh \
|
|
|
|
/extrapackages
|