-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
starter
299 lines (273 loc) · 14.5 KB
/
starter
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/bin/bash
# /////////////////////////////////////////////////////////////////////////// #
# #
# Copyright 2022 AcidicNodes #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# /////////////////////////////////////////////////////////////////////////// #
# ////////////////| [🥽] | AcidicNodes | [⚗️] |//////////////// #
# || Start [📍] || #
# const { exec } = require('child_process');
INSTALLER_VERSION=1.1.1
DEBIAN_VERSION=$(cat /etc/debian_version)
GIT_VERSION=$(git --version)
NODEJS_VERSION=$(node -v)
PYTHON3_VERSION=$(python3 --version)
NPM_VERSION=$(npm -v)
YARN_VERSION=$(yarn -v)
NORMAL="\e[0m"
BOLD="\e[1m"
UNDERLINE="\e[4m"
YELLOW="\e[33m"
LIGHT_YELLOW="\e[93m"
LIGHT_MAGENTA="\e[95m"
LIGHT_GREEN="\e[92m"
LIGHT_RED="\e[91m"
DEFAULT="\e[39m"
FILE=$1
APPLICATION=$2
MANAGER=$6
TERMINAL=$7
AUTO_INSTALL=$8
AUTO_PULL=$9
LOGGER=${10}
if [ "$2" != "none" ]; then
GIT_REPOSITORY=""
GIT_BRANCH=""
GIT_TOKEN=""; shift
elif [ "$2" == "none" ]; then
GIT_REPOSITORY="$3"
GIT_BRANCH="$4"
GIT_TOKEN="$5"; shift
fi
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "| > Application: '${UNDERLINE}${APPLICATION}\e[24m'"
echo -e "| > Starter File: '${UNDERLINE}${FILE}\e[24m'"
echo -e "| > Git Repository: '${UNDERLINE}${GIT_REPOSITORY}\e[24m'"
echo -e "| > Git Branch: '${UNDERLINE}${GIT_BRANCH}\e[24m'"
echo -e "| > Git Token: '${UNDERLINE}${GIT_TOKEN}\e[24m'"
echo -e "| > Package Manager: '${UNDERLINE}${MANAGER}\e[24m'"
echo -e "| > Terminal Mode: '${UNDERLINE}${TERMINAL}\e[24m'"
echo -e "| > Auto Install: '${UNDERLINE}${AUTO_INSTALL}\e[24m'"
echo -e "| > Auto Pull: '${UNDERLINE}${AUTO_PULL}\e[24m'"
echo -e "| > Logs: '${UNDERLINE}${LOGGER}\e[24m'"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
sleep 0.5
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "| > Time Zone: '${UNDERLINE}${TZ}\e[24m'"
echo -e "| > Cluster: '${UNDERLINE}${P_SERVER_LOCATION}\e[24m'"
echo -e "| > RAM: '${UNDERLINE}${SERVER_MEMORY}MB\e[24m'"
echo -e "| > Local IPv4: '${UNDERLINE}${SERVER_IP}\e[24m'"
echo -e "| > Primary Port: '${UNDERLINE}${SERVER_PORT}\e[24m'"
echo -e "| > UUID: '${UNDERLINE}${P_SERVER_UUID}\e[24m'"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
sleep 0.5
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "| > Installer Version: '${UNDERLINE}${INSTALLER_VERSION}\e[24m'"
echo -e "| > Debian Version: '${UNDERLINE}${DEBIAN_VERSION}\e[24m'"
echo -e "| > Bash Version: '${UNDERLINE}${BASH_VERSION}\e[24m'"
echo -e "| > Git Version: '${UNDERLINE}${GIT_VERSION}\e[24m'"
echo -e "| > NodeJs Version: '${UNDERLINE}${NODE_VERSION}\e[24m'"
echo -e "| > Python(3) Version: '${UNDERLINE}${PYTHON3_VERSION}\e[24m'"
if [ "$NODEJS_VERSION" == "v8.17.0" ] || [ "$NODEJS_VERSION" == "v10.24.1" ] || [ "$NODEJS_VERSION" == "v11.15.0" ]; then
echo -e "| > NPM VERSION: '${LIGHT_RED}${UNDERLINE}Not available\e[24m'"
echo -e "| > YARN VERSION: '${LIGHT_RED}${UNDERLINE}Not available\e[24m'"
echo -e "| > JDK: '${LIGHT_RED}${UNDERLINE}Not available\e[24m'"
elif [ "$NODEJS_VERSION" == "v16.16.0" ]; then
echo -e "| > NPM VERSION: '${LIGHT_GREEN}${UNDERLINE}${NPM_VERSION}\e[24m'"
echo -e "| > YARN VERSION: '${LIGHT_GREEN}${UNDERLINE}${YARN_VERSION}\e[24m'"
echo -e "| > JDK: '${LIGHT_GREEN}${UNDERLINE}Available\e[24m'"
else
echo -e "| > NPM VERSION: '${LIGHT_GREEN}${UNDERLINE}${NPM_VERSION}\e[24m'"
echo -e "| > YARN VERSION: '${LIGHT_GREEN}${UNDERLINE}${YARN_VERSION}\e[24m'"
echo -e "| > JDK: '${LIGHT_RED}${UNDERLINE}Not available\e[24m'"
fi
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
sleep 1.5
echo
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
wget -nv -O /tmp/start https://raw.githubusercontent.com/AcidicNodes/starter/main/starter.sh
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
if [ "$APPLICATION" == "none" ]; then
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > You have picked ${UNDERLINE}no application\e[24m!"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
elif [ "$APPLICATION" == "-( Discord Bots )-" ] || [ "$APPLICATION" == "-( Telegram Bots )-" ] || [ "$APPLICATION" == "-( Twitch Bots )-" ] || [ "$APPLICATION" == "-( WhatsApp Bots )-" ] || [ "$APPLICATION" == "-( [MD] WhatsApp Bots )-" ] || [ "$APPLICATION" == "-( [NON-MD] WhatsApp Bots )-" ] || [ "$APPLICATION" == "-( General Applications )-" ]; then
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > ${BOLD}WARNING! '${UNDERLINE}${APPLICATION}\e[24m' is not an application, please pick another one!\e[21m${NORMAL}"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo
exit 0
elif [ "$APPLICATION" != "-( Discord Bots )-" ] || [ "$APPLICATION" != "-( Telegram Bots )-" ] || [ "$APPLICATION" != "-( Twitch Bots )-" ] || [ "$APPLICATION" != "-( WhatsApp Bots )-" ] || [ "$APPLICATION" == "-( [MD] WhatsApp Bots )-" ] || [ "$APPLICATION" != "-( [NON-MD] WhatsApp Bots )-" ] || [ "$APPLICATION" != "-( General Applications )-" ]; then
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > ${BOLD}WARNING! Remember to reinstall your server in order for '${UNDERLINE}${APPLICATION}\e[24m' to work.\e[21m${NORMAL}"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo
fi
bash /tmp/start "$GIT_REPOSITORY" "$GIT_BRANCH" "$GIT_TOKEN" $TERMINAL $AUTO_PULL
if [ "$NODEJS_VERSION" != "v8.17.0" ] || [ "$NODEJS_VERSION" != "v10.24.1" ] || [ "$NODEJS_VERSION" != "v11.15.0" ]; then
npm i yarn@latest
fi
if [ "$MANAGER" == "yarn" ]; then
if [ "$NODEJS_VERSION" == "v8.17.0" ] || [ "$NODEJS_VERSION" == "v10.24.1" ] || [ "$NODEJS_VERSION" == "v11.15.0" ]; then
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo "-| > Yarn could eventually not work with this NodeJs version. ($NODEJS_VERSION)"
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
fi
fi
if [ "$MANAGER" == "ask" ]; then
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo "-| > Please choose your favourite package manager: [Enter the integer]"
echo "-|"
if [ "$NODEJS_VERSION" == "v8.17.0" ] || [ "$NODEJS_VERSION" == "v10.24.1" ] || [ "$NODEJS_VERSION" == "v11.15.0" ]; then
echo -e ">> | > *) No package manager can be selected."
else
echo -e ">> | > 1) npm ($NPM_VERSION) [default]"
echo -e ">> | > 2) yarn ($YARN_VERSION)"
fi
# echo -e ">> | > 3) pnpm"
echo "-|"
echo -e "-| > ${BOLD}Hint: You could hide this prompt by setting up a default value on the 'Startup' page.${NORMAL}"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
if [ "$NODEJS_VERSION" != "v8.17.0" ] || [ "$NODEJS_VERSION" != "v10.24.1" ] || [ "$NODEJS_VERSION" != "v11.15.0" ]; then
read confirmation
case $confirmation in
2 )
MANAGER="yarn"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo "*| > Using $MANAGER..."
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
sleep 1.5
;;
# 3 )
# MANAGER="pnpm"
# echo "Using pnpm"
# ;;
* )
MANAGER="npm"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo "*| > Using $MANAGER..."
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
sleep 1.5
;;
esac
fi
fi
if [ -f package.json ] && [ "$AUTO_INSTALL" != "no" ]; then
if [ "$AUTO_INSTALL" == "ask" ]; then
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > A package.json have been detected."
echo -e "-| > Continue to Install/Upgrade from package.json? [Enter ${UNDERLINE}yes\e[24m or ${UNDERLINE}no\e[24m]"
echo -e "-| > ${BOLD}Hint: You could hide this prompt by setting up a default value on the 'Startup' page.${NORMAL}"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
read confirmation
case $confirmation in
[Yy]* )
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo "*| > Installing/Upgrading from package.json..."
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
eval $MANAGER "install";;
* )
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo "*| > Skipped!"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo;;
esac
else
eval $MANAGER "install"
fi
fi
if [ "$APPLICATION" != "none" ]; then
echo
echo -e "${LIGHT_YELLOW}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > Remember to take a look at our Discord Server and at our Knowledgebase if you need help setting up ${APPLICATION}!"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_YELLOW}************************************************************${DEFAULT}"
echo
fi
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > Starting Application/Bot..."
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_GREEN}************************************************************${DEFAULT}"
echo
if [ "$APPLICATION" == "none" ]; then
CMD="node $FILE"
elif [ "$APPLICATION" == "Jareer12/DiscordBotPanel" ] && [ "$SERVER_MEMORY" -lt "2048" ]; then
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo -e "-| > ${BOLD}WARNING! '${UNDERLINE}${APPLICATION}\e[24m' must have a minimum of '${UNDERLINE}2048MB\e[24m' of RAM in order for it to run!\e[21m${NORMAL}"
echo -e "${LIGHT_MAGENTA}************************************************************${DEFAULT}"
echo
echo -e "${LIGHT_RED}************************************************************${DEFAULT}"
echo
exit 0
elif [ "$APPLICATION" != "none" ]; then
if [ "$SERVER_MEMORY" -eq "1024" ]; then
CMD="node --max-old-space-size=768 ."
else
CMD="node ."
fi
fi
if [ "$LOGGER" == "yes" ]; then
eval "$CMD | tee acidicnodes_debug_$(date +%d-%m-%Y_%H-%M-%S).log"
else
eval "$CMD"
fi