diff --git a/core/scripts/hysteria2/install.sh b/core/scripts/hysteria2/install.sh index bea3751..e43d19e 100644 --- a/core/scripts/hysteria2/install.sh +++ b/core/scripts/hysteria2/install.sh @@ -80,9 +80,20 @@ install_hysteria() { exit 1 fi - chmod +x /etc/hysteria/core/scripts/hysteria2/user.sh chmod +x /etc/hysteria/core/scripts/hysteria2/kick.py + if ! check_auth_server_service; then + echo "Setting up Hysteria auth server..." + setup_hysteria_auth_server + fi + + if systemctl is-active --quiet hysteria-auth.service; then + echo -e "${cyan}Hysteria auth server${NC} has been successfully started." + else + echo -e "${red}Error:${NC} hysteria-auth.service is not active." + exit 1 + fi + if ! check_scheduler_service; then setup_hysteria_scheduler fi diff --git a/core/scripts/scheduler.sh b/core/scripts/scheduler.sh index 95dbc8a..64257f3 100644 --- a/core/scripts/scheduler.sh +++ b/core/scripts/scheduler.sh @@ -27,10 +27,7 @@ EOF systemctl daemon-reload systemctl enable hysteria-scheduler.service systemctl start hysteria-scheduler.service - # wait 2 (crontab -l | grep -v "hysteria2_venv.*traffic-status" | grep -v "hysteria2_venv.*backup-hysteria") | crontab - - - # return 0 } check_scheduler_service() { @@ -40,3 +37,38 @@ check_scheduler_service() { return 1 fi } + +setup_hysteria_auth_server() { + chmod +x /etc/hysteria/core/scripts/hysteria2/auth_server.py + + cat > /etc/systemd/system/hysteria-auth.service << 'EOF' +[Unit] +Description=Hysteria aiohttp Auth Server +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/etc/hysteria/core/scripts/hysteria2 +ExecStart=/etc/hysteria/hysteria2_venv/bin/python3 /etc/hysteria/core/scripts/hysteria2/auth_server.py +Restart=always +RestartSec=3 +Environment="USERS_FILE=/etc/hysteria/users.json" +Environment="CONFIG_FILE=/etc/hysteria/config.json" + +[Install] +WantedBy=multi-user.target +EOF + + systemctl daemon-reload + systemctl enable hysteria-auth.service + systemctl start hysteria-auth.service +} + +check_auth_server_service() { + if systemctl is-active --quiet hysteria-auth.service; then + return 0 + else + return 1 + fi +} \ No newline at end of file