コード例 #1
0
 def create(username: str):
     try:
         User.load(username)
         raise UserAlreadyExists
     except UserNotFound:
         run(['useradd', '-m', username])
         return User.load(username)
コード例 #2
0
def setup_pepper(path='/mnt', boot_dev='/dev/vda'):
    arch_chroot_unmount(path)
    services = ServiceManager()
    services.add(Service('ssh', ['openssh'], 'sshd'))
    services.add(Service('docker', ['docker', 'docker-compose'], 'docker'))
    services.add(Service('network', ['networkmanager'], 'NetworkManager'))
    services.add(Service('SMART', ['smartmontools'], 'smartd'))
    services.add_many(
        Service.short_list(
            ['gpm', 'acpid', 'iptables', 'fancontrol', 'udisks2']))
    services.add(
        Service('libvirt', ['firewalld', 'qemu', 'ebtables'],
                ['virtnetworkd', 'libvirtd']))

    # bootstrap the system
    pacstrap(path, ['base', 'base-devel'])
    edit(f'{path}/etc/pacman.conf')
    edit(f'{path}/etc/locale.gen')
    open(f'{path}/etc/hostname', 'w').write('pepper\n')
    os.makedirs(f'{path}/etc/', exist_ok=True)
    run(['cp', '-v', '/etc/resolv.conf', f'{path}/etc/resolv.conf'])
    with arch_chroot(path):
        Pacman.sync()
        Pacman.install([
            'net-tools', 'wireguard-tools', 'grub', 'vim', 'zsh', 'git', 'gcc',
            'clang', 'linux', 'linux-headers', 'linux-firmware', 'mkinitcpio',
            'mdadm', 'archlinux-keyring', 'sudo', 'wget', 'gdisk', 'xfsprogs',
            'btrfs-progs', 'tmux', 'smartmontols', 'neofetch', 'rtorrent',
            'screen', 'openbsd-netcat' * services.packages()
        ])
        run(['mkinitcpio', '-p', 'linux'])
        services.enable()
        os.makedirs('/etc/polkit-1/rules.d/', exist_ok=True)
        set_timezone('Europe/Paris')

        # setup my user account
        user, is_new = User.get_or_create('snicolet')
        user.add_to_groups(
            ['audio', 'video', 'wheel', 'docker', 'kvm', 'input', 'render'])
        if is_new:
            user.run(['ssh-keygen', '-N', ''])
            run(['passwd', user.username])
        run(['passwd'])
        install_trizen(user)

        install_grub_i386(boot_dev)
    genfstab(path)
コード例 #3
0
 def install(packages):
     return run(['/usr/bin/pacman', '-S', '--noconfirm'] + packages)
コード例 #4
0
 def sync():
     return run(['/usr/bin/pacman', '-Sy'])
コード例 #5
0
def pacstrap(path: str, packages):
    run(['pacstrap', path] + packages)
コード例 #6
0
 def add_to_groups(self, groups):
     for group in groups:
         run(['gpasswd', '-a', self.username, group])
コード例 #7
0
 def add_to_group(self, group: str):
     run(['gpasswd', '-a', self.username, group])
コード例 #8
0
 def run(self, *args, **kwargs):
     kwargs.setdefault('preexec_fn', self.demote)
     kwargs.setdefault('env', self.env)
     return run(*args, **kwargs)
コード例 #9
0
ファイル: services.py プロジェクト: Chr0nos/archinstall
 def enable(self):
     for service in self.services:
         run(['systemctl', 'enable', service])
     return self