Example #1
0
def choose_additions():
    """Choose specific applications to install"""

    inst = {}
    hostname = socket.gethostname()

    if re.match('^(mrchat|moignon)$', hostname):
        inst["nfssrv"] = "yes"
        inst["docker"] = "no"
        inst["vbox"] = "yes"
        inst["tsmd"] = "yes"
        inst["mediatools"] = "yes"
        inst["kodi"] = "yes"
        inst["steam"] = "yes"
    else:
        inst["nfssrv"] = mylib.yesno("Install NFS server", "n")
        inst["docker"] = mylib.yesno("Install docker", "n")
        if not mylib.is_vm():
            inst["vbox"] = mylib.yesno("Install VirtualBox", "n")
        else:
            inst["vbox"] = "no"
        inst["tsmd"] = mylib.yesno("Install Transmission-daemon", "n")
        inst["mediatools"] = mylib.yesno("Install multimedia tools", "n")
        inst["kodi"] = mylib.yesno("Install Kodi MediaCenter", "n")
        inst["steam"] = mylib.yesno("Install Steam", "n")

    return inst
Example #2
0
def deusers_add(de, userlist):
    """Determine users to apply Desktop Environment configuration"""

    deusers = []
    for user in userlist:
        home = f"/home/{user}"
        grp = pathlib.Path(home).group()

        wmcfg = mylib.yesno(f"Deploy '{de}' config for '{user}'", "y")
        if not re.match('^(n|no)$', wmcfg.lower()):
            deusers.append((home, user, grp))

    return deusers
Example #3
0
def deploy_dotconfig(home, confcontent, srcfolder):
    for conf in confcontent:
        src = f"{srcfolder}/home/config/{conf}"
        tgt = f"{home}/.config/{conf}"
        if os.path.isdir(tgt):
            if home == "/etc/skel":
                mylib.file.overwrite(src, tgt)
            else:
                print(f"{warning} '{tgt}' already exists")
                resetconf = mylib.yesno("Overwrite it", "y")
                if not re.match('^(n|no)', resetconf.lower()):
                    mylib.file.overwrite(src, tgt)
        elif os.path.exists(src):
            shutil.copytree(src, tgt, symlinks=True)
Example #4
0
def sid_sourceslist(codename, stable):
    newsl = True
    sourceslist = "/etc/apt/sources.list"
    srcurl = "http://deb.debian.org/debian"
    branch = "main contrib non-free"

    sl = [
        "# sid\n", f"deb {srcurl}/ sid {branch}\n",
        f"#deb-src {srcurl}/ sid {branch}\n\n", "# testing\n",
        f"#deb {srcurl}/ testing {branch}\n",
        f"#deb-src {srcurl}/ testing {branch}\n", "# testing security\n",
        f"#deb {srcurl}-security/ testing-security/updates {branch}\n",
        f"#deb-src {srcurl}-security/ testing-security/updates {branch}\n\n",
        f"# {stable}\n", f"#deb {srcurl}/ {stable} {branch}\n",
        f"#deb-src {srcurl}/ {stable} {branch}\n", f"# {stable} security\n",
        f"#deb {srcurl}-security/ {stable}/updates {branch}\n",
        f"#deb-src {srcurl}-security/ {stable}/updates {branch}\n",
        f"# {stable} volatiles\n",
        f"#deb {srcurl}/ {stable}-updates {branch}\n",
        f"#deb-src {srcurl}/ {stable}-updates {branch}\n"
    ]

    if codename == "sid":
        print(f"{warning} Already sid")
        renewsl = mylib.yesno(f"Renew '{sourceslist}'", "n")
        if not re.match('^(y|yes)$', renewsl.lower()):
            newsl = False
    else:
        herewego = mylib.yesno(f"Upgrade {codename} to sid", "y")
        if re.match('^(n|no)$', herewego.lower()):
            exit(0)

    if newsl:
        with open(sourceslist, "w") as f:
            for line in sl:
                f.write(line)
Example #5
0
def switch_firefox():
    swok = True
    swfirefox_cmds = [
        "apt install firefox 2>/dev/null", "apt purge firefox-esr 2>/dev/null",
        "apt autoremove --purge -yy 2>/dev/null"
    ]

    swfirefox = mylib.yesno("\nSwitch firefox-esr to firefox", "y")
    if not re.match('^(n|no)', swfirefox.lower()):
        for cmd in swfirefox_cmds:
            if os.system(cmd) != 0:
                swok = False

    if swok:
        print(f"{done} firefox-esr switched to firefox")
    else:
        print(f"{error} Failed to switch firefox-esr to firefox")
        exit(1)
Example #6
0
        morepkgs += ["docker-compose"]

    if re.match('^(y|yes)$', additions["vbox"]):
        newgroups.append("vboxusers")
        moreinst += ["VirtualBox"]
        morepkgs += [
            "virtualbox", "virtualbox-ext-pack",
            "virtualbox-guest-additions-iso"
        ]

    if re.match('^(y|yes)$', additions["tsmd"]):
        moreinst += ["Transmission-daemon"]
        morepkgs += ["transmission-daemon"]
        tsmduser = ""
        for (home, user, grp) in mydeusers:
            oktsm = mylib.yesno(f"Make '{user}' transmission-daemon user", "n")
            if re.match('^(y|yes)$', oktsm):
                tsmduser = user
                break
        if tsmduser == "":
            tsmduser = mydeusers[0][1]

    if re.match('^(y|yes)$', additions["mediatools"]):
        moreinst += ["Multimedia utilities"]
        morepkgs += ["easytag", "audacity"]

    if re.match('^(y|yes)$', additions["kodi"]):
        moreinst += ["Kodi MediaCenter"]
        morepkgs += ["kodi"]

    if re.match('^(y|yes)$', additions["steam"]):