1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00

update installer

This commit is contained in:
thatmattlove 2022-12-24 18:21:31 -05:00
parent 43faa0f8e4
commit 3d579d5961

View file

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