def configureGrub(cryptDevice): cprint('Configuring grub') grubFile = '/mnt/etc/default/grub' grubContent = getFileContents(grubFile).replace('GRUB_CMDLINE_LINUX=""', f'GRUB_CMDLINE_LINUX="cryptdevice={cryptDevice}:crypt"') writeFileContent(grubFile, grubContent) chroot('grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck') chroot('grub-mkconfig -o /boot/grub/grub.cfg')
def updateAutokeyFolders(): fileDir = f'{HOME}/.config/autokey' fileLocation = f'{fileDir}/autokey.json' cmd(f'mkdir -p {fileDir}') content = getFileContents(fileLocation) jsonContent = json.loads(content) jsonContent['folders'] = [f'{HOME}/dotfiles/autokey/my-rebinds'] resultingContent = json.dumps(jsonContent, indent=4) writeFileContent(fileLocation, resultingContent)
def updateMkinitcpio(): cprint('Configuring Mkinitcpio') file = '/mnt/etc/mkinitcpio.conf' content = getFileContents(file) content = content.replace('#COMPRESSION="xz"', '#COMPRESSION="xz"\nCOMPRESSION="pigz"') pattern = r'^HOOKS=\((.*)\)$' hooks = re.findall(pattern, content, re.MULTILINE)[0] hooks = hooks.replace('block', 'block keymap encrypt') hooks = hooks.replace('filesystems', 'lvm2 filesystems') content = re.sub(pattern, f'HOOKS=({hooks})', content, flags=re.MULTILINE) writeFileContent(file, content) chroot('mkinitcpio -p linux')
def setupUsers(user): cprint('Changing the shell for root') chroot('chsh -s /usr/bin/fish') def changeRootPw(): cprint('Change root password') chroot('passwd') runInput(changeRootPw) chroot(f'useradd -m -G wheel -s /usr/bin/fish {user}') def changeUserPw(): cprint('Password for the new user:'******'passwd {user}') runInput(changeUserPw) sudoers = '/mnt/etc/sudoers' contentToWrite = getFileContents(sudoers).replace('# %wheel ALL=(ALL) ALL', '%wheel ALL=(ALL) ALL').replace('root ALL=(ALL) ALL\n', f'root ALL=(ALL) ALL\n{user} ALL=(ALL) ALL\n') writeFileContent(sudoers, contentToWrite)
def enableMultiLibs(): cprint('Enabling multilibs') pacmanConf = '/mnt/etc/pacman.conf' contentToWrite = getFileContents(pacmanConf).replace('#[multilib]\n#Include = /etc/pacman.d/mirrorlist', '[multilib]\nInclude = /etc/pacman.d/mirrorlist') writeFileContent(pacmanConf, contentToWrite)
def generateFStab(): cprint('Generating fstab') fstabContent = run('genfstab -U /mnt').stdout # Add tmpfs fstabContent += 'tmpfs /tmp tmpfs rw,nodev,nosuid 0 0\n' writeFileContent('/mnt/etc/fstab', fstabContent)
def updateXinit(): xinitrc = f'{HOME}/.xinitrc' writeFileContent(xinitrc, 'setxkbmap -layout se -option nodeadkeys,caps:escape')
def updateProfile(): profileLocation = f'{HOME}/.profile' writeFileContent(profileLocation, 'setxkbmap -layout se -option nodeadkeys,caps:escape')