|
|
@@ -0,0 +1,91 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
from collections import OrderedDict |
|
|
|
import sys |
|
|
|
|
|
|
|
import getpass |
|
|
|
import json |
|
|
|
|
|
|
|
# Each entry here is key => (label, hide input) |
|
|
|
PROPS = OrderedDict([ |
|
|
|
('net.vpn.provider', ('VPN Provider', 'See https://github.com/sscraggles/docker-deluge-openvpn for options')), |
|
|
|
('net.vpn.username', ('VPN Username', None)), |
|
|
|
('net.vpn.password', ('VPN Password', None)), |
|
|
|
('vol.media.movies', ('Movies Storage Path', None)), |
|
|
|
('vol.media.tv', ('TV Storage Path', None)), |
|
|
|
('vol.media.anime', ('Anime Storage Path', None)), |
|
|
|
('vol.conf.torrent', ('Torrent Data Dir', 'Directory for torrent client(s) to store configs and state')), |
|
|
|
('vol.conf.bootybot', ('Bootybot Config Dir', 'Config directory for Bootybot')), |
|
|
|
('vol.conf.plex', ('Plex Data Dir', 'Directory for all of Plex\'s stuff')), |
|
|
|
('vol.ingest.torrent', ('Torrent Ingest Dir', 'Directory to drop .torrent files to download through VPN')), |
|
|
|
('vol.ingest.media', ('Media Ingest Dir', 'Directory to drop full media files for Bootybot to later process')), |
|
|
|
('vol.work.plextrans', ('Plex Transcode Dir', 'Directory for Plex to store certain transcoded files')), |
|
|
|
('vol.work.bootybot', ('Bootybot Extract Dir', 'Directory where Bootybot temporarily stores contents of archives, etc')) |
|
|
|
]) |
|
|
|
|
|
|
|
PROMPT = '> ' |
|
|
|
|
|
|
|
def ask_config_opt(config, key): |
|
|
|
label, desc = PROPS[key] |
|
|
|
nodisp = 'password' in key |
|
|
|
|
|
|
|
# Print titles |
|
|
|
title = '= ' + label + ' =' |
|
|
|
bars = '=' * len(title) |
|
|
|
print(bars + '\n' + title + '\n' + bars) |
|
|
|
if desc is not None: |
|
|
|
print(desc) |
|
|
|
|
|
|
|
# Current state stuff. |
|
|
|
if key in config: |
|
|
|
if not nodisp: |
|
|
|
print('Current: \'' + config[key] + '\'') |
|
|
|
|
|
|
|
# Actually ask for input. |
|
|
|
if not nodisp: |
|
|
|
val = input(PROMPT) |
|
|
|
else: |
|
|
|
val = getpass.getpass('(hidden) ' + PROMPT) |
|
|
|
|
|
|
|
config[key] = val |
|
|
|
|
|
|
|
USAGE_STR = 'usage: yarrbox.py <init|edit|generate>' |
|
|
|
|
|
|
|
def main(): |
|
|
|
if len(sys.argv) != 2: |
|
|
|
print(USAGE_STR) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
command = sys.argv[1] |
|
|
|
if command == 'init': |
|
|
|
# Make a new config object and read all the properties. |
|
|
|
cfg = {} |
|
|
|
for k in PROPS: |
|
|
|
ask_config_opt(cfg, k) |
|
|
|
print('') |
|
|
|
|
|
|
|
# Write it to file |
|
|
|
with open('config.json', 'w') as f: |
|
|
|
f.write(json.dumps(cfg)) |
|
|
|
|
|
|
|
elif command == 'edit': |
|
|
|
print('Leave options blank to leave unchanged!\n') |
|
|
|
# Read the file. |
|
|
|
cfg = None |
|
|
|
with open('config.json', 'r') as f: |
|
|
|
cfg = json.loads(f.read()) |
|
|
|
|
|
|
|
# Go through all the properties again and reread them. |
|
|
|
for k in PROPS: |
|
|
|
ask_config_opt(cfg, k) |
|
|
|
print('') |
|
|
|
|
|
|
|
# Write it back. |
|
|
|
with open('config.json', 'w') as f: |
|
|
|
f.write(json.dumps(cfg)) |
|
|
|
|
|
|
|
else: |
|
|
|
print(USAGE_STR) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
main() |