コード例 #1
0
def configure_users(user_input):
    ### Add user
    username = user_input['username']
    run("arch-chroot /mnt useradd -m -G wheel -s /bin/bash "+username)

    ### Get user password
    success = False
    while not success:
        try:
            print(" >> Please type in a password for "+username+":")
            run("arch-chroot /mnt passwd "+username)
            success = True
        except subprocess.CalledProcessError as error:
            print(' >> It seems you did not type in matching passwords. Error-message: ', error.output)

    ### Get root password
    success = False
    while not success:
        try:
            print(" >> Please type in a password for root user:"******"arch-chroot /mnt passwd")
            success = True
        except subprocess.CalledProcessError as error:
            print(' >> It seems you did not type in matching passwords. Error-message: ', error.output)

    ### Place the user into the sudoers list
    sed_inplace("/mnt/etc/sudoers", "# %wheel ALL=\(ALL\) ALL", "%wheel ALL=(ALL) ALL")
コード例 #2
0
def install_basic_arch():
    ### Nicer formatting for pacstrap
    sed_inplace("/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/etc/pacman.conf", "#TotalDownload", "TotalDownload")

    ### Update mirrorlist
    print(" >> Updating mirror list")
    try:
        run('reflector --latest 100 --sort rate --protocol https --save /etc/pacman.d/mirrorlist'
            )
    except CalledProcessError as error:
        print('Updating package mirrorlist failed with message: ',
              error.output)

    print(" >> Going to install arch base packages")
    try:
        run('pacstrap /mnt ' + ' '.join(basics))
    except CalledProcessError as error:
        print('Error installing base packages. Message: ', error.output)

    print(" >> Installed arch base packages")

    ### Nicer formatting for pacstrap on installed system
    sed_inplace("/mnt/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/mnt/etc/pacman.conf", "#TotalDownload", "TotalDownload")
コード例 #3
0
def configure_desktop(user_input):
    if user_input['desktop'] == 'KDE plasma':

        print(" >> Activating Desktop (sddm)")
        try:
            run("arch-chroot /mnt sddm --example-config > /mnt/etc/sddm.conf")
            sed_inplace("/mnt/etc/sddm.conf", "^Current=.*", "Current=breeze")
            sed_inplace("/mnt/etc/sddm.conf", "CursorTheme=",
                        "CursorTheme=breeze-dark")
            sed_inplace("/mnt/etc/sddm.conf", "Numlock=none", "Numlock=on")
            run("arch-chroot /mnt systemctl enable sddm")
        except CalledProcessError as error:
            print('Enabling sddm failed with message: ', error.output)

        print(" >> Copying Desktop and Shell theme files")
        #if not os.path.exists("/mnt/etc/skel/.config/gtk-3.0"):
        #    os.makedirs("/mnt/etc/skel/.config/gtk-3.0")
        #if not os.path.exists("mkdir -p /mnt/etc/skel/.local/share/konsole/"):
        #    os.makedirs("mkdir -p /mnt/etc/skel/.local/share/konsole/")

        #copytree("arch-installer/configuration_desktop", "/mnt/etc/skel/")
        try:
            run('cp -a arch-installer/configuration_desktop/. /mnt/etc/skel/')
        except CalledProcessError as error:
            print(
                'Error installing default user desktop configurations with message: ',
                error.output)
コード例 #4
0
def configure_shell():
    ### Place yakuake into autostart
    print(" >> Adding yakuake to autostart")
    run("mkdir -p /mnt/etc/skel/.config/autostart-scripts/")
    run("chmod +x arch-installer/autostart/yakuake.sh")
    copy2("arch-installer/autostart/yakuake.sh",
          "/mnt/etc/skel/.config/autostart-scripts/")

    ### Install zsh and configure
    print(" >> Installing zsh with prezto")

    ### Clone the Prezto files
    run("git clone --recursive https://github.com/sorin-ionescu/prezto.git /mnt/etc/skel/.zprezto"
        )

    ### Set correct theme
    # sed -i "s|theme '<replace>'|theme '$USER_ZSH_THEME'|g" arch-installer/configuration_zsh/zpreztorc

    ### Copy them into the user's folder
    run("zsh arch-installer/configuration_zsh/zsh_setup_configs.sh")

    ### Copy prompt theme and .zpreztorc over
    copy2("arch-installer/configuration_zsh/zshrc", "/mnt/etc/skel/.zshrc")
    copy2("arch-installer/configuration_zsh/zpreztorc",
          "/mnt/etc/skel/.zpreztorc")
    copy2("arch-installer/configuration_zsh/prompt_plasmon_setup",
          "/mnt/etc/skel/.zprezto/modules/prompt/functions/")

    ### Add powerline fonts to display prezto symbols
    print(" >> Installing powerline fonts")
    run("git clone https://github.com/powerline/fonts")
    run("export HOME='/mnt/etc/skel' && zsh ./fonts/install.sh")

    ### Copy Vim-config
    copy2("arch-installer/configuration_zsh/.vimrc", "/mnt/etc/skel/")

    ### Change the default shell
    print(" >> Changing default shell to zsh")
    sed_inplace("/mnt/etc/default/useradd", "SHELL=/bin/bash",
                "SHELL=/bin/zsh")
コード例 #5
0
def set_locale(lang, lc_time):
    with open('/mnt/etc/locale.conf', 'w') as text_file:
        text_file.write('LANG=' + lang + '\n')
        text_file.write('LC_TIME=' + lc_time + '\n')
        sed_inplace('/mnt/etc/locale.gen', '#' + lang, lang)
        sed_inplace('/mnt/etc/locale.gen', '#' + lc_time, lc_time)
        sed_inplace('arch-installer/configuration_zsh/zshrc', '<replace>',  lang)
コード例 #6
0
def set_locale(lang, lc_time):
    with open('/mnt/etc/locale.conf', 'w') as text_file:
        text_file.write('LANG=' + lang + '\n')
        text_file.write('LC_TIME' + lc_time + '\n')
        sed_inplace('/mnt/etc/locale.gen', '#' + lang, lang)
        sed_inplace('/mnt/etc/locale.gen', '#' + lc_time, lc_time)
        sed_inplace('arch-installer/configuration_zsh/zshrc', '<replace>',
                    lang)
コード例 #7
0
ファイル: s12_aur.py プロジェクト: dhanush-raj/arch-installer
def configure_aur():
    print(" >> Going to install AUR packages")

    # Create fake install user
    run("arch-chroot /mnt useradd -m installer")
    open('/mnt/etc/sudoers', 'a').write('installer ALL=(ALL) NOPASSWD: ALL\n')

    # Copy install files to fake install user home directory
    copy2("arch-installer/aur-packages/aurPackageList.txt",
          "/mnt/home/installer/")
    copy2("arch-installer/aur-packages/installAurPackages.py",
          "/mnt/home/installer/")

    # Install aura and AUR packages
    run("arch-chroot /mnt sudo -u installer python /home/installer/installAurPackages.py"
        )

    # Remove fake install user,
    run("arch-chroot /mnt userdel installer")
    sed_inplace('/mnt/etc/sudoers', 'installer ALL=\(ALL\) NOPASSWD: ALL', '')
    run("rm -rf /mnt/home/installer")

    print(" >> Installed AUR packages")
コード例 #8
0
def set_keymap_gui(keymap_gui, internationalisation=False):
    # Set the keymap
    sed_inplace('arch-installer/20-keyboard.conf', '<LAYOUT>', keymap_gui)

    # If internationalisation is chosen, add the option
    if internationalisation:
        sed_inplace('arch-installer/20-keyboard.conf', '<INTL>',
                    'Option          \"XkbVariant\" \"altgr-intl\"')
    else:
        sed_inplace('arch-installer/20-keyboard.conf', '<INTL>', '')

    # Finally copy file over
    copy2('arch-installer/20-keyboard.conf', '/mnt/etc/X11/xorg.conf.d/')
コード例 #9
0
def set_keymap_gui(keymap_gui, internationalisation=False):
    # Set the keymap
    sed_inplace('arch-installer/20-keyboard.conf', '<LAYOUT>', keymap_gui)

    # If internationalisation is chosen, add the option
    if internationalisation:
        sed_inplace('arch-installer/20-keyboard.conf', '<INTL>',
                    'Option          \"XkbVariant\" \"altgr-intl\"')
    else:
        sed_inplace('arch-installer/20-keyboard.conf', '<INTL>', '')

    # Finally copy file over
    run("mkdir -p /mnt/etc/X11/xorg.conf.d/")
    copy2('arch-installer/20-keyboard.conf', '/mnt/etc/X11/xorg.conf.d/')
