Fix menu.sh and update.sh bugs
This commit is contained in:
@ -8,7 +8,7 @@ echo "Backing up the current configuration..."
|
|||||||
cp "$CONFIG_FILE" /etc/hysteria/config_backup.json
|
cp "$CONFIG_FILE" /etc/hysteria/config_backup.json
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: Failed to back up configuration. Aborting update."
|
echo "Error: Failed to back up configuration. Aborting update."
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Downloading and installing the latest version of Hysteria2..."
|
echo "Downloading and installing the latest version of Hysteria2..."
|
||||||
@ -17,21 +17,21 @@ if [ $? -ne 0 ]; then
|
|||||||
echo "Error: Failed to download or install the latest version. Restoring backup configuration."
|
echo "Error: Failed to download or install the latest version. Restoring backup configuration."
|
||||||
mv /etc/hysteria/config_backup.json "$CONFIG_FILE"
|
mv /etc/hysteria/config_backup.json "$CONFIG_FILE"
|
||||||
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Restoring configuration from backup..."
|
echo "Restoring configuration from backup..."
|
||||||
mv /etc/hysteria/config_backup.json "$CONFIG_FILE"
|
mv /etc/hysteria/config_backup.json "$CONFIG_FILE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: Failed to restore configuration from backup."
|
echo "Error: Failed to restore configuration from backup."
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Modifying systemd service to use config.json..."
|
echo "Modifying systemd service to use config.json..."
|
||||||
sed -i "s|/etc/hysteria/config.yaml|$CONFIG_FILE|" /etc/systemd/system/hysteria-server.service
|
sed -i "s|/etc/hysteria/config.yaml|$CONFIG_FILE|" /etc/systemd/system/hysteria-server.service
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: Failed to modify systemd service."
|
echo "Error: Failed to modify systemd service."
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm /etc/hysteria/config.yaml
|
rm /etc/hysteria/config.yaml
|
||||||
@ -39,9 +39,9 @@ systemctl daemon-reload >/dev/null 2>&1
|
|||||||
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: Failed to restart Hysteria2 service."
|
echo "Error: Failed to restart Hysteria2 service."
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Hysteria2 has been successfully updated."
|
echo "Hysteria2 has been successfully updated."
|
||||||
echo ""
|
echo ""
|
||||||
return 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user