refactor(install): Integrate aiohttp auth server into installation
This commit is contained in:
@ -80,9 +80,20 @@ install_hysteria() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x /etc/hysteria/core/scripts/hysteria2/user.sh
|
|
||||||
chmod +x /etc/hysteria/core/scripts/hysteria2/kick.py
|
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
|
if ! check_scheduler_service; then
|
||||||
setup_hysteria_scheduler
|
setup_hysteria_scheduler
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -27,10 +27,7 @@ EOF
|
|||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable hysteria-scheduler.service
|
systemctl enable hysteria-scheduler.service
|
||||||
systemctl start 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 -
|
(crontab -l | grep -v "hysteria2_venv.*traffic-status" | grep -v "hysteria2_venv.*backup-hysteria") | crontab -
|
||||||
|
|
||||||
# return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_scheduler_service() {
|
check_scheduler_service() {
|
||||||
@ -40,3 +37,38 @@ check_scheduler_service() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user