コード例 #10
0
def install_basic_arch():
    ### Nicer formatting for pacstrap
    sed_inplace("/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/etc/pacman.conf", "#TotalDownload", "TotalDownload")
    ### Enable Multilib
    with open("/etc/pacman.conf", "a") as file:
        file.write("[multilib]\nInclude = /etc/pacman.d/mirrorlist")

    ### Update mirrorlist
    print(" >> Updating mirror list")
    try:
        run('reflector --latest 100 --sort rate --protocol https --save /etc/pacman.d/mirrorlist')
    except CalledProcessError as error:
        print('Updating package mirrorlist failed with message: ', error.output)

    ### Update system and keyring
    print(" >> Updating system and keyring")
    try:
        run('pacman -Sy --noconfirm')
        run('pacman -S archlinux-keyring --noconfirm')
    except CalledProcessError as error:
        print('Updating system and keyring failed with message: ', error.output)

    ### Install base packages
    print(" >> Going to install arch base packages")
    try:
        run('pacstrap /mnt '+ ' '.join(basics))
    except CalledProcessError as error:
        print('Error installing base packages. Message: ', error.output)

    print(" >> Installed arch base packages")

    ### Nicer formatting for pacstrap on installed system
    sed_inplace("/mnt/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/mnt/etc/pacman.conf", "#TotalDownload", "TotalDownload")
    ### Enable Multilib on installed system
    with open("/mnt/etc/pacman.conf", "a") as file:
        file.write("[multilib]\nInclude = /etc/pacman.d/mirrorlist")
コード例 #11
0
def configure_desktop(user_input):
    if user_input['desktop'] == 'KDE plasma':

        print(" >> Configuring KDE desktop (sddm)")
        try:
            run("arch-chroot /mnt sddm --example-config > /mnt/etc/sddm.conf")
            sed_inplace("/mnt/etc/sddm.conf", "^Current=.*", "Current=breeze")
            sed_inplace("/mnt/etc/sddm.conf", "CursorTheme=", "CursorTheme=breeze-dark")
            sed_inplace("/mnt/etc/sddm.conf", "Numlock=none", "Numlock=on")
        except CalledProcessError as error:
            print('Configuring KDE desktop (sddm) failed with message: ', error.output)

        print(" >> Copying KDE Desktop and Shell theme files")
        #if not os.path.exists("/mnt/etc/skel/.config/gtk-3.0"):
        #    os.makedirs("/mnt/etc/skel/.config/gtk-3.0")
        #if not os.path.exists("mkdir -p /mnt/etc/skel/.local/share/konsole/"):
        #    os.makedirs("mkdir -p /mnt/etc/skel/.local/share/konsole/")

        #copytree("arch-installer/configuration_desktop", "/mnt/etc/skel/")
        try:
            run('cp -a arch-installer/configuration_desktop/. /mnt/etc/skel/')
        except CalledProcessError as error:
            print('Error installing default user desktop configurations with message: ', error.output)
        #copy2("arch-installer/configuration_desktop/.config/kdeglobals", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.config/konsolerc", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.config/yakuakerc", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.config/kcminputrc", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.local/share/konsole/Default.profile", "/mnt/etc/skel/.local/share/konsole/")
        #copy2("arch-installer/configuration_desktop/.local/share/konsole/Dark Breeze.colorscheme", "/mnt/etc/skel/.local/share/konsole/")
        #copy2("arch-installer/configuration_desktop/.gtkrc-2.0", "/mnt/etc/skel/")
        #copy2("arch-installer/configuration_desktop/.config/gtk-3.0/settings.ini", "/mnt/etc/locale.conf/")

    elif user_input['desktop'] == 'Cinnamon':

        print(" >> Configuring Cinnamon desktop (gdm)")
        try:
            pass
        except CalledProcessError as error:
            print('Configuring Cinnamon desktop (gdm) failed with message: ', error.output)
