Merge branch 'rclone-sysconfig' into 'main'

Add rclone option to the "sysconfig" scope of YAML config file

See merge request systemrescue/systemrescue-sources!229
This commit is contained in:
Gerd v. Egidy 2022-08-24 11:24:54 +00:00
commit 495fea0194
2 changed files with 33 additions and 0 deletions

View file

@ -5,6 +5,11 @@ IMPORTANT: The 32bit (i686) release of SystemRescue will be deprecated soon
unless volunteers are found to help maintaining it. See
https://gitlab.com/systemrescue/systemrescue-sources/-/issues/278
------------------------------------------------------------------------------
9.05 (YYYY-MM-DD):
-------------------------------------------------------------------------------
* Add rclone option to the "sysconfig" scope of YAML config file, it writes a rclone.conf file
------------------------------------------------------------------------------
9.04 (2022-08-07):
-------------------------------------------------------------------------------

View file

@ -10,6 +10,7 @@ import sys
import re
import tempfile
import functools
import configparser
# flush stdout buffer after each print call: immediately show the user what is going on
print = functools.partial(print, flush=True)
@ -249,6 +250,33 @@ if 'sysconfig' in config and 'bookmarks' in config['sysconfig'] and config['sysc
with open(firefox_policy_path, "w", encoding='utf-8') as polfile:
json.dump(ff_policy, polfile, ensure_ascii=False, indent=2)
# ==============================================================================
# configure rclone
# ==============================================================================
if 'sysconfig' in config and 'rclone' in config['sysconfig'] and \
config['sysconfig']['rclone'] and isinstance(config['sysconfig']['rclone'], dict) and \
'config' in config['sysconfig']['rclone'] and \
config['sysconfig']['rclone']['config'] and \
isinstance(config['sysconfig']['rclone']['config'], dict):
print(f"====> Adding rclone config ...")
try:
if not os.path.isdir("/root/.config"):
os.mkdir("/root/.config")
if not os.path.isdir("/root/.config/rclone"):
os.mkdir("/root/.config/rclone")
os.chmod("/root/.config/rclone", 0o700)
iniparser = configparser.ConfigParser()
iniparser.read_dict(config['sysconfig']['rclone']['config'])
with open('/root/.config/rclone/rclone.conf', 'w') as configfile:
os.chmod("/root/.config/rclone/rclone.conf", 0o600)
iniparser.write(configfile)
except Exception as e:
print(e)
errcnt+=1
# ==============================================================================
# Configure custom CA certificates
# ==============================================================================