-
Notifications
You must be signed in to change notification settings - Fork 551
/
install.sh
executable file
·160 lines (132 loc) · 4.43 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/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
}
SUDO_CMD=""
if [ ! x"$SUDO_USER" = x"" ]; then
if command -v sudo >/dev/null; then
SUDO_CMD="sudo -u $SUDO_USER "
fi
fi
##############################################################################
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
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" ]; then
# If hikka is already installed by this script
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"
runout dpkg --configure -a
runout apt update
PYVER="3"
elif echo "$OSTYPE" | grep -qE '^linux-gnu.*' && [ -f '/etc/arch-release' ]; then
PKGMGR="pacman -Sy --noconfirm"
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 "$SUDO_CMD $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 "$SUDO_CMD $PKGMGR python$PYVER-dev"
runout "$SUDO_CMD $PKGMGR python$PYVER-pip"
runout "$SUDO_CMD $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 "$SUDO_CMD $PKGMGR openssl libjpeg-turbo libwebp libffi libcairo build-essential libxslt libiconv git ncurses-utils"
elif echo "$OSTYPE" | grep -qE '^darwin.*'; then
runout "$SUDO_CMD$ $PKGMGR jpeg webp"
fi
printf "\r\033[K\033[0;32mPackages installed!\e[0m"
printf "\n\r\033[0;34mCloning repo...\e[0m"
##############################################################################
# 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
}