Development
This commit is contained in:
parent
3729ecfa76
commit
c7d1231714
1 changed files with 14 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ Usage:
|
||||||
sudo python3 install.py
|
sudo python3 install.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
|
|
@ -19,6 +20,8 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
AUTO_YES = False
|
||||||
|
|
||||||
SCRIPT_DIR = Path(__file__).parent.resolve()
|
SCRIPT_DIR = Path(__file__).parent.resolve()
|
||||||
COMPOSE_FILE = SCRIPT_DIR.parent / "docker" / "routlin-dash" / "docker-compose.yml"
|
COMPOSE_FILE = SCRIPT_DIR.parent / "docker" / "routlin-dash" / "docker-compose.yml"
|
||||||
CADDYFILE = Path("/etc/caddy/Caddyfile")
|
CADDYFILE = Path("/etc/caddy/Caddyfile")
|
||||||
|
|
@ -71,6 +74,10 @@ def check_root():
|
||||||
|
|
||||||
def prompt_yn(question, default=None):
|
def prompt_yn(question, default=None):
|
||||||
"""Prompt for yes/no. default: 'y', 'n', or None (require explicit answer)."""
|
"""Prompt for yes/no. default: 'y', 'n', or None (require explicit answer)."""
|
||||||
|
if AUTO_YES:
|
||||||
|
choice = (default == "y") if default else True
|
||||||
|
print(f" {question} [auto: {'y' if choice else 'n'}]")
|
||||||
|
return choice
|
||||||
hint = {None: "[y/n]", "y": "[Y/n]", "n": "[y/N]"}[default]
|
hint = {None: "[y/n]", "y": "[Y/n]", "n": "[y/N]"}[default]
|
||||||
while True:
|
while True:
|
||||||
ans = input(f" {question} {hint}: ").strip().lower()
|
ans = input(f" {question} {hint}: ").strip().lower()
|
||||||
|
|
@ -535,6 +542,13 @@ def _lan_ip():
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global AUTO_YES
|
||||||
|
parser = argparse.ArgumentParser(description="Routlin setup wizard.")
|
||||||
|
parser.add_argument('-y', '--yes', action='store_true',
|
||||||
|
help='Auto-accept all yes/no prompts using their defaults.')
|
||||||
|
args = parser.parse_args()
|
||||||
|
AUTO_YES = args.yes
|
||||||
|
|
||||||
check_root()
|
check_root()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue