#!/bin/bash runin() { # Runs the arguments, piping stderr to logfile { "$@" 2>>../hikka-install.log || return $?; } | while read -r line; do printf "%s\n" "$line" >>../hikka-install.log done } runout() { # Runs the arguments, piping stderr to logfile { "$@" 2>>hikka-install.log || return $?; } | while read -r line; do printf "%s\n" "$line" >>hikka-install.log done } errorin() { cat ../hikka-install.log } errorout() { cat hikka-install.log } ############################################################################## clear clear printf "\n\e[1;35;47m \e[0m" printf "\n\e[1;35;47m █ █ █ █▄▀ █▄▀ ▄▀█ \e[0m" printf "\n\e[1;35;47m █▀█ █ █ █ █ █ █▀█ \e[0m" printf "\n\e[1;35;47m \e[0m" printf "\n\n\e[3;34;40m Installing...\e[0m\n\n" ############################################################################## printf "\r\033[0;34mPreparing for installation...\e[0m" touch hikka-install.log if [ ! x"$SUDO_USER" = x"" ]; then chown "$SUDO_USER:" hikka-install.log fi # Temporarily disabled: # if [ ! x"" = x"$DYNO" ] && ! command -v python >/dev/null; then # # We are running in a heroku dyno without python, time to get ugly! # runout git clone https://github.com/heroku/heroku-buildpack-python || { # printf "Bootstrap download failed!" # exit 1 # } # rm -rf .heroku .cache .profile.d requirements.txt runtime.txt .env # mkdir .cache .env # echo "python-3.9.6" >runtime.txt # echo "pip" >requirements.txt # STACK=heroku-18 runout bash heroku-buildpack-python/bin/compile /app /app/.cache /app/.env || # { # printf "Bootstrap install failed!" # exit 1 # } # rm -rf .cache # export PATH="/app/.heroku/python/bin:$PATH" # Prefer the bootstrapped python, incl. pip, over the system one. # fi if [ -d "Hikka/hikka" ]; then cd Hikka || { printf "\rError: Install git package and re-run installer" exit 6 } DIR_CHANGED="yes" fi if [ -f ".setup_complete" ] || [ -d "hikka" -a ! x"" = x"$DYNO" ]; then # If hikka is already installed by this script, or its in Heroku and installed PYVER="" if echo "$OSTYPE" | grep -qE '^linux-gnu.*'; then PYVER="3" fi printf "\rExisting installation detected" clear "python$PYVER" -m hikka "$@" exit $? elif [ "$DIR_CHANGED" = "yes" ]; then cd .. fi ############################################################################## echo "Installing..." >hikka-install.log if echo "$OSTYPE" | grep -qE '^linux-gnu.*' && [ -f '/etc/debian_version' ]; then PKGMGR="apt install -y" if [ ! "$(whoami)" = "root" ]; then # Relaunch as root, preserving arguments if command -v sudo >/dev/null; then printf "\r\033[0;33mRestarting as root...\e[0m" echo "Relaunching" >>hikka-install.log sudo "$BASH" -c '. <(wget -qO- https://github.com/hikariatama/Hikka/master/install.sh)'"$*" exit $? else PKGMGR="true" fi else runout dpkg --configure -a runout apt update fi PYVER="3" elif echo "$OSTYPE" | grep -qE '^linux-gnu.*' && [ -f '/etc/arch-release' ]; then PKGMGR="pacman -Sy --noconfirm" if [ ! "$(whoami)" = "root" ]; then # Relaunch as root, preserving arguments if command -v sudo >/dev/null; then printf "\r\033[0;33mRestarting as root...\e[0m" echo "Relaunching" >>hikka-install.log sudo "$BASH" -c '. <(wget -qO- https://github.com/hikariatama/Hikka/master/install.sh)'"$*" exit $? else PKGMGR="true" fi fi PYVER="3" elif echo "$OSTYPE" | grep -qE '^linux-android.*'; then runout apt update PKGMGR="apt install -y" PYVER="" elif echo "$OSTYPE" | grep -qE '^darwin.*'; then if ! command -v brew >/dev/null; then ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go) fi PKGMGR="brew install" PYVER="3" else printf "\r\033[1;31mUnrecognised OS.\e[0m Please follow 'Manual installation' at \033[0;94mhttps://github.com/hikariatama/Hikka/#-installation\e[0m" exit 1 fi ############################################################################## runout $PKGMGR "python$PYVER" git || { errorout "Core install failed." exit 2 } printf "\r\033[K\033[0;32mPreparation complete!\e[0m" printf "\n\r\033[0;34mInstalling linux packages...\e[0m" if echo "$OSTYPE" | grep -qE '^linux-gnu.*'; then runout $PKGMGR "python$PYVER-dev" runout $PKGMGR "python$PYVER-pip" runout $PKGMGR python3 python3-pip git python3-dev libwebp-dev libz-dev libjpeg-dev libopenjp2-7 libtiff5 ffmpeg imamgemagick libffi-dev libcairo2 elif echo "$OSTYPE" | grep -qE '^linux-android.*'; then runout $PKGMGR openssl libjpeg-turbo libwebp libffi libcairo build-essential libxslt libiconv git ncurses-utils elif echo "$OSTYPE" | grep -qE '^darwin.*'; then runout $PKGMGR jpeg webp fi runout $PKGMGR neofetch dialog printf "\r\033[K\033[0;32mPackages installed!\e[0m" printf "\n\r\033[0;34mCloning repo...\e[0m" ############################################################################## SUDO_CMD="" if [ ! x"$SUDO_USER" = x"" ]; then if command -v sudo >/dev/null; then SUDO_CMD="sudo -u $SUDO_USER " fi fi # shellcheck disable=SC2086 ${SUDO_CMD}rm -rf Hikka # shellcheck disable=SC2086 runout ${SUDO_CMD}git clone https://github.com/hikariatama/Hikka/ || { errorout "Clone failed." exit 3 } cd Hikka || { printf "\r\033[0;33mRun: \033[1;33mpkg install git\033[0;33m and restart installer" exit 7 } printf "\r\033[K\033[0;32mRepo cloned!\e[0m" printf "\n\r\033[0;34mInstalling python dependencies...\e[0m" # shellcheck disable=SC2086 runin ${SUDO_CMD}"python$PYVER" -m pip install --upgrade pip setuptools wheel --user # shellcheck disable=SC2086 runin ${SUDO_CMD}"python$PYVER" -m pip install -r requirements.txt --upgrade --user --no-warn-script-location --disable-pip-version-check || { errorin "Requirements failed!" exit 4 } rm -f ../hikka-install.log touch .setup_complete printf "\r\033[K\033[0;32mDependencies installed!\e[0m" printf "\n\033[0;32mStarting...\e[0m\n\n" ${SUDO_CMD}"python$PYVER" -m hikka "$@" || { printf "\033[1;31mPython scripts failed\e[0m" exit 5 }