コード例 #12
0
def install_packages(user_input, install_user_name):

    print(" >> Packages Installation...")
    print("    Your package choices: ", user_input)

    ### All the packages

    misc_packages = ['vim',
                     'vim-supertab',
                     'vim-jedi',
                     'zsh',
                     'powerline-fonts',
                     'p7zip',
                     'unrar',
                     'fortune-mod',
                     'reflector',
                     'tree',
                     'openssh',
                     'networkmanager',
                     'htop',
                     'tmux']
    packages = {
        'minimal': {
            'desktop' : [],
            'server'  : ['docker']},
        'developer': defaultdict(lambda:
                                 ['cmake',
                                  'boost',
                                  'eigen',
                                  'opencl-headers',
                                  'ocl-icd',
                                  'openmpi',
                                  'hdf5-cpp-fortran',
                                  'python2-pip',
                                  'python-pip',
                                  'ipython',
                                  'python-h5py',
                                  'python-scipy',
                                  'python-matplotlib',
                                  'python-pillow',
                                  'python-pylint',
                                  'autopep8',
                                  'doxygen',
                                  'clinfo']),
        'office': defaultdict(lambda:
                              ['texlive-most',
                               'texlive-lang']),
        'media': {
            'desktop' : ['gnuplot',
                         'graphviz',
                         'ffmpeg'],
            'server'  : ['gnuplot',
                         'graphviz',
                         'ffmpeg']
        }
    }

    desktop_distros = {
        "KDE plasma": ['xorg-server',
                       'xorg-apps',
                       'yakuake',
                       'plasma-meta',
                       'kde-applications'],
        "Gnome": ['gnome',
                  'gnome-extra',
                  'gdm'],
        "Cinnamon": ['cinnamon',
                     'gdm'],
        "Deepin": ['deepin',
                   'deepin-extra',
                   'lightdm'],
        "Budgie": ['budgie-desktop',
                   'gnome',
                   'gdm']
    }

    gui_packages = {
        'minimal': {
            'desktop': ['qtox',
                        'xclip',
                        'yakuake-skin-breeze-thin-dark'],
            'server': ['yakuake-skin-breeze-thin-dark']},
        'developer': defaultdict(lambda: ['xterm', 'visual-studio-code']),
        'office': defaultdict(lambda:
                              ['texstudio',
                               'libreoffice-fresh']),
        'media': {
            'desktop': ['teamspeak3',
                        'gimp',
                        'inkscape',
                        'blender',
                        'handbrake',
                        'vlc',
                        'skypeforlinux-bin',
                        'nextcloud-client',
                        'steam'],
            'server': ['vlc',
                       'steam']}
    }

    graphics_driver_packages = {
        'default': ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'intel':   ['mesa', 'mesa-libgl', 'xf86-video-intel', 'opencl-mesa'],
        'nvidia':  ['nvidia', 'nvidia-libgl', 'opencl-nvidia'],
        'amd':     ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'vbox':    ['virtualbox-guest-modules-arch', 'virtualbox-guest-utils', 'opencl-mesa']}

    server_docker_images = {
        'minimal':   ['nginx'],
        'developer': ['gitlab'],
        'office':    [],
        'media':     ['teamspeak', 'nextcloud']}


    ### Generate the package list
    package_list = misc_packages
    package_list += graphics_driver_packages[user_input['graphics driver']]
    #   Add non-minimal packages to list
    if 'full' in user_input['packages']:
        for _, value in packages.items():
            package_list += value[user_input['system type']]

        if user_input['desktop'] != 'none':
            package_list += desktop_distros[user_input['desktop']]
            for _, value in gui_packages.items():
                package_list += value[user_input['system type']]
    else:
        for package_type in set(['minimal'] + user_input['packages']):
            package_list += packages[package_type][user_input['system type']]

            if user_input['desktop'] != 'none':
                package_list += desktop_distros[user_input['desktop']]
                package_list += gui_packages[package_type][user_input['system type']]

    ### Generate docker image list
    server_docker_list = []
    #   Add non-minimal images to list
    if 'full' in user_input['packages']:
        for _, value in server_docker_images.items():
            server_docker_list += value
    else:
        for package_type in set(['minimal'] + user_input['packages']):
            server_docker_list += server_docker_images[package_type]

    ### Parallel makepkg
    print(" >> Setting `makepkg` parallel")
    sed_inplace(
        '/etc/makepkg.conf',
        '#MAKEFLAGS="-j2"',
        'MAKEFLAGS="-j$(nproc)"')
    sed_inplace(
        '/mnt/etc/makepkg.conf',
        '#MAKEFLAGS="-j2"',
        'MAKEFLAGS="-j$(nproc)"')
    print(" >> Gave `makepkg` the flag `-j2`")


    ### Install packages using pacaur
    print(" >> Going to install user packages")
    with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', dir='/mnt') as package_file:
        package_string = " ".join(package_list)
        package_file.write(package_string)
        package_file.flush()
        try:
            run('arch-chroot /mnt sudo -u {} pacaur -S --noconfirm --noedit `cat {}`'.format(install_user_name, package_file.name))
        except CalledProcessError as error:
            print('Error installing packages. Message: ', error.output)
    print(" >> Installed user packages")

    ### Pull docker images
    if user_input['system type'] == 'server':
        print(" >> Going to pull docker images")
        try:
            for image in server_docker_list:
                run('arch-chroot /mnt sudo -u {} systemctl start docker'.format(install_user_name))
                run('arch-chroot /mnt sudo -u {} docker pull {}'.format(install_user_name, image))
        except CalledProcessError as error:
            print('Error pulling docker images. Message: ', error.output)
        print(" >> Pulled docker images")


    print(" >> Packages Installation... done")
