forked from mirrors/thatmattlove-hyperglass
update installer
This commit is contained in:
parent
43faa0f8e4
commit
3d579d5961
1 changed files with 41 additions and 72 deletions
113
install.sh
113
install.sh
|
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# HYPERGLASS_VERSION="1.0.0b42"
|
|
||||||
|
|
||||||
MIN_PYTHON_MAJOR="3"
|
MIN_PYTHON_MAJOR="3"
|
||||||
MIN_PYTHON_MINOR="6"
|
MIN_PYTHON_MINOR="9"
|
||||||
MIN_NODE_MAJOR="14"
|
MIN_NODE_MAJOR="18"
|
||||||
MIN_YARN_MAJOR="1"
|
MIN_REDIS_MAJOR="6"
|
||||||
MIN_REDIS_MAJOR="4"
|
|
||||||
|
|
||||||
APT_INSTALL="apt-get install -y"
|
APT_INSTALL="apt-get install -y"
|
||||||
APT_UPDATE="apt update"
|
APT_UPDATE="apt update"
|
||||||
|
|
@ -24,10 +21,14 @@ INSTALLER=""
|
||||||
NEEDS_UPDATE="0"
|
NEEDS_UPDATE="0"
|
||||||
NEEDS_PYTHON="1"
|
NEEDS_PYTHON="1"
|
||||||
NEEDS_NODE="1"
|
NEEDS_NODE="1"
|
||||||
NEEDS_YARN="1"
|
NEEDS_PNPM="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
|
||||||
|
|
@ -39,7 +40,7 @@ has_cmd() {
|
||||||
|
|
||||||
clean_temp() {
|
clean_temp() {
|
||||||
echo "Cleaning up temporary files..."
|
echo "Cleaning up temporary files..."
|
||||||
rm -rf /tmp/yarnkey.gpg
|
rm -rf $PNPM_INSTALL_FILE
|
||||||
rm -rf /tmp/nodesetup.sh
|
rm -rf /tmp/nodesetup.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,14 +130,14 @@ needs_node() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
needs_yarn() {
|
needs_pnpm() {
|
||||||
local has_yarn=$(has_cmd yarn)
|
local has_pnpm=$(has_cmd pnpm)
|
||||||
if [[ $has_yarn == 1 ]]; then
|
if [[ $has_pnpm == 1 ]]; then
|
||||||
NEEDS_YARN="1"
|
NEEDS_PNPM="1"
|
||||||
elif [[ $has_yarn == 0 ]]; then
|
elif [[ $has_pnpm == 0 ]]; then
|
||||||
NEEDS_YARN="0"
|
NEEDS_PNPM="0"
|
||||||
else
|
else
|
||||||
NEEDS_YARN="1"
|
NEEDS_PNPM="1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,16 +195,16 @@ node_post() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
yarn_post() {
|
pnpm_post() {
|
||||||
if [[ $1 == 0 ]]; then
|
if [[ $1 == 0 ]]; then
|
||||||
local successful=$(needs_yarn)
|
local successful=$(NEEDS_PNPM)
|
||||||
if [[ $successful == 0 ]]; then
|
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
|
else
|
||||||
echo "[ERROR] Tried to install Yarn, but post-install check failed."
|
echo "[ERROR] Tried to install PNPM, but post-install check failed."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo '[ERROR] Tried to install Yarn, but encountered an error.'
|
echo '[ERROR] Tried to install PNPM, but encountered an error.'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,14 +228,6 @@ 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
|
||||||
|
|
@ -242,9 +235,9 @@ node_yum_prepare() {
|
||||||
NEEDS_UPDATE="1"
|
NEEDS_UPDATE="1"
|
||||||
}
|
}
|
||||||
|
|
||||||
yarn_yum_prepare() {
|
redis_apt_prepare() {
|
||||||
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo
|
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
|
||||||
sleep 1
|
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"
|
NEEDS_UPDATE="1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,24 +259,6 @@ 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
|
||||||
|
|
@ -306,7 +281,7 @@ python_brew() {
|
||||||
}
|
}
|
||||||
|
|
||||||
redis_apt() {
|
redis_apt() {
|
||||||
apt-get install -y redis-server
|
apt-get install -y redis
|
||||||
sleep 1
|
sleep 1
|
||||||
redis_post $?
|
redis_post $?
|
||||||
}
|
}
|
||||||
|
|
@ -375,25 +350,21 @@ install_node() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_yarn() {
|
install_pnpm() {
|
||||||
if [[ $NEEDS_YARN == "1" ]]; then
|
if [[ $NEEDS_PNPM == "1" ]]; then
|
||||||
echo "[INFO] Installing Yarn..."
|
echo "[INFO] Installing PNPM..."
|
||||||
|
curl -fsSL https://get.pnpm.io/install.sh -o $PNPM_INSTALL_FILE
|
||||||
|
bash $PNPM_INSTALL_FILE
|
||||||
|
|
||||||
if [[ $INSTALLER == "apt" ]]; then
|
elif [[ $NEEDS_PNPM == "0" ]]; then
|
||||||
yarn_apt
|
echo "[INFO] Your system is running PNPM $(pnpm --version)."
|
||||||
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 Yarn."
|
echo "[ERROR] Unable to determine if your system needs PNPM."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
pnpm_post $?
|
||||||
}
|
}
|
||||||
|
|
||||||
install_redis() {
|
install_redis() {
|
||||||
|
|
@ -501,28 +472,26 @@ while true; do
|
||||||
|
|
||||||
needs_python
|
needs_python
|
||||||
needs_node
|
needs_node
|
||||||
needs_yarn
|
needs_pnpm
|
||||||
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_yarn
|
install_pnpm
|
||||||
install_redis
|
install_redis
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
if [[ $? == 0 ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue