Refactor services name

This commit is contained in:
Iam54r1n4
2025-02-07 21:08:41 +00:00
parent 2cf4d01066
commit f2d8009515
9 changed files with 62 additions and 62 deletions

View File

@ -122,13 +122,13 @@ show_uri() {
fi fi
fi fi
if [ "$generate_singbox" = true ] && systemctl is-active --quiet singbox.service; then if [ "$generate_singbox" = true ] && systemctl is-active --quiet hysteria-singbox.service; then
read -r domain port < <(get_singbox_domain_and_port) read -r domain port < <(get_singbox_domain_and_port)
if [ -n "$domain" ] && [ -n "$port" ]; then if [ -n "$domain" ] && [ -n "$port" ]; then
echo -e "\nSingbox Sublink:\nhttps://$domain:$port/sub/singbox/$username/$ip_version#$username\n" echo -e "\nSingbox Sublink:\nhttps://$domain:$port/sub/singbox/$username/$ip_version#$username\n"
fi fi
fi fi
if [ "$generate_normalsub" = true ] && systemctl is-active --quiet normalsub.service; then if [ "$generate_normalsub" = true ] && systemctl is-active --quiet hysteria-normal-sub.service; then
read -r domain port < <(get_normalsub_domain_and_port) read -r domain port < <(get_normalsub_domain_and_port)
if [ -n "$domain" ] && [ -n "$port" ]; then if [ -n "$domain" ] && [ -n "$port" ]; then
echo -e "\nNormal-SUB Sublink:\nhttps://$domain:$port/sub/normal/$username#Hysteria2\n" echo -e "\nNormal-SUB Sublink:\nhttps://$domain:$port/sub/normal/$username#Hysteria2\n"

View File

@ -32,12 +32,12 @@ echo "Removing alias 'hys2' from .bashrc..."
sed -i '/alias hys2=.*\/etc\/hysteria\/menu.sh/d' ~/.bashrc sed -i '/alias hys2=.*\/etc\/hysteria\/menu.sh/d' ~/.bashrc
echo "Stop/Disabling Hysteria TelegramBOT Service..." echo "Stop/Disabling Hysteria TelegramBOT Service..."
systemctl stop hysteria-bot.service > /dev/null 2>&1 systemctl stop hysteria-telegram-bot.service > /dev/null 2>&1
systemctl disable hysteria-bot.service > /dev/null 2>&1 systemctl disable hysteria-telegram-bot.service > /dev/null 2>&1
echo "Stop/Disabling Singbox SubLink Service..." echo "Stop/Disabling Singbox SubLink Service..."
systemctl stop singbox.service > /dev/null 2>&1 systemctl stop hysteria-singbox.service > /dev/null 2>&1
systemctl disable singbox.service > /dev/null 2>&1 systemctl disable hysteria-singbox.service > /dev/null 2>&1
echo "Hysteria2 uninstalled!" echo "Hysteria2 uninstalled!"

View File

@ -26,7 +26,7 @@ EOL
} }
create_service_file() { create_service_file() {
cat <<EOL > /etc/systemd/system/normalsub.service cat <<EOL > /etc/systemd/system/hysteria-normal-sub.service
[Unit] [Unit]
Description=normalsub Python Service Description=normalsub Python Service
After=network.target After=network.target
@ -48,8 +48,8 @@ start_service() {
local domain=$1 local domain=$1
local port=$2 local port=$2
if systemctl is-active --quiet normalsub.service; then if systemctl is-active --quiet hysteria-normal-sub.service; then
echo "The normalsub.service is already running." echo "The hysteria-normal-sub.service is already running."
return return
fi fi
@ -67,11 +67,11 @@ start_service() {
chown -R hysteria:hysteria "/etc/letsencrypt/live/$domain" chown -R hysteria:hysteria "/etc/letsencrypt/live/$domain"
chown -R hysteria:hysteria /etc/hysteria/core/scripts/normalsub chown -R hysteria:hysteria /etc/hysteria/core/scripts/normalsub
systemctl daemon-reload systemctl daemon-reload
systemctl enable normalsub.service > /dev/null 2>&1 systemctl enable hysteria-normal-sub.service > /dev/null 2>&1
systemctl start normalsub.service > /dev/null 2>&1 systemctl start hysteria-normal-sub.service > /dev/null 2>&1
systemctl daemon-reload > /dev/null 2>&1 systemctl daemon-reload > /dev/null 2>&1
if systemctl is-active --quiet normalsub.service; then if systemctl is-active --quiet hysteria-normal-sub.service; then
echo -e "${green}normalsub service setup completed. The service is now running on port $port. ${NC}" echo -e "${green}normalsub service setup completed. The service is now running on port $port. ${NC}"
else else
echo -e "${red}normalsub setup completed. The service failed to start. ${NC}" echo -e "${red}normalsub setup completed. The service failed to start. ${NC}"
@ -90,8 +90,8 @@ stop_service() {
echo -e "${red}HYSTERIA_DOMAIN not found in .env. Skipping certificate deletion.${NC}" echo -e "${red}HYSTERIA_DOMAIN not found in .env. Skipping certificate deletion.${NC}"
fi fi
systemctl stop normalsub.service > /dev/null 2>&1 systemctl stop hysteria-normal-sub.service > /dev/null 2>&1
systemctl disable normalsub.service > /dev/null 2>&1 systemctl disable hysteria-normal-sub.service > /dev/null 2>&1
systemctl daemon-reload > /dev/null 2>&1 systemctl daemon-reload > /dev/null 2>&1
rm -f /etc/hysteria/core/scripts/normalsub/.env rm -f /etc/hysteria/core/scripts/normalsub/.env

View File

@ -3,9 +3,9 @@
declare -a services=( declare -a services=(
"hysteria-server.service" "hysteria-server.service"
"webpanel.service" "webpanel.service"
"hysteria-bot.service" "hysteria-telegram-bot.service"
"normalsub.service" "hysteria-normal-sub.service"
"singbox.service" "hysteria-singbox.service"
"wg-quick@wgcf.service" "wg-quick@wgcf.service"
) )

View File

@ -26,7 +26,7 @@ EOL
} }
create_service_file() { create_service_file() {
cat <<EOL > /etc/systemd/system/singbox.service cat <<EOL > /etc/systemd/system/hysteria-singbox.service
[Unit] [Unit]
Description=Singbox Python Service Description=Singbox Python Service
After=network.target After=network.target
@ -48,8 +48,8 @@ start_service() {
local domain=$1 local domain=$1
local port=$2 local port=$2
if systemctl is-active --quiet singbox.service; then if systemctl is-active --quiet hysteria-singbox.service; then
echo "The singbox.service is already running." echo "The hysteria-singbox.service is already running."
return return
fi fi
@ -67,11 +67,11 @@ start_service() {
chown -R hysteria:hysteria "/etc/letsencrypt/live/$domain" chown -R hysteria:hysteria "/etc/letsencrypt/live/$domain"
chown -R hysteria:hysteria /etc/hysteria/core/scripts/singbox chown -R hysteria:hysteria /etc/hysteria/core/scripts/singbox
systemctl daemon-reload systemctl daemon-reload
systemctl enable singbox.service > /dev/null 2>&1 systemctl enable hysteria-singbox.service > /dev/null 2>&1
systemctl start singbox.service > /dev/null 2>&1 systemctl start hysteria-singbox.service > /dev/null 2>&1
systemctl daemon-reload > /dev/null 2>&1 systemctl daemon-reload > /dev/null 2>&1
if systemctl is-active --quiet singbox.service; then if systemctl is-active --quiet hysteria-singbox.service; then
echo -e "${green}Singbox service setup completed. The service is now running on port $port. ${NC}" echo -e "${green}Singbox service setup completed. The service is now running on port $port. ${NC}"
else else
echo -e "${red}Singbox setup completed. The service failed to start. ${NC}" echo -e "${red}Singbox setup completed. The service failed to start. ${NC}"
@ -90,8 +90,8 @@ stop_service() {
echo -e "${red}HYSTERIA_DOMAIN not found in .env. Skipping certificate deletion.${NC}" echo -e "${red}HYSTERIA_DOMAIN not found in .env. Skipping certificate deletion.${NC}"
fi fi
systemctl stop singbox.service > /dev/null 2>&1 systemctl stop hysteria-singbox.service > /dev/null 2>&1
systemctl disable singbox.service > /dev/null 2>&1 systemctl disable hysteria-singbox.service > /dev/null 2>&1
systemctl daemon-reload > /dev/null 2>&1 systemctl daemon-reload > /dev/null 2>&1
rm -f /etc/hysteria/core/scripts/singbox/.env rm -f /etc/hysteria/core/scripts/singbox/.env

View File

@ -13,7 +13,7 @@ EOL
} }
create_service_file() { create_service_file() {
cat <<EOL > /etc/systemd/system/hysteria-bot.service cat <<EOL > /etc/systemd/system/hysteria-telegram-bot.service
[Unit] [Unit]
Description=Hysteria Telegram Bot Description=Hysteria Telegram Bot
After=network.target After=network.target
@ -32,8 +32,8 @@ start_service() {
local api_token=$1 local api_token=$1
local admin_user_ids=$2 local admin_user_ids=$2
if systemctl is-active --quiet hysteria-bot.service; then if systemctl is-active --quiet hysteria-telegram-bot.service; then
echo "The hysteria-bot.service is already running." echo "The hysteria-telegram-bot.service is already running."
return return
fi fi
@ -41,10 +41,10 @@ start_service() {
create_service_file create_service_file
systemctl daemon-reload systemctl daemon-reload
systemctl enable hysteria-bot.service > /dev/null 2>&1 systemctl enable hysteria-telegram-bot.service > /dev/null 2>&1
systemctl start hysteria-bot.service > /dev/null 2>&1 systemctl start hysteria-telegram-bot.service > /dev/null 2>&1
if systemctl is-active --quiet hysteria-bot.service; then if systemctl is-active --quiet hysteria-telegram-bot.service; then
echo -e "${green}Hysteria bot setup completed. The service is now running. ${NC}" echo -e "${green}Hysteria bot setup completed. The service is now running. ${NC}"
echo -e "\n\n" echo -e "\n\n"
else else
@ -53,8 +53,8 @@ start_service() {
} }
stop_service() { stop_service() {
systemctl stop hysteria-bot.service > /dev/null 2>&1 systemctl stop hysteria-telegram-bot.service > /dev/null 2>&1
systemctl disable hysteria-bot.service > /dev/null 2>&1 systemctl disable hysteria-telegram-bot.service > /dev/null 2>&1
rm -f /etc/hysteria/core/scripts/telegrambot/.env rm -f /etc/hysteria/core/scripts/telegrambot/.env
echo -e "\n" echo -e "\n"

View File

@ -97,7 +97,7 @@ EOL
create_webpanel_service_file() { create_webpanel_service_file() {
cat <<EOL > /etc/systemd/system/webpanel.service cat <<EOL > /etc/systemd/system/hysteria-webpanel.service
[Unit] [Unit]
Description=Hysteria2 Web Panel Description=Hysteria2 Web Panel
After=network.target After=network.target
@ -125,7 +125,7 @@ start_service() {
# MAYBE I WANT TO CHANGE CONFIGS WITHOUT RESTARTING THE SERVICE MYSELF # MAYBE I WANT TO CHANGE CONFIGS WITHOUT RESTARTING THE SERVICE MYSELF
# # Check if the services are already active # # Check if the services are already active
# if systemctl is-active --quiet webpanel.service && systemctl is-active --quiet caddy.service; then # if systemctl is-active --quiet hysteria-webpanel.service && systemctl is-active --quiet caddy.service; then
# echo -e "${green}Hysteria web panel is already running with Caddy.${NC}" # echo -e "${green}Hysteria web panel is already running with Caddy.${NC}"
# source /etc/hysteria/core/scripts/webpanel/.env # source /etc/hysteria/core/scripts/webpanel/.env
# echo -e "${yellow}The web panel is accessible at: http://$domain:$port/$ROOT_PATH${NC}" # echo -e "${yellow}The web panel is accessible at: http://$domain:$port/$ROOT_PATH${NC}"
@ -151,11 +151,11 @@ start_service() {
# Reload systemd and enable webpanel service # Reload systemd and enable webpanel service
systemctl daemon-reload systemctl daemon-reload
systemctl enable webpanel.service > /dev/null 2>&1 systemctl enable hysteria-webpanel.service > /dev/null 2>&1
systemctl start webpanel.service > /dev/null 2>&1 systemctl start hysteria-webpanel.service > /dev/null 2>&1
# Check if the web panel is running # Check if the web panel is running
if systemctl is-active --quiet webpanel.service; then if systemctl is-active --quiet hysteria-webpanel.service; then
echo -e "${green}Hysteria web panel setup completed. The web panel is running locally on: http://127.0.0.1:8080/${NC}" echo -e "${green}Hysteria web panel setup completed. The web panel is running locally on: http://127.0.0.1:8080/${NC}"
else else
echo -e "${red}Error: Hysteria web panel service failed to start.${NC}" echo -e "${red}Error: Hysteria web panel service failed to start.${NC}"
@ -177,7 +177,7 @@ start_service() {
fi fi
# Check if the web panel is still running after Caddy restart # Check if the web panel is still running after Caddy restart
if systemctl is-active --quiet webpanel.service; then if systemctl is-active --quiet hysteria-webpanel.service; then
source /etc/hysteria/core/scripts/webpanel/.env source /etc/hysteria/core/scripts/webpanel/.env
local webpanel_url="http://$domain:$port/$ROOT_PATH/" local webpanel_url="http://$domain:$port/$ROOT_PATH/"
echo -e "${green}Hysteria web panel is now running. The service is accessible on: $webpanel_url ${NC}" echo -e "${green}Hysteria web panel is now running. The service is accessible on: $webpanel_url ${NC}"
@ -204,8 +204,8 @@ stop_service() {
echo "Caddy stopped." echo "Caddy stopped."
echo "Stopping Hysteria web panel..." echo "Stopping Hysteria web panel..."
systemctl disable webpanel.service systemctl disable hysteria-webpanel.service
systemctl stop webpanel.service systemctl stop hysteria-webpanel.service
echo "Hysteria web panel stopped." echo "Hysteria web panel stopped."
} }

36
menu.sh
View File

@ -259,11 +259,11 @@ hysteria2_show_user_uri_handler() {
flags="" flags=""
if check_service_active "singbox.service"; then if check_service_active "hysteria-singbox.service"; then
flags+=" -s" flags+=" -s"
fi fi
if check_service_active "normalsub.service"; then if check_service_active "hysteria-normal-sub.service"; then
flags+=" -n" flags+=" -n"
fi fi
@ -300,8 +300,8 @@ hysteria2_change_sni_handler() {
python3 $CLI_PATH change-hysteria2-sni --sni "$sni" python3 $CLI_PATH change-hysteria2-sni --sni "$sni"
if systemctl is-active --quiet singbox.service; then if systemctl is-active --quiet hysteria-singbox.service; then
systemctl restart singbox.service systemctl restart hysteria-singbox.service
fi fi
} }
@ -422,8 +422,8 @@ telegram_bot_handler() {
case $option in case $option in
1) 1)
if systemctl is-active --quiet hysteria-bot.service; then if systemctl is-active --quiet hysteria-telegram-bot.service; then
echo "The hysteria-bot.service is already active." echo "The hysteria-telegram-bot.service is already active."
else else
while true; do while true; do
read -e -p "Enter the Telegram bot token: " token read -e -p "Enter the Telegram bot token: " token
@ -470,8 +470,8 @@ singbox_handler() {
case $option in case $option in
1) 1)
if systemctl is-active --quiet singbox.service; then if systemctl is-active --quiet hysteria-singbox.service; then
echo "The singbox.service is already active." echo "The hysteria-singbox.service is already active."
else else
while true; do while true; do
read -e -p "Enter the domain name for the SSL certificate: " domain read -e -p "Enter the domain name for the SSL certificate: " domain
@ -497,8 +497,8 @@ singbox_handler() {
fi fi
;; ;;
2) 2)
if ! systemctl is-active --quiet singbox.service; then if ! systemctl is-active --quiet hysteria-singbox.service; then
echo "The singbox.service is already inactive." echo "The hysteria-singbox.service is already inactive."
else else
python3 $CLI_PATH singbox -a stop python3 $CLI_PATH singbox -a stop
fi fi
@ -522,8 +522,8 @@ normalsub_handler() {
case $option in case $option in
1) 1)
if systemctl is-active --quiet normalsub.service; then if systemctl is-active --quiet hysteria-normal-sub.service; then
echo "The normalsub.service is already active." echo "The hysteria-normal-sub.service is already active."
else else
while true; do while true; do
read -e -p "Enter the domain name for the SSL certificate: " domain read -e -p "Enter the domain name for the SSL certificate: " domain
@ -549,8 +549,8 @@ normalsub_handler() {
fi fi
;; ;;
2) 2)
if ! systemctl is-active --quiet normalsub.service; then if ! systemctl is-active --quiet hysteria-normal-sub.service; then
echo "The normalsub.service is already inactive." echo "The hysteria-normal-sub.service is already inactive."
else else
python3 $CLI_PATH normal-sub -a stop python3 $CLI_PATH normal-sub -a stop
fi fi
@ -581,8 +581,8 @@ webpanel_handler() {
case $option in case $option in
1) 1)
if systemctl is-active --quiet webpanel.service; then if systemctl is-active --quiet hysteria-webpanel.service; then
echo "The webpanel.service is already active." echo "The hysteria-webpanel.service is already active."
else else
while true; do while true; do
read -e -p "Enter the domain name for the SSL certificate: " domain read -e -p "Enter the domain name for the SSL certificate: " domain
@ -626,8 +626,8 @@ webpanel_handler() {
fi fi
;; ;;
2) 2)
if ! systemctl is-active --quiet webpanel.service; then if ! systemctl is-active --quiet hysteria-webpanel.service; then
echo "The webpanel.service is already inactive." echo "The hysteria-webpanel.service is already inactive."
else else
python3 $CLI_PATH webpanel -a stop python3 $CLI_PATH webpanel -a stop
fi fi

View File

@ -79,9 +79,9 @@ pip install -r requirements.txt
echo "Restarting hysteria services" echo "Restarting hysteria services"
systemctl restart hysteria-server.service systemctl restart hysteria-server.service
systemctl restart hysteria-bot.service systemctl restart hysteria-telegram-bot.service
systemctl restart singbox.service systemctl restart hysteria-singbox.service
systemctl restart webpanel.service systemctl restart hysteria-webpanel.service
echo "Checking hysteria-server.service status" echo "Checking hysteria-server.service status"
if systemctl is-active --quiet hysteria-server.service; then if systemctl is-active --quiet hysteria-server.service; then