Skip to content

Commit d9b8a44

Browse files
committed
update install.sh
1 parent 9463ed3 commit d9b8a44

1 file changed

Lines changed: 39 additions & 11 deletions

File tree

install.sh

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ install() {
6969
echo -e "${yellow}×××××××××××××××××××××××${rest}"
7070
echo -e "${cyan}N R P${green} is already installed.${rest}"
7171
echo -e "${yellow}×××××××××××××××××××××××${rest}"
72-
exit 0
7372
else
7473
# Ask the user for the domain name
7574
echo -e "${yellow}×××××××××××××××××××××××${rest}"
@@ -172,7 +171,7 @@ EOL
172171
# Restart NGINX service
173172
sudo systemctl restart nginx || display_error "Failed to restart NGINX service"
174173
check_installation
175-
fi
174+
fi
176175
}
177176

178177
# Check installation statu
@@ -189,20 +188,47 @@ check_installation() {
189188
if systemctl is-active --quiet nginx && [ -f "/etc/nginx/sites-available/$domain" ]; then
190189
(crontab -l 2>/dev/null | grep -v 'certbot renew --nginx --force-renewal --non-interactive --post-hook "nginx -s reload"' ; echo '0 0 1 * * certbot renew --nginx --force-renewal --non-interactive --post-hook "nginx -s reload" > /dev/null 2>&1;') | crontab -
191190
echo ""
192-
echo -e "${Purple}Certificate and Key saved at:${rest}"
191+
echo -e "${purple}Certificate and Key saved at:${rest}"
193192
echo -e "${yellow}×××××××××××××××××××××××××××××××××××××××××××××××××××××${rest}"
194193
echo -e "${cyan}/etc/letsencrypt/live/$domain/fullchain.pem${rest}"
195194
echo -e "${cyan}/etc/letsencrypt/live/$domain/privkey.pem${rest}"
196195
echo -e "${yellow}×××××××××××××××××××××××××××××××××××××××××××××××××××××${rest}"
197196
echo -e "${cyan}🌟 N R P installed Successfully.🌟${rest}"
198197
echo -e "${yellow}××××××××××××××××××××××××××××××××${rest}"
199-
exit 0
200198
else
201199
echo ""
202200
echo -e "${yellow}×××××××××××××××××××××××${rest}"
203201
echo -e "${red}❌N R P installation failed.❌${rest}"
204202
echo -e "${yellow}×××××××××××××××××××××××${rest}"
205-
exit 1
203+
fi
204+
}
205+
206+
# Change Paths
207+
path() {
208+
if systemctl is-active --quiet nginx && [ -f "/etc/nginx/sites-available/$saved_domain" ]; then
209+
echo -e "${yellow}×××××××××××××××××××××××${rest}"
210+
read -p "Enter the new GRPC path (Service Name) [default: grpc]: " new_grpc_path
211+
new_grpc_path=${new_grpc_path:-grpc}
212+
echo -e "${yellow}×××××××××××××××××××××××${rest}"
213+
read -p "Enter the new WebSocket path (Service Name) [default: ws]: " new_ws_path
214+
new_ws_path=${new_ws_path:-ws}
215+
echo -e "${yellow}×××××××××××××××××××××××${rest}"
216+
217+
sed -i "14s|location ~ .* {$|location ~ ^/${new_grpc_path}/(?<port>\\d+)/(.*)$ {|" /etc/nginx/sites-available/$saved_domain
218+
sed -i "28s|location ~ .* {$|location ~ ^/${new_ws_path}/(?<port>\\d+)$ {|" /etc/nginx/sites-available/$saved_domain
219+
220+
# Restart Nginx
221+
systemctl restart nginx
222+
echo -e " ${purple}Paths Changed Successfully${cyan}:
223+
|-----------------|-------|
224+
| GRPC Path | ${yellow}$new_grpc_path
225+
${cyan}| WebSocket Path | ${yellow}$new_ws_path ${cyan}
226+
|-----------------|-------|${rest}"
227+
echo -e "${yellow}×××××××××××××××××××××××${rest}"
228+
else
229+
echo -e "${yellow}×××××××××××××××××××××××${rest}"
230+
echo -e "${red}N R P is not installed.${rest}"
231+
echo -e "${yellow}×××××××××××××××××××××××${rest}"
206232
fi
207233
}
208234

@@ -213,16 +239,14 @@ uninstall() {
213239
echo -e "${yellow}×××××××××××××××××××××××${rest}"
214240
echo -e "${red}N R P is not installed.${rest}"
215241
echo -e "${yellow}×××××××××××××××××××××××${rest}"
216-
exit 0
217242
else
218243
echo -e "${green}☑️Uninstalling... ${rest}"
219244
# Remove SSL certificate files
220245
rm -rf /etc/letsencrypt > /dev/null 2>&1
221-
rm -rf /etc/letsencrypt > /dev/null 2>&1
222246

223247
# Remove NGINX configuration files
224-
rm /etc/nginx/sites-available/$saved_domain > /dev/null 2>&1
225-
rm /etc/nginx/sites-enabled/$saved_domain > /dev/null 2>&1
248+
find /etc/nginx/sites-available/ -mindepth 1 -maxdepth 1 ! -name 'default' -exec rm -rf {} +
249+
find /etc/nginx/sites-enabled/ -mindepth 1 -maxdepth 1 ! -name 'default' -exec rm -rf {} +
226250

227251
# Restart NGINX service
228252
systemctl restart nginx
@@ -242,17 +266,21 @@ echo -e "${yellow}* ${cyan}N${green}ginx ${cyan}R${green}everse ${cyan}P${green}
242266
echo -e "${purple}***********************${rest}"
243267
echo -e "${yellow} 1) ${green}Install ${purple}*${rest}"
244268
echo -e "${purple} * ${rest}"
245-
echo -e "${yellow} 2) ${green}Uninstall${rest} ${purple}*${rest}"
269+
echo -e "${yellow} 2) ${green}Change Paths${rest} ${purple}*${rest}"
270+
echo -e "${purple} * ${rest}"
271+
echo -e "${yellow} 3) ${green}Uninstall${rest} ${purple}*${rest}"
246272
echo -e "${purple} * ${rest}"
247273
echo -e "${yellow} 0) ${purple}Exit${rest}${purple} *${rest}"
248274
echo -e "${purple}***********************${rest}"
249275
read -p "Enter your choice: " choice
250276
case "$choice" in
251277
1)
252278
install
253-
check_installation
254279
;;
255280
2)
281+
path
282+
;;
283+
3)
256284
uninstall
257285
;;
258286
0)

0 commit comments

Comments
 (0)