Skip to content

Commit

Permalink
Check if there is really changes before writing config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Aug 28, 2024
1 parent ccbb69e commit f98c362
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
omr-vps-admin (0.12+20240827) unstable; urgency=medium

* Add support for "none" encryption with Shadowsocks-go
* Check if there is really a modification before modifying config file

-- OpenMPTCProuter <[email protected]> Tue, 27 Aug 2024 15:14:37 +0200

omr-vps-admin (0.12+20240819) unstable; urgency=medium

* Add LAN IPs info in status return
Expand Down
13 changes: 9 additions & 4 deletions omr-admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import psutil
import time
import uuid
import copy
from pprint import pprint
from datetime import datetime, timedelta
from tempfile import mkstemp
Expand Down Expand Up @@ -300,11 +301,15 @@ def set_global_param(key, value):
def modif_config_user(user, changes):
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json') as f:
content = json.load(f)
content_initial = copy.deepcopy(content)
content['users'][0][user].update(changes)
LOG.debug("backup_config() in modif_config_user")
backup_config()
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
json.dump(content, f, indent=4)
if content_initial != content:
LOG.debug("backup_config() in modif_config_user")
backup_config()
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
json.dump(content, f, indent=4)
else:
LOG.debug("No real changes in modif_config_user")

def add_ss_user(port, key, userid=0, ip=''):
with open('/etc/shadowsocks-libev/manager.json') as f:
Expand Down

0 comments on commit f98c362

Please sign in to comment.