Revert "update installer"

This reverts commit 3d579d5961.
This commit is contained in:
thatmattlove 2022-12-24 18:24:46 -05:00
parent 3d579d5961
commit bda17d546e

View file

@ -2,10 +2,13 @@
set -e set -e
# HYPERGLASS_VERSION="1.0.0b42"
MIN_PYTHON_MAJOR="3" MIN_PYTHON_MAJOR="3"
MIN_PYTHON_MINOR="9" MIN_PYTHON_MINOR="6"
MIN_NODE_MAJOR="18" MIN_NODE_MAJOR="14"
MIN_REDIS_MAJOR="6" MIN_YARN_MAJOR="1"
MIN_REDIS_MAJOR="4"
APT_INSTALL="apt-get install -y" APT_INSTALL="apt-get install -y"
APT_UPDATE="apt update" APT_UPDATE="apt update"
@ -21,14 +24,10 @@ INSTALLER=""
NEEDS_UPDATE="0" NEEDS_UPDATE="0"
NEEDS_PYTHON="1" NEEDS_PYTHON="1"
NEEDS_NODE="1" NEEDS_NODE="1"
NEEDS_PNPM="1" NEEDS_YARN="1"
NEEDS_REDIS="1" NEEDS_REDIS="1"
PNPM_INSTALL_FILE="/tmp/hyperglass-install-pnpm.sh"
has_cmd() { has_cmd() {
source ~/.profile
which $1 >/dev/null which $1 >/dev/null
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@ -40,7 +39,7 @@ has_cmd() {
clean_temp() { clean_temp() {
echo "Cleaning up temporary files..." echo "Cleaning up temporary files..."
rm -rf $PNPM_INSTALL_FILE rm -rf /tmp/yarnkey.gpg
rm -rf /tmp/nodesetup.sh rm -rf /tmp/nodesetup.sh
} }
@ -130,14 +129,14 @@ needs_node() {
fi fi
} }
needs_pnpm() { needs_yarn() {
local has_pnpm=$(has_cmd pnpm) local has_yarn=$(has_cmd yarn)
if [[ $has_pnpm == 1 ]]; then if [[ $has_yarn == 1 ]]; then
NEEDS_PNPM="1" NEEDS_YARN="1"
elif [[ $has_pnpm == 0 ]]; then elif [[ $has_yarn == 0 ]]; then
NEEDS_PNPM="0" NEEDS_YARN="0"
else else
NEEDS_PNPM="1" NEEDS_YARN="1"
fi fi
} }
@ -195,16 +194,16 @@ node_post() {
fi fi
} }
pnpm_post() { yarn_post() {
if [[ $1 == 0 ]]; then if [[ $1 == 0 ]]; then
local successful=$(NEEDS_PNPM) local successful=$(needs_yarn)
if [[ $successful == 0 ]]; then if [[ $successful == 0 ]]; then
echo "[SUCCESS] Installed PNPM $(pnpm --version | egrep -o '\d+\.\d+\.\d+')" echo "[SUCCESS] Installed Yarn $(yarn --version | egrep -o '\d+\.\d+\.\d+')"
else else
echo "[ERROR] Tried to install PNPM, but post-install check failed." echo "[ERROR] Tried to install Yarn, but post-install check failed."
fi fi
else else
echo '[ERROR] Tried to install PNPM, but encountered an error.' echo '[ERROR] Tried to install Yarn, but encountered an error.'
fi fi
} }
@ -228,6 +227,14 @@ node_apt_prepare() {
NEEDS_UPDATE="1" NEEDS_UPDATE="1"
} }
yarn_apt_prepare() {
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg -o /tmp/yarnkey.gpg
sleep 1
apt-key add /tmp/yarnkey.gpg
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
NEEDS_UPDATE="1"
}
node_yum_prepare() { node_yum_prepare() {
curl -sL https://rpm.nodesource.com/setup_$MIN_NODE_MAJOR.x -o /tmp/nodesetup.sh curl -sL https://rpm.nodesource.com/setup_$MIN_NODE_MAJOR.x -o /tmp/nodesetup.sh
bash /tmp/nodesetup.sh bash /tmp/nodesetup.sh
@ -235,9 +242,9 @@ node_yum_prepare() {
NEEDS_UPDATE="1" NEEDS_UPDATE="1"
} }
redis_apt_prepare() { yarn_yum_prepare() {
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list sleep 1
NEEDS_UPDATE="1" NEEDS_UPDATE="1"
} }
@ -259,6 +266,24 @@ node_brew() {
node_post $? node_post $?
} }
yarn_apt() {
apt-get install -y yarn
sleep 1
yarn_post $?
}
yarn_yum() {
yum -y install gcc-c++ make yarn
sleep 1
yarn_post $?
}
yarn_brew() {
brew install yarn
sleep 1
yarn_post $?
}
python_apt() { python_apt() {
apt-get install -y python3-dev python3-pip >/dev/null apt-get install -y python3-dev python3-pip >/dev/null
sleep 1 sleep 1
@ -281,7 +306,7 @@ python_brew() {
} }
redis_apt() { redis_apt() {
apt-get install -y redis apt-get install -y redis-server
sleep 1 sleep 1
redis_post $? redis_post $?
} }
@ -350,21 +375,25 @@ install_node() {
fi fi
} }
install_pnpm() { install_yarn() {
if [[ $NEEDS_PNPM == "1" ]]; then if [[ $NEEDS_YARN == "1" ]]; then
echo "[INFO] Installing PNPM..." echo "[INFO] Installing Yarn..."
curl -fsSL https://get.pnpm.io/install.sh -o $PNPM_INSTALL_FILE
bash $PNPM_INSTALL_FILE
elif [[ $NEEDS_PNPM == "0" ]]; then if [[ $INSTALLER == "apt" ]]; then
echo "[INFO] Your system is running PNPM $(pnpm --version)." yarn_apt
elif [[ $INSTALLER == "yum" ]]; then
yarn_yum
elif [[ $INSTALLER == "brew" ]]; then
yarn_brew
fi
elif [[ $NEEDS_YARN == "0" ]]; then
echo "[INFO] Your system is running Yarn $(yarn --version) (Minimum is $MIN_YARN_MAJOR+)."
else else
echo "[ERROR] Unable to determine if your system needs PNPM." echo "[ERROR] Unable to determine if your system needs Yarn."
exit 1 exit 1
fi fi
pnpm_post $?
} }
install_redis() { install_redis() {
@ -472,26 +501,28 @@ while true; do
needs_python needs_python
needs_node needs_node
needs_pnpm needs_yarn
needs_redis needs_redis
if [[ $NEEDS_YARN == "1" && $INSTALLER == "apt" ]]; then
yarn_apt_prepare
elif [[ $NEEDS_YARN == "1" && $INSTALLER == "yum" ]]; then
yarn_yum_prepare
fi
if [[ $NEEDS_NODE == "1" && $INSTALLER == "apt" ]]; then if [[ $NEEDS_NODE == "1" && $INSTALLER == "apt" ]]; then
node_apt_prepare node_apt_prepare
elif [[ $NEEDS_NODE == "1" && $INSTALLER == "yum" ]]; then elif [[ $NEEDS_NODE == "1" && $INSTALLER == "yum" ]]; then
node_yum_prepare node_yum_prepare
fi fi
if [[ $NEEDS_REDIS == "1" && $INSTALLER == "apt" ]]; then
redis_apt_prepare
fi
if [[ $NEEDS_UPDATE == "1" ]]; then if [[ $NEEDS_UPDATE == "1" ]]; then
update_repo update_repo
fi fi
install_python install_python
install_node install_node
install_pnpm install_yarn
install_redis install_redis
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then