Merge pull request #47 from ReturnFI/dev

Fix Upgrade
This commit is contained in:
Whispering Wind
2024-12-03 22:49:51 +03:30
committed by GitHub
2 changed files with 11 additions and 17 deletions

View File

@ -1 +1 @@
0.2.8
0.2.9

View File

@ -1,18 +1,12 @@
#!/bin/bash
cd /root/
if ! command -v zip &> /dev/null; then
apt install -y zip
fi
TEMP_DIR=$(mktemp -d)
FILES=(
"/etc/hysteria/ca.key"
"/etc/hysteria/ca.crt"
"/etc/hysteria/users.json"
"/etc/hysteria/traffic_data.json"
"/etc/hysteria/config.json"
"/etc/hysteria/core/scripts/telegrambot/.env"
"/etc/hysteria/core/scripts/singbox/.env"
@ -40,16 +34,6 @@ for FILE in "${FILES[@]}"; do
cp "$TEMP_DIR/$FILE" "$FILE"
done
echo "Merging traffic data into users.json"
if [ -f /etc/hysteria/traffic_data.json ]; then
jq -s '.[0] * .[1]' /etc/hysteria/users.json /etc/hysteria/traffic_data.json > /etc/hysteria/users_temp.json
mv /etc/hysteria/users_temp.json /etc/hysteria/users.json
# rm /etc/hysteria/traffic_data.json
else
echo "No traffic_data.json found to merge."
fi
if [ ! -f /etc/hysteria/.configs.env ]; then
echo ".configs.env not found, creating it with default SNI=bts.com"
echo "SNI=bts.com" > /etc/hysteria/.configs.env
@ -84,5 +68,15 @@ else
echo "Upgrade failed: hysteria-server.service is not active"
fi
CRON_JOB="0 3 */3 * * /bin/bash -c 'source /etc/hysteria/hysteria2_venv/bin/activate && python3 /etc/hysteria/core/cli.py restart-hysteria2' >/dev/null 2>&1"
if crontab -l | grep -Fxq "$CRON_JOB"; then
echo "Cron job already exists."
else
echo "Adding cron job."
(crontab -l; echo "$CRON_JOB") | crontab -
echo "Cron job added successfully."
fi
chmod +x menu.sh
./menu.sh