refactor: setup, add debian support

This commit is contained in:
Elton Renda 2022-01-16 19:27:05 +02:00
parent 67cf40d623
commit c1a8541394
2 changed files with 18 additions and 7 deletions

View File

@ -2,6 +2,9 @@
set -euo pipefail
trap trapexit EXIT SIGTERM
DISTRO_ID=$(cat /etc/*-release | grep -w ID | cut -d= -f2 | tr -d '"')
DISTRO_CODENAME=$(cat /etc/*-release | grep -w VERSION_CODENAME | cut -d= -f2 | tr -d '"')
TEMPDIR=$(mktemp -d)
TEMPLOG="$TEMPDIR/tmplog"
TEMPERR="$TEMPDIR/tmperr"
@ -68,7 +71,7 @@ fi
log "Installing dependencies"
runcmd apt-get update
export DEBIAN_FRONTEND=noninteractive
runcmd 'sudo apt-get install -y --no-install-recommends $DEVDEPS gnupg openssl ca-certificates apache2-utils logrotate'
runcmd 'apt-get install -y --no-install-recommends $DEVDEPS gnupg openssl ca-certificates apache2-utils logrotate'
# Install Python
log "Installing python"
@ -86,9 +89,12 @@ runcmd pip install --no-cache-dir cffi certbot
# Install openresty
log "Installing openresty"
wget -qO - https://openresty.org/package/pubkey.gpg | apt-key add -
_distro_release=$(lsb_release -sc)
_distro_release=$(wget $WGETOPT "http://openresty.org/package/ubuntu/dists/" -O - | grep -o "$_distro_release" | head -n1 || true)
echo "deb [trusted=yes] http://openresty.org/package/ubuntu ${_distro_release:-focal} main" | tee /etc/apt/sources.list.d/openresty.list
_distro_release=$(wget $WGETOPT "http://openresty.org/package/$DISTRO_ID/dists/" -O - | grep -o "$DISTRO_CODENAME" | head -n1 || true)
if [ $DISTRO_ID = "ubuntu" ]; then
echo "deb [trusted=yes] http://openresty.org/package/$DISTRO_ID ${_distro_release:-focal} main" | tee /etc/apt/sources.list.d/openresty.list
else
echo "deb [trusted=yes] http://openresty.org/package/$DISTRO_ID ${_distro_release:-bullseye} openresty" | tee /etc/apt/sources.list.d/openresty.list
fi
runcmd apt-get update && apt-get install -y -q --no-install-recommends openresty
# Install nodejs

View File

@ -8,18 +8,23 @@ if [ "$(uname)" != "Linux" ]; then
fi
DISTRO=$(cat /etc/*-release | grep -w ID | cut -d= -f2 | tr -d '"')
if [ "$DISTRO" != "alpine" ] && [ "$DISTRO" != "ubuntu" ]; then
if [ "$DISTRO" != "alpine" ] && [ "$DISTRO" != "ubuntu" ] && [ "$DISTRO" != "debian" ]; then
echo "DISTRO NOT SUPPORTED"
exit 1
fi
INSTALL_SCRIPT=$DISTRO
if [ "$DISTRO" = "ubuntu" ]; then
INSTALL_SCRIPT="debian"
fi
rm -rf $TMP
wget -O "$TMP" "$URL/$DISTRO.sh"
wget -O "$TMP" "$URL/$INSTALL_SCRIPT.sh"
chmod +x "$TMP"
if [ "$(command -v bash)" ]; then
sudo bash "$TMP"
$(command -v sudo) bash "$TMP"
else
sh "$TMP"
fi