Skip to content

Commit

Permalink
Merge pull request #47 from ReturnFI/dev
Browse files Browse the repository at this point in the history
Fix Upgrade
  • Loading branch information
ReturnFI authored Dec 3, 2024
2 parents e456eac + c93f840 commit 0fbc8d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.8
0.2.9
26 changes: 10 additions & 16 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 0fbc8d3

Please sign in to comment.