mirror of
https://github.com/netinvent/npbackup.git
synced 2025-02-24 06:25:17 +08:00
Upgrade client: Add --upgrade-conf parameter to add new options that come with new versions
This commit is contained in:
parent
9ed6f761d9
commit
6a1ceeab74
2 changed files with 25 additions and 5 deletions
3
TODO.md
3
TODO.md
|
@ -31,4 +31,5 @@ rest:https://user:***@good.example.tld/user/
|
|||
- Linux installer script
|
||||
- Windows installer GUI
|
||||
- Create task from GUI
|
||||
- Make cloud file filters optional
|
||||
- Make cloud file filters optional
|
||||
- Default config parameters
|
|
@ -214,10 +214,11 @@ This is free software, and you are welcome to redistribute it under certain cond
|
|||
help="Create task that runs every n minutes",
|
||||
)
|
||||
|
||||
parser.add_argument("--license", action="store_true", help=("Show license"))
|
||||
parser.add_argument("--license", action="store_true", help="Show license")
|
||||
parser.add_argument(
|
||||
"--auto-upgrade", action="store_true", help=("Auto upgrade NPBackup")
|
||||
)
|
||||
"--auto-upgrade", action="store_true", help="Auto upgrade NPBackup")
|
||||
parser.add_argument(
|
||||
"--upgrade-conf", action="store_true", help="Add new configuration elements after upgrade")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.version:
|
||||
|
@ -299,6 +300,24 @@ This is free software, and you are welcome to redistribute it under certain cond
|
|||
logger.error("No configuration created via GUI")
|
||||
sys.exit(7)
|
||||
|
||||
if args.upgrade_conf:
|
||||
# Whatever we need to add here for future releases
|
||||
# Eg:
|
||||
|
||||
logger.info("Upgrading configuration file to version %s", __version__)
|
||||
try:
|
||||
config_dict["options"]
|
||||
except KeyError:
|
||||
# Create new section
|
||||
config_dict["options"] = {}
|
||||
try:
|
||||
config_dict["options"]["how_many_fancy_options"]
|
||||
except KeyError:
|
||||
# Create new entry
|
||||
config_dict["options"]["how_many_fancy_options"] = "Yes !"
|
||||
configuration.save_config(CONFIG_FILE, config_dict)
|
||||
sys.exit(0)
|
||||
|
||||
# Try to perform an auto upgrade if needed
|
||||
try:
|
||||
auto_upgrade = config_dict["options"]["auto_upgrade"]
|
||||
|
@ -319,7 +338,7 @@ This is free software, and you are welcome to redistribute it under certain cond
|
|||
"auto_upgrade_server_password"
|
||||
]
|
||||
except KeyError as exc:
|
||||
logger.error("Missing auto upgrade info: %s", exc)
|
||||
logger.error("Missing auto upgrade info: %s, cannot launch auto upgrade", exc)
|
||||
else:
|
||||
if args.auto_upgrade:
|
||||
logger.info("Running user initiated auto upgrade")
|
||||
|
|
Loading…
Reference in a new issue