コード例 #13
0
def install_packages(user_input, install_user_name):
    ### Setup Package List
    print(" >> Creating package list")
    print(" Your choices: ", user_input)

    sed_inplace('/etc/makepkg.conf', '#MAKEFLAGS="-j2"',
                'MAKEFLAGS="-j$(nproc)"')
    sed_inplace('/mnt/etc/makepkg.conf', '#MAKEFLAGS="-j2"',
                'MAKEFLAGS="-j$(nproc)"')

    misc_packages = [
        'vim', 'vim-supertab', 'vim-jedi', 'zsh', 'powerline-fonts', 'p7zip',
        'unrar', 'fortune-mod', 'reflector', 'tree'
    ]
    packages = {
        'minimal': {
            'desktop': [],
            'server': ['openssh']
        },
        'developer':
        defaultdict(lambda: [
            'cmake', 'boost', 'eigen', 'opencl-headers', 'ocl-icd', 'openmpi',
            'hdf5-cpp-fortran', 'python2-pip', 'python-pip', 'ipython',
            'python-h5py', 'python-scipy', 'python-matplotlib',
            'python-pillow', 'python-pylint', 'autopep8', 'doxygen', 'clinfo'
        ]),
        'office':
        defaultdict(lambda: ['texlive-most', 'texlive-lang']),
        'media': {
            'desktop': ['gnuplot', 'graphviz', 'ffmpeg'],
            'server': ['gnuplot', 'graphviz', 'ffmpeg', 'teamspeak3-server']
        }
    }

    desktop_distros = {
        "KDE plasma": [
            'xorg-server', 'xorg-apps', 'yakuake', 'plasma-meta',
            'kde-applications'
        ]
    }

    gui_packages = {
        'minimal': {
            'desktop': ['qtox', 'xclip', 'yakuake-skin-breeze-thin-dark'],
            'server': ['yakuake-skin-breeze-thin-dark']
        },
        'developer': defaultdict(lambda: ['xterm', 'visual-studio-code']),
        'office': defaultdict(lambda: ['texstudio', 'libreoffice-fresh']),
        'media': {
            'desktop': [
                'teamspeak3', 'gimp', 'inkscape', 'blender', 'handbrake',
                'vlc', 'skypeforlinux-bin', 'nextcloud-client'
            ],
            'server': ['vlc', 'nextcloud']
        }
    }

    graphics_driver_packages = {
        'default': ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'intel': ['mesa', 'mesa-libgl', 'xf86-video-intel', 'opencl-mesa'],
        'nvidia': ['nvidia', 'nvidia-libgl', 'opencl-nvidia'],
        'amd': ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'vbox': [
            'virtualbox-guest-modules-arch', 'virtualbox-guest-utils',
            'opencl-mesa'
        ]
    }

    package_list = misc_packages
    package_list += graphics_driver_packages[user_input['graphics driver']]

    if 'full' in user_input['packages']:
        for _, value in packages.items():
            package_list += value[user_input['system type']]

        if user_input['desktop'] != 'none':
            package_list += desktop_distros[user_input['desktop']]
            for _, value in gui_packages.items():
                package_list += value[user_input['system type']]

    else:
        for package_type in set(['minimal'] + user_input['packages']):
            package_list += packages[package_type][user_input['system type']]

            if user_input['desktop'] != 'none':
                package_list += desktop_distros[user_input['desktop']]
                package_list += gui_packages[package_type][
                    user_input['system type']]

    package_string = " ".join(package_list)

    print(" >> Going to install user packages")
    with tempfile.NamedTemporaryFile(mode='w', suffix='.txt',
                                     dir='/mnt') as package_file:
        package_file.write(package_string)
        package_file.flush()
        try:
            run('arch-chroot /mnt sudo -u {} pacaur -S --noconfirm --noedit `cat {}`'
                .format(install_user_name, package_file.name))
        except CalledProcessError as error:
            print('Error installing packages. Message: ', error.output)

    print(" >> Installed user packages")