-
Notifications
You must be signed in to change notification settings - Fork 37
/
install_yum.sh
226 lines (195 loc) · 6.25 KB
/
install_yum.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
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
#!/bin/bash
if command -v termux-setup-storage; then
echo For termux, please use https://raw.githubusercontent.com/The-MoonTg-project/Moon-Userbot/main/termux-install.sh
exit 1
fi
if [[ $UID != 0 ]]; then
echo Please run this script as root
exit 1
fi
yum check-update
yum upgrade
yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
yum install python3 python3-pip git ffmpeg ffmpeg-devel wget gnupg -y || exit 2
su -c "python3 -m pip install -U pip" $SUDO_USER
su -c "python3 -m pip install -U wheel pillow" $SUDO_USER
if [[ -d "Moon-Userbot" ]]; then
cd Moon-Userbot
elif [[ -f ".env.dist" ]] && [[ -f "main.py" ]] && [[ -d "modules" ]]; then
:
else
git clone https://github.com/The-MoonTg-project/Moon-Userbot || exit 2
cd Moon-Userbot || exit 2
fi
if [[ -f ".env" ]] && [[ -f "my_account.session" ]]; then
echo "It seems that Moon-Userbot is already installed. Exiting..."
exit
fi
su -c "python3 -m pip install -U -r requirements_yum.txt" $SUDO_USER || exit 2
echo
echo "Enter API_ID and API_HASH"
echo "You can get it here -> https://my.telegram.org/"
echo "Leave empty to use defaults (please note that default keys significantly increases your ban chances)"
read -r -p "API_ID > " api_id
if [[ $api_id = "" ]]; then
api_id="2040"
api_hash="b18441a1ff607e10a989891a5462e627"
else
read -r -p "API_HASH > " api_hash
fi
echo
echo "Enter APIFLASH_KEY for webshot plugin"
echo "You can get it here -> https://apiflash.com/dashboard/access_keys"
read -r -p "APIFLASH_KEY > " apiflash_key
if [[ $apiflash_key = "" ]]; then
echo "NOTE: API Not set you'll get errors with webshot & ws module"
fi
echo
echo "Enter RMBG_KEY for remove background module"
echo "You can get it here -> https://www.remove.bg/dashboard#api-key"
read -r -p "RMBG_KEY > " rmbg_key
if [[ $rmbg_key = "" ]]; then
echo "NOTE: API Not set you'll not be able to use remove background modules"
fi
echo
echo "Enter VT_KEY for VirusTotal"
echo "You can get it here -> https://www.virustotal.com/"
read -r -p "VT_KEY > " vt_key
if [[ $vt_key = "" ]]; then
echo "NOTE: API Not set you'll not be able to use VirusTotal module"
fi
echo
echo "Enter GEMINI_KEY if you want to use AI"
echo "You can get it here -> https://makersuite.google.com/app/apikey"
read -r -p "GEMINI_KEY > " gemini_key
if [[ $gemini_key = "" ]]; then
echo "NOTE: API Not set you'll not be able to use Gemini AI modules"
fi
echo
echo "Enter COHERE_KEY if you want to use AI"
echo "You can get it here -> https://dashboard.cohere.com/api-keys"
read -r -p "COHERE_KEY > " cohere_key
if [[ $cohere_key = "" ]]; then
echo "NOTE: API Not set you'll not be able to use Coral AI modules"
fi
echo
echo "Enter VCA_API_KEY for aiutils"
echo "Learn How to Get One --> https://github.com/VisionCraft-org/VisionCraft?tab=readme-ov-file#obtaining-an-api-key"
read -r -p "VCA_API_KEY > " vca_api_key
if [[ $vca_api_key = "" ]]; then
echo "NOTE: API Not set you'll not be able to use aiutils module/pligins"
fi
echo
echo "Choose database type:"
echo "[1] MongoDB db_url"
echo "[2] MongoDB localhost"
echo "[3] Sqlite (default)"
read -r -p "> " db_type
echo
case $db_type in
1)
echo "Please enter db_url"
echo "You can get it here -> https://mongodb.com/atlas"
read -r -p "> " db_url
db_name=Moon_Userbot
db_type=mongodb
;;
2)
if systemctl status mongodb; then
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add -
source /etc/os-release
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu ${UBUNTU_CODENAME}/mongodb-org/5.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list
apt update
apt install mongodb -y
systemctl daemon-reload
systemctl enable mongodb
fi
systemctl start mongodb
db_url=mongodb://localhost:27017
db_name=Moon_Userbot
db_type=mongodb
;;
*)
db_name=db.sqlite3
db_type=sqlite3
;;
esac
cat > .env << EOL
API_ID=${api_id}
API_HASH=${api_hash}
# sqlite/sqlite3 or mongo/mongodb
DATABASE_TYPE=${db_type}
# file name for sqlite3, database name for mongodb
DATABASE_NAME=${db_name}
# only for mongodb
DATABASE_URL=${db_url}
APIFLASH_KEY=${apiflash_key}
RMBG_KEY=${rmbg_key}
VT_KEY=${vt_key}
GEMINI_KEY=${gemini_key}
COHERE_KEY=${cohere_key}
VCA_API_KEY=${vca_api_key}
EOL
chown -R $SUDO_USER:$SUDO_USER .
echo
echo "Choose installation type:"
echo "[1] PM2"
echo "[2] Systemd service"
echo "[3] Custom (default)"
read -r -p "> " install_type
su -c "python3 install.py ${install_type}" $SUDO_USER || exit 3
case $install_type in
1)
if ! command -v pm2; then
curl -fsSL https://deb.nodesource.com/setup_17.x | bash
yum install nodejs -y
npm install pm2 -g
su -c "pm2 startup" $SUDO_USER
env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u $SUDO_USER --hp /home/$SUDO_USER
fi
su -c "pm2 start main.py --name Moon --interpreter python3" $SUDO_USER
su -c "pm2 save" $SUDO_USER
echo
echo "============================"
echo "Great! Moon-Userbot installed successfully and running now!"
echo "Installation type: PM2"
echo "Start with: \"pm2 start Moon\""
echo "Stop with: \"pm2 stop Moon\""
echo "Process name: Moon"
echo "============================"
;;
2)
cat > /etc/systemd/system/Moon.service << EOL
[Unit]
Description=Service for Moon Userbot
[Service]
Type=simple
ExecStart=$(which python3) ${PWD}/main.py
WorkingDirectory=${PWD}
Restart=always
User=${SUDO_USER}
Group=${SUDO_USER}
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl start Moon
systemctl enable Moon
echo
echo "============================"
echo "Great! Moon-Userbot installed successfully and running now!"
echo "Installation type: Systemd service"
echo "Start with: \"sudo systemctl start Moon\""
echo "Stop with: \"sudo systemctl stop Moon\""
echo "============================"
;;
*)
echo
echo "============================"
echo "Great! Moon-Userbot installed successfully!"
echo "Installation type: Custom"
echo "Start with: \"python3 main.py\""
echo "============================"
;;
esac
chown -R $SUDO_USER:$SUDO_USER .