2021-10-04 23:56:53 +00:00
|
|
|
import os
|
2021-10-08 00:18:08 +00:00
|
|
|
import sys
|
2021-10-04 23:56:53 +00:00
|
|
|
import toml
|
2021-10-08 00:18:08 +00:00
|
|
|
from rich import print
|
2021-10-04 23:56:53 +00:00
|
|
|
|
|
|
|
if 'XDG_CONFIG_HOME' in os.environ:
|
|
|
|
config_dir = os.environ['XDG_CONFIG_HOME']
|
|
|
|
else:
|
|
|
|
config_dir = os.path.join(os.environ['HOME'], '.config')
|
|
|
|
|
|
|
|
# if the config dir doesn't exist, create it
|
|
|
|
config_dir = os.path.join(config_dir, 'vacuum-tube')
|
|
|
|
os.makedirs(config_dir, exist_ok=True)
|
|
|
|
|
|
|
|
# create an example config file if it doesn't already exist
|
|
|
|
if not os.path.exists(config_dir + '/config.toml'):
|
|
|
|
with open(config_dir + '/config.toml', 'a+') as f:
|
2021-10-05 22:52:54 +00:00
|
|
|
f.write('''# Disable ascii art if you're using a screen reader or want smaller output
|
|
|
|
ascii_art = true
|
2021-10-08 00:18:08 +00:00
|
|
|
# Change the output color
|
|
|
|
# Example: `red`, `#553e78` or `rgb(104,74,112)`
|
|
|
|
color = "#d89961"
|
|
|
|
|
2021-10-05 22:52:54 +00:00
|
|
|
[repo]
|
2021-10-04 23:56:53 +00:00
|
|
|
# Example: `~/backups/backup.borg` or `ssh://agatha@some.place:22/~/backups/backup.borg`
|
|
|
|
path = ""
|
|
|
|
# Leave empty if none
|
|
|
|
# If repo is encrypted and no passphrase is provided, the program will ask you for one.
|
|
|
|
passphrase = ""
|
|
|
|
|
|
|
|
[disk]
|
|
|
|
# Example: `/dev/sda1`
|
|
|
|
partition = ""
|
|
|
|
# If the backup disk is remote, provide an ssh command.
|
|
|
|
# Otherwise, leave empty.
|
|
|
|
# Example: `ssh -p 22 agatha@some.place`
|
|
|
|
ssh = ""''')
|
2021-10-08 00:18:08 +00:00
|
|
|
print('No existing configuration found, creating one at: [underline #d89961]' + config_dir + '/config.toml')
|
|
|
|
sys.exit()
|
2021-10-04 23:56:53 +00:00
|
|
|
|
|
|
|
config = toml.load(config_dir + '/config.toml')
|