├── .build └── ShobuArch ├── .examples ├── example.log ├── example_config.json ├── example_config.yaml └── original_shell │ ├── configure_arch.sh │ ├── configure_finish.sh │ ├── configure_user.sh │ └── configure_zfs.sh ├── .github └── workflows │ ├── go-build.yml │ └── golangci-lint.yml ├── LICENSE ├── README.md ├── debug.go ├── go.mod ├── go.sum ├── main.go └── pkg ├── config ├── config.go └── pacman.go ├── install ├── postinstall.go ├── preinstall.go ├── setup.go └── user.go ├── interfaces └── interfaces.go ├── shell └── shell.go └── util ├── biometrics.go ├── cpu.go ├── disk.go ├── files.go ├── firefox_pwa.go ├── host.go ├── pci.go ├── pretty.go ├── secure_boot.go └── usb.go /.build/ShobuArch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShobuPrime/ShobuArch/77a9af1f9785cab865c12308cac3a75446ca16ac/.build/ShobuArch -------------------------------------------------------------------------------- /.examples/example_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "kernel": "linux-zen", 3 | "hostname": "ShobuArch", 4 | "timezone": "America/New_York", 5 | "user": { 6 | "username": "shobuprime", 7 | "password": "demo", 8 | "language": { 9 | "locale": "en_US.UTF-8", 10 | "charset": "UTF-8", 11 | "keyboard_layout": "us" 12 | }, 13 | "git": {} 14 | }, 15 | "storage": { 16 | "system_disk": "/dev/nvme0n2", 17 | "system_disk_id": "VMware_Virtual_NVMe_Disk-VMware NVME_0000", 18 | "mirror_install": true, 19 | "mirror_disk": "/dev/nvme0n3", 20 | "mirror_disk_id": "VMware_Virtual_NVMe_Disk-VMware NVME_0000", 21 | "filesystem": "btrfs" 22 | }, 23 | "desktop": { 24 | "environment": "kde", 25 | "install_type": "FULL" 26 | }, 27 | "pacman": { 28 | "aur": { 29 | "aur_helper": "yay", 30 | "aur_packages": [ 31 | "cockpit-navigator", 32 | "enpass-bin", 33 | "firefox-pwa-bin", 34 | "macchina-bin", 35 | "openrazer-daemon", 36 | "openrazer-driver-dkms", 37 | "polychromatic", 38 | "razer-nari-pipewire-profile", 39 | "sddm-sugar-dark", 40 | "system-monitoring-center" 41 | ] 42 | }, 43 | "packages": [ 44 | "cockpit", 45 | "cockpit-machines", 46 | "code", 47 | "dmidecode", 48 | "dnsmasq", 49 | "docker", 50 | "efibootmgr", 51 | "firefox", 52 | "firewalld", 53 | "flatpak", 54 | "fwupd", 55 | "go", 56 | "grub", 57 | "libdbusmenu-glib", 58 | "networkmanager", 59 | "network-manager-applet", 60 | "obs-studio", 61 | "openssh", 62 | "os-prober", 63 | "packagekit", 64 | "pipewire", 65 | "pipewire-docs", 66 | "pipewire-jack", 67 | "pipewire-pulse", 68 | "qemu-full", 69 | "qpwgraph", 70 | "reflector", 71 | "rsync", 72 | "steam", 73 | "terminus-font", 74 | "virt-manager", 75 | "v4l2loopback-dkms", 76 | "wget", 77 | "wireplumber", 78 | "wireplumber-docs", 79 | "wpa_supplicant", 80 | "xdg-desktop-portal-gtk", 81 | "xdg-user-dirs", 82 | "xdg-utils", 83 | "ark", 84 | "audiocd-kio", 85 | "bluedevil", 86 | "breeze-gtk", 87 | "discover", 88 | "dolphin", 89 | "dragon", 90 | "drkonqi", 91 | "ffmpegthumbs", 92 | "filelight", 93 | "gwenview", 94 | "juk", 95 | "k3b", 96 | "kamera", 97 | "kamoso", 98 | "kate", 99 | "kbackup", 100 | "kcalc", 101 | "kcharselect", 102 | "kcolorchooser", 103 | "kcodecs", 104 | "kcron", 105 | "kde-gtk-config", 106 | "kde-network-meta", 107 | "kde-pim-meta", 108 | "kdebugsettings", 109 | "kdegraphics-thumbnailers", 110 | "kdenlive", 111 | "kdeplasma-addons", 112 | "kdialog", 113 | "kdf", 114 | "keditbookmarks", 115 | "kfind", 116 | "kgamma5", 117 | "kgpg", 118 | "khelpcenter", 119 | "khotkeys", 120 | "kimagemapeditor", 121 | "kinfocenter", 122 | "kmag", 123 | "kmousetool", 124 | "kmouth", 125 | "kolourpaint", 126 | "konsole", 127 | "kontrast", 128 | "kruler", 129 | "kscreen", 130 | "ksshaskpass", 131 | "ksystemlog", 132 | "kteatime", 133 | "ktimer", 134 | "kwallet-pam", 135 | "kwalletmanager", 136 | "kwave", 137 | "kwayland-integration", 138 | "kwrited", 139 | "markdownpart", 140 | "okular", 141 | "oxygen", 142 | "packagekit-qt5", 143 | "partitionmanager", 144 | "plasma-browser-integration", 145 | "plasma-desktop", 146 | "plasma-disks", 147 | "plasma-firewall", 148 | "plasma-nm", 149 | "plasma-pa", 150 | "plasma-systemmonitor", 151 | "plasma-thunderbolt", 152 | "plasma-vault", 153 | "plasma-wayland-session", 154 | "plasma-workspace-wallpapers", 155 | "powerdevil", 156 | "print-manager", 157 | "sddm", 158 | "sddm-kcm", 159 | "skanpage", 160 | "spectacle", 161 | "svgpart", 162 | "sweeper", 163 | "xdg-desktop-portal-kde", 164 | "yakuake" 165 | ] 166 | }, 167 | "flatpak": { 168 | "packages": [ 169 | "com.belmoussaoui.Obfuscate", 170 | "com.getmailspring.Mailspring", 171 | "com.github.liferooter.textpieces", 172 | "com.github.tchx84.Flatseal", 173 | "com.steamgriddb.steam-rom-manager", 174 | "com.snes9x.Snes9x", 175 | "com.synology.SynologyDrive", 176 | "com.usebottles.bottles", 177 | "im.riot.Riot", 178 | "io.github.antimicrox.antimicrox", 179 | "io.github.m64p.m64p", 180 | "io.github.seadve.Kooha", 181 | "io.mgba.mGBA", 182 | "media.emby.EmbyServer", 183 | "net.filebot.Filebot", 184 | "net.kuribo64.melonDS", 185 | "net.pcsx2.PCSX2", 186 | "org.citra_emu.citra", 187 | "org.DolphinEmu.dolphin-emu", 188 | "org.gnome.Firmware", 189 | "org.gnome.Maps", 190 | "org.gnome.Weather", 191 | "org.libretro.RetroArch", 192 | "org.mixxx.Mixxx", 193 | "org.ppsspp.PPSSPP", 194 | "org.yuzu_emu.yuzu" 195 | ] 196 | }, 197 | "pwa": { 198 | "sites": [ 199 | { 200 | "name": "YouTube", 201 | "description": "Share your videos with friends, family, and the world.", 202 | "start_url": "https://www.youtube.com", 203 | "manifest": "manifest.webmanifest" 204 | } 205 | ] 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /.examples/example_config.yaml: -------------------------------------------------------------------------------- 1 | kernel: linux-zen 2 | hostname: ShobuArch 3 | timezone: America/New_York 4 | user: 5 | username: shobuprime 6 | password: demo 7 | language: 8 | locale: en_US.UTF-8 9 | charset: UTF-8 10 | keyboard: us 11 | storage: 12 | system_disk: /dev/nvme0n2 13 | system_disk_id: VMware_Virtual_NVMe_Disk-VMware NVME_0000 14 | mirror_install: true 15 | mirror_disk: /dev/nvme0n3 16 | mirror_disk_id: VMware_Virtual_NVMe_Disk-VMware NVME_0000 17 | filesystem: zfs 18 | desktop: 19 | environment: kde 20 | install_type: FULL 21 | pacman: 22 | aur: 23 | aur_helper: yay 24 | aur_packages: 25 | - microsoft-edge-stable-bin 26 | - openrazer-meta 27 | - polychromatic 28 | packages: 29 | - cockpit 30 | - cockpit-machines 31 | - code 32 | - dmidecode 33 | - dnsmasq 34 | - docker 35 | - efibootmgr 36 | - firefox 37 | - firewalld 38 | - flatpak 39 | - fwupd 40 | - go 41 | - grub 42 | - libdbusmenu-glib 43 | - networkmanager 44 | - network-manager-applet 45 | - openssh 46 | - os-prober 47 | - packagekit 48 | - qemu 49 | - reflector 50 | - rsync 51 | - steam 52 | - terminus-font 53 | - vde2 54 | - virt-manager 55 | - wget 56 | - wpa_supplicant 57 | - xdg-user-dirs 58 | - xdg-utils 59 | - bluedevil 60 | - breeze-gtk 61 | - discover 62 | - drkonqi 63 | - kde-accessibility-meta 64 | - kde-education-meta 65 | - kde-games-meta 66 | - kde-graphics-meta 67 | - kde-gtk-config 68 | - kde-multimedia-meta 69 | - kde-network-meta 70 | - kde-pim-meta 71 | - kdeplasma-addons 72 | - kde-sdk-meta 73 | - kde-system-meta 74 | - kde-utilities-meta 75 | - kdevelop-meta 76 | - kgamma5 77 | - khotkeys 78 | - kinfocenter 79 | - kscreen 80 | - ksshaskpass 81 | - kwallet-pam 82 | - kwayland-integration 83 | - kwrited 84 | - oxygen 85 | - packagekit-qt5 86 | - plasma-browser-integration 87 | - plasma-desktop 88 | - plasma-disks 89 | - plasma-firewall 90 | - plasma-nm 91 | - plasma-pa 92 | - plasma-systemmonitor 93 | - plasma-thunderbolt 94 | - plasma-vault 95 | - plasma-wayland-session 96 | - plasma-workspace-wallpapers 97 | - powerdevil 98 | - sddm 99 | - sddm-kcm 100 | - xdg-desktop-portal-kde 101 | -------------------------------------------------------------------------------- /.examples/original_shell/configure_arch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Comment out all zroot entries, because zfs handles this by itself 4 | sed -i 's/zroot/# zroot/g' /etc/fstab 5 | sed -i 's/# # zroot/# zroot/g' /etc/fstab 6 | 7 | # Add parallel downloading 8 | # sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf 9 | 10 | # Enable multilib repos 11 | sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf 12 | 13 | # plasma-desktop and plasma-nm for more minimul install 14 | pacman -Syu --needed --noconfirm \ 15 | efibootmgr \ 16 | grub \ 17 | cockpit \ 18 | cockpit-machines \ 19 | packagekit \ 20 | docker \ 21 | go \ 22 | virt-manager \ 23 | qemu \ 24 | vde2 \ 25 | dnsmasq \ 26 | dmidecode \ 27 | code \ 28 | libdbusmenu-glib \ 29 | networkmanager \ 30 | network-manager-applet \ 31 | openssh \ 32 | firewalld \ 33 | os-prober \ 34 | reflector \ 35 | rsync \ 36 | terminus-font \ 37 | wpa_supplicant \ 38 | xdg-user-dirs \ 39 | xdg-utils \ 40 | wget \ 41 | firefox \ 42 | plasma \ 43 | kde-applications \ 44 | plasma-wayland-session \ 45 | sddm \ 46 | lib32-mesa \ 47 | vulkan-radeon \ 48 | vulkan-tools \ 49 | lib32-vulkan-radeon \ 50 | vulkan-icd-loader \ 51 | lib32-vulkan-icd-loader \ 52 | steam 53 | 54 | # Configure kvm 55 | sed -i 's/#unix_sock_group/unix_sock_group/g' /etc/libvirt/libvirtd.conf 56 | sed -i 's/#unix_sock_rw_perms/unix_sock_rw_perms/g' /etc/libvirt/libvirtd.conf 57 | 58 | # Add custom repo to install ArchZFS 59 | wget https://archzfs.com/archzfs.gpg 60 | echo "" >> /etc/pacman.conf 61 | echo '[archzfs]' >> /etc/pacman.conf 62 | pacman-key -a archzfs.gpg 63 | pacman-key -r DDF7DB817396A49B2A2723F7403BD972F75D9D76 64 | pacman-key --lsign-key DDF7DB817396A49B2A2723F7403BD972F75D9D76 65 | 66 | # Check the fingerprint and verify it matches the one on the archzfs page 67 | pacman-key -f DDF7DB817396A49B2A2723F7403BD972F75D9D76 68 | 69 | # echo "SigLevel = Optional TrustAll" >> /etc/pacman.conf 70 | echo "# Origin Server - France" >> /etc/pacman.conf 71 | echo 'Server = http://archzfs.com/$repo/x86_64' >> /etc/pacman.conf 72 | 73 | echo "# Mirror - Germany" >> /etc/pacman.conf 74 | echo 'Server = http://mirror.sum7.eu/archlinux/archzfs/$repo/x86_64' >> /etc/pacman.conf 75 | 76 | echo "# Mirror - Germany" >> /etc/pacman.conf 77 | echo 'Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/x86_64' >> /etc/pacman.conf 78 | 79 | echo "# Mirror - India" >> /etc/pacman.conf 80 | echo 'Server = https://mirror.in.themindsmaze.com/archzfs/$repo/x86_64' >> /etc/pacman.conf 81 | 82 | echo "# ArchZFS - US Mirror" >> /etc/pacman.conf 83 | echo 'Server = https://zxcvfdsa.com/archzfs/$repo/$arch' >> /etc/pacman.conf 84 | 85 | pacman -Syu --needed --noconfirm \ 86 | zfs-dkms \ 87 | zfs-utils 88 | 89 | systemctl enable cockpit.socket 90 | systemctl enable docker.service 91 | systemctl enable firewalld 92 | systemctl enable libvirtd.service 93 | systemctl enable NetworkManager 94 | systemctl enable reflector.timer 95 | systemctl enable sddm 96 | systemctl enable sshd 97 | systemctl enable zfs-import-cache 98 | systemctl enable zfs-import-scan 99 | systemctl enable zfs-mount 100 | systemctl enable zfs-share 101 | systemctl enable zfs-zed 102 | systemctl enable zfs.target 103 | 104 | # systemctl start firewalld 105 | # firewall-cmd --permanent --add-service=cockpit 106 | 107 | # Configure TimeZone 108 | ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime 109 | 110 | # Sync to hardware clock 111 | hwclock --systohc 112 | 113 | # Configure locale 114 | sed -i 's/#en_US.UTF-8/en_US.UTF-8/g' /etc/locale.gen && locale-gen 115 | echo "LANG=en_US.UTF-8" >> /etc/locale.conf 116 | 117 | # Configure Hostname 118 | echo "" >> /etc/hostname 119 | echo "127.0.0.1 localhost" >> /etc/hosts 120 | echo "::1 localhost" >> /etc/hosts 121 | echo "127.0.1.1 .local Hostname02" >> /etc/hosts 122 | 123 | # Install zsh 124 | pacman -Syu --needed --noconfirm \ 125 | zsh \ 126 | grml-zsh-config 127 | 128 | # Create main user 129 | useradd -mU \ 130 | -s /bin/zsh \ 131 | -G sys,log,network,floppy,scanner,power,rfkill,users,video,storage,optical,lp,audio,wheel,adm,docker,kvm \ 132 | -d /home/shobuprime/ \ 133 | username 134 | 135 | # Set password 136 | passwd shobuprime 137 | 138 | # Give root password 139 | passwd 140 | 141 | # visudo -- Uncomment 'wheel' group 142 | sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/g' /etc/sudoers 143 | 144 | # Add user to sudoers 145 | # touch /etc/sudoers.d/local_users 146 | # echo 'shobuprime ALL=(ALL) ALL' >> /etc/sudoers.d/local_users 147 | 148 | # To prioritize the local and fastest repositories, edit reflector.conf to have the following 149 | # --save /etc/pacman.d/mirrorlist 150 | # --protocol https 151 | # --country US 152 | # --latest 5 153 | # --sort rate 154 | cp /etc/xdg/reflector/reflector.conf /etc/xdg/reflector/reflector.conf.bak 155 | sed -i 's/#--country France,Germany/--country US/g' /etc/xdg/reflector/reflector.conf 156 | sed -i 's/--sort age/--sort rate/g' /etc/xdg/reflector/reflector.conf 157 | 158 | # # Install Arch User Repository helper (yay) 159 | git clone https://aur.archlinux.org/yay.git /opt/yay 160 | chown -R shobuprime:users /opt/yay 161 | 162 | # Make yay package, and return to PWD 163 | current_dir=$PWD 164 | cd /opt/yay 165 | su -c 'makepkg -si -S --noconfirm' shobuprime 166 | pacman -U yay_11.1.1_x86_64.tar.gz 167 | cd $current_dir 168 | 169 | # # Install AUR Packages 170 | # # yay -Syu --noconfirm \ 171 | # # vulkan-amdgpu-pro \ 172 | # # amf-amdgpu-pro \ 173 | # # amdgpu-pro-libgl \ 174 | # # openrazer-meta \ 175 | # # polychromatic \ 176 | # # microsoft-edge-stable-bin \ 177 | # # cockpit-navigator \ 178 | # # cockpit-zfs-manager 179 | 180 | su -c 'yay -Syu --noconfirm openrazer-meta polychromatic microsoft-edge-stable-bin cockpit-navigator' shobuprime 181 | 182 | # # Configure Razer Drivers 183 | gpassws -a shobuprime plugdev 184 | systemctl enable openrazer-daemon.service 185 | 186 | # GRUB_CMDLINE_LINUX_DEFAULT: add "video=1920x1080" 187 | # GRUB_CMDLINE_LINUX="root=ZFS=zroot/ROOT/default" 188 | sed -i 's/quiet/quiet video=1920x1080/g' /etc/default/grub 189 | sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="root=ZFS=zroot\/ROOT\/default"/g' /etc/default/grub 190 | 191 | grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ArchLinux 192 | 193 | grub-mkconfig -o /boot/grub/grub.cfg 194 | 195 | # Make HOOKS=(base udev autodetect modconf block keyboard zfs filesystems) 196 | sed -i 's/HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)/HOOKS=(base udev autodetect modconf block keyboard zfs filesystems shutdown)/g' /etc/mkinitcpio.conf 197 | 198 | mkinitcpio -p linux 199 | -------------------------------------------------------------------------------- /.examples/original_shell/configure_finish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #--------------------------------------------------------------------------------- 4 | 5 | # umount /mnt/boot/efi 6 | umount /dev/nvme1n1p1 7 | zfs umount -a 8 | zpool export zroot 9 | dd if=/dev/nvme1n1p1 of=/dev/nvme2n1p1 10 | systemctl reboot --firmware -------------------------------------------------------------------------------- /.examples/original_shell/configure_user.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install Arch User Repository helper (yay) 4 | # git clone https://aur.archlinux.org/yay.git /opt/yay 5 | # chown -R username:users /opt/yay 6 | 7 | # Make yay package, and return to PWD 8 | current_dir=$PWD 9 | cd /opt/yay 10 | makepkg -si -S --noconfirm 11 | cd $current_dir 12 | 13 | # Install AUR Packages 14 | # yay -Syyu --noconfirm \ 15 | # vulkan-amdgpu-pro \ 16 | # amf-amdgpu-pro \ 17 | # amdgpu-pro-libgl \ 18 | # openrazer-meta \ 19 | # polychromatic \ 20 | # microsoft-edge-stable-bin \ 21 | # cockpit-navigator \ 22 | # cockpit-zfs-manager 23 | 24 | yay -Syyu --noconfirm openrazer-driver-dkms polychromatic microsoft-edge-stable-bin cockpit-navigator 25 | 26 | # Configure Razer Drivers 27 | gpasswd -a shobuprime plugdev 28 | systemctl enable openrazer-daemon.service 29 | 30 | # Install zsh 31 | pacman -Syyu --needed --noconfirm \ 32 | zsh \ 33 | grml-zsh-config 34 | 35 | chsh --shell /bin/zsh -------------------------------------------------------------------------------- /.examples/original_shell/configure_zfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Installing Arch on ZFS\n" 4 | 5 | # Ensure network connectivity 6 | # ip a 7 | 8 | # List block devices 9 | # lsblk 10 | 11 | # List devices by id 12 | # ls -lah /dev/disk/by-id/ 13 | 14 | # Manual Partition disk (using values from 5700g ITX) 15 | # gdisk /dev/nvme1n1 16 | # gdisk /dev/nvme2n1 17 | 18 | # Command: n 19 | # Partition number: \n (1) 20 | # First sector: \n 21 | # Last sector: +600M 22 | # Hex code or GUID: ef00 23 | 24 | # Command: n 25 | # Partition number: \n (2) 26 | # First sector: \n 27 | # Last sector: \n 28 | # Hex code or GUID: bf00 29 | 30 | # Command: p 31 | 32 | # Command: w 33 | # Command: Y 34 | 35 | # sgdisk --zap-all /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_ 36 | # sgdisk -n1:0:+600M -t1:ef00 /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_ 37 | # sgdisk -n2:0:0 -t2:bf00 /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_ 38 | 39 | wipefs -a /dev/nvme1n1 40 | sgdisk --zap-all /dev/nvme1n1 41 | sgdisk -o /dev/nvme1n1 42 | sgdisk -n 1::+600M -t 1:ef00 /dev/nvme1n1 43 | sgdisk -n 2:: -t 2:bf00 /dev/nvme1n1 44 | 45 | # sgdisk --zap-all /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_ 46 | # sgdisk -n1:0:+600M -t1:ef00 /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_ 47 | # sgdisk -n2:0:0 -t2:bf00 /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_ 48 | 49 | wipefs -a /dev/nvme2n1 50 | sgdisk --zap-all /dev/nvme2n1 51 | sgdisk -o /dev/nvme2n1 52 | sgdisk -n 1::+600M -t 1:ef00 /dev/nvme2n1 53 | sgdisk -n 2:: -t 2:bf00 /dev/nvme2n1 54 | 55 | # Make EFI partition fat32 56 | # mkfs.vfat /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_-part1 57 | mkfs.vfat /dev/nvme1n1p1 58 | 59 | # mkfs.vfat /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_-part1 60 | mkfs.vfat /dev/nvme2n1p1 61 | 62 | # Load zfs modules 63 | modprobe zfs 64 | 65 | # Check that modules are loaded 66 | lsmod | grep -i zfs 67 | 68 | # Create zpool 69 | # zpool create -f -o ashift=12 \ 70 | # -O acltype=posixacl \ 71 | # -O relatime=on \ 72 | # -O xattr=sa \ 73 | # -O dnodesize=legacy \ 74 | # -O normalization=formD \ 75 | # -O mountpoint=none \ 76 | # -O canmount=off \ 77 | # -O devices=off \ 78 | # -R /mnt \ 79 | # -O compression=zstd \ 80 | # zroot mirror /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_-part2 /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_-part2 81 | 82 | zpool create -f -o ashift=12 \ 83 | -O acltype=posixacl \ 84 | -O relatime=on \ 85 | -O xattr=sa \ 86 | -O dnodesize=legacy \ 87 | -O normalization=formD \ 88 | -O mountpoint=none \ 89 | -O canmount=off \ 90 | -O devices=off \ 91 | -R /mnt \ 92 | -O compression=zstd \ 93 | -O dedup=on \ 94 | zroot mirror /dev/nvme1n1p2 /dev/nvme2n1p2 95 | 96 | zpool status 97 | zfs create -o mountpoint=none zroot/data 98 | zfs create -o mountpoint=none zroot/ROOT 99 | zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default 100 | zfs create -o mountpoint=/home zroot/data/home 101 | zfs create -o mountpoint=/var -o canmount=off zroot/var 102 | # zfs create zroot/var/log 103 | zfs create -o mountpoint=/var/lib -o canmount=off zroot/var/lib 104 | zfs create zroot/var/lib/libvirt 105 | zfs create zroot/var/lib/docker 106 | zpool export zroot 107 | # zpool import -d /dev/disk/by-id/nvme-Samsung_970_PRO_512GB_-part2 -R /mnt zroot -N 108 | # zpool import -d /dev/nvme1n1p2 -R /mnt zroot -N 109 | zpool import -d /dev/nvme1n1p2 -R /mnt zroot -N 110 | zfs mount zroot/ROOT/default 111 | zfs mount -a 112 | 113 | zpool set bootfs=zroot/ROOT/default zroot 114 | zpool set cachefile=/etc/zfs/zpool.cache zroot 115 | mkdir -p /mnt/{etc/zfs,boot} 116 | cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache 117 | 118 | mount /dev/nvme1n1p1 /mnt/boot 119 | 120 | pacman -Syu --noconfirm 121 | 122 | # amd/intel-ucode depending on system 123 | pacstrap /mnt base base-devel dkms git amd-ucode linux linux-firmware linux-headers nano vim --needed --noconfirm 124 | 125 | genfstab -U -p /mnt >> /mnt/etc/fstab 126 | 127 | chmod +x ./configure_arch.sh 128 | cp ./configure_arch.sh /mnt/configure_arch.sh 129 | chmod +x ./configure_user.sh 130 | cp ./configure_user.sh /mnt/configure_user.sh 131 | zpool status 132 | # echo "Running 'arch-chroot /mnt' -- please run './configure_arch.sh' next" 133 | # arch-chroot /mnt 134 | 135 | # ( arch-chroot /mnt /usr/bin/runuser /configure_arch.sh )|& tee 2-arch.log 136 | # ( arch-chroot /mnt /usr/bin/runuser -u shobuprime -- /configure_user.sh )|& tee 2-user.log 137 | 138 | arch-chroot /mnt /configure_arch.sh 139 | # arch-chroot /mnt /usr/bin/runuser -u shobuprime -- /configure_user.sh -------------------------------------------------------------------------------- /.github/workflows/go-build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | tags: 5 | - v* 6 | branches: 7 | - master 8 | - main 9 | pull_request: 10 | permissions: 11 | contents: write 12 | # Optional: allow read access to pull request. Use with `only-new-issues` option. 13 | # pull-requests: read 14 | jobs: 15 | compile-shobuarch: 16 | name: go_build 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@master 20 | 21 | - name: Checkout 22 | uses: actions/checkout@master 23 | 24 | - name: Set up Go 25 | uses: actions/setup-go@master 26 | with: 27 | go-version: 1.23 28 | 29 | - name: Build 30 | run: go build -o ./.build/ -v ./... 31 | 32 | - name: Test 33 | run: go test -v ./... 34 | 35 | # - name: Upload Artifact 36 | # uses: actions/upload-artifact@master 37 | # with: 38 | # name: ShobuArch 39 | # path: ./.build/ 40 | 41 | - name: Commit Build 42 | run: | 43 | git config --global user.name '${{ secrets.GIT_USER }}' 44 | git config --global user.email '${{ secrets.GIT_EMAIL }}' 45 | git remote set-url --push origin https://x-access-token:${{ secrets.ShobuArch_Builder }}@github.com/ShobuPrime/ShobuArch.git 46 | git add -A 47 | git commit -am "Automated Build" 48 | git push origin main 49 | 50 | -------------------------------------------------------------------------------- /.github/workflows/golangci-lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | push: 4 | tags: 5 | - v* 6 | branches: 7 | - master 8 | - main 9 | pull_request: 10 | permissions: 11 | contents: read 12 | # Optional: allow read access to pull request. Use with `only-new-issues` option. 13 | # pull-requests: read 14 | jobs: 15 | golangci: 16 | name: lint 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/setup-go@master 20 | - uses: actions/checkout@master 21 | 22 | - name: golangci-lint 23 | uses: golangci/golangci-lint-action@master 24 | with: 25 | # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version 26 | version: latest 27 | 28 | # Optional: working directory, useful for monorepos 29 | # working-directory: somedir 30 | 31 | # Optional: golangci-lint command line arguments. 32 | # args: --issues-exit-code=0 33 | 34 | # Optional: show only new issues if it's a pull request. The default value is `false`. 35 | # only-new-issues: true 36 | 37 | # Optional: if set to true then the all caching functionality will be complete disabled, 38 | # takes precedence over all other caching options. 39 | # skip-cache: true 40 | 41 | # Optional: if set to true then the action don't cache or restore ~/go/pkg. 42 | # skip-pkg-cache: true 43 | 44 | # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. 45 | # skip-build-cache: true 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShobuArch -- Automated Arch Linux Tools (Written in Go) 2 | [![Lint Status](https://github.com/ShobuPrime/ShobuArch/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/marketplace/actions/run-golangci-lint) 3 | [![Build Status](https://github.com/ShobuPrime/ShobuArch/actions/workflows/go-build.yml/badge.svg)](https://github.com/ShobuPrime/ShobuArch/actions/workflows/go-build.yml) 4 | [![Go Report Card](https://goreportcard.com/badge/github.com/ShobuPrime/ShobuArch)](https://goreportcard.com/report/github.com/ShobuPrime/ShobuArch) 5 | [![License](https://img.shields.io/badge/License-GPLv3-success.svg)](./LICENSE.md) 6 | 7 | 8 | 9 | Have you ever wanted to use an IaC (Infrastructure as Code) approach towards automating an Arch Linux environment? If so, this README should help with getting you get what you need. 10 | 11 | --- 12 | ### Why does this exist? 13 | There are other Automated Linux installers, and there's nothing wrong with them if your needs are met. However, if you're a ZFS fan most alternatives don't account for ZFS on Root, let alone a mirrored configuration! 14 | 15 | On a personal level, I'm finally making efforts to run Linux as my daily driver since I believe we are approaching the time of the Linux Desktop. Most tools I enjoy to use these days are written in Go, and I wanted to become a Gopher myself. 16 | 17 | In addition, the release of the Steam Deck has motivated me to ensure I get Arch Linux configured exactly the way I want. 18 | 19 | Implementing a project like this was practical for me to easily and consistently repeat multiple OS installs while ensuring I improve my skills in another language. 20 | 21 | --- 22 | ## Create Arch ISO or Use Image 23 | Download ArchISO from and put on a USB drive with [Etcher](https://www.balena.io/etcher/), [Ventoy](https://www.ventoy.net/en/index.html), or [Rufus](https://rufus.ie/en/) 24 | 25 | If you're looking for ZFS on Root, ensure to use an ISO with ZFS packages pre-installed. 26 | 27 | Some archiso wrappers include: and 28 | 29 | Another helpful guide can be found at 30 | 31 | ## Boot Arch ISO 32 | 33 | If running ShobuArch from official repository, run the following commands on a fresh boot of your ISO: 34 | 35 | ``` 36 | pacman -Syy git 37 | git clone https://github.com/ShobuPrime/ShobuArch.git 38 | cd ShobuArch/.build 39 | chmod +x ShobuArch 40 | ./ShobuArch 41 | ``` 42 | 43 | ShobuArch runs both with and without arguments. Currently, supported flags are: 44 | 45 | ``` 46 | -config string 47 | 'y': Load config, 'n': Fresh config (default "n") 48 | -format string 49 | Accepted: 'JSON' || 'YAML' (default "json") 50 | -method string 51 | 'a': Automated, 'm': Manual (default "m") 52 | ``` 53 | 54 | ### System Description 55 | Depending on arguments used, ShobuArch prompts the user for information deemed important for a coherent OS install: 56 | - Username 57 | - Password 58 | - Filesystem 59 | - Kernel 60 | - Desktop Environment 61 | - Window Manager 62 | - AUR helper 63 | - etc. 64 | 65 | ## Troubleshooting 66 | 67 | __[Official Arch Installation Guide](https://wiki.archlinux.org/title/Installation_guide)__ 68 | 69 | __[Install Ach Linux on ZFS](https://wiki.archlinux.org/title/Install_Arch_Linux_on_ZFS)__ 70 | 71 | __[Arch Linux Installed on ZFS](https://michaelabrahamsen.com/posts/arch-linux-installed-on-zfs/)__ 72 | 73 | ShobuArch generates a logfile including every command ran, and its STDOUT and STDERR outputs. If something ended up not working the way you want, you should be able to dig through the logs to find what commands started to Go wonky. 74 | 75 | # To-Do 76 | - Add some GIFS or screenshots of the tool working in action 77 | 78 | # Planned Features 79 | - Offline ISO builder 80 | - Verbosity flag, since right now the log is naturally very verbose 81 | - Implement some sort of `resume` mechanism if a specific function failed very poorly, so we can continue from where we left off 82 | 83 | # Known Issues 84 | - When generating a fresh config through the UI, [util-linux v2.38](https://github.com/util-linux/util-linux/releases/tag/v2.38) added new key-value pairs which are being returned incorrectly. [A fix was committed](https://github.com/util-linux/util-linux/commit/97ce458a0dc2465fca2b36a6a4aa3378b607476e). 85 | - You can workaround this issue my manually creating your config and loading it. A temp fix was also implemented via [this commit](https://github.com/ShobuPrime/ShobuArch/commit/5811003470471982ddcca68f726ea1d5584e4dc7) to only return "working" fields. 86 | 87 | ## Credits 88 | 89 | - Inspiration for the project came from the philosophy of [ArchTitus](https://github.com/ChrisTitusTech/ArchTitus) 90 | - Thank you Reddit User /u/BrenekH for [helping solve my Go Report Card issues](https://www.reddit.com/r/golang/comments/u0kg78/shobuarch_automated_arch_linux_tools_written_in_go/i46pgnq?utm_medium=android_app&utm_source=share&context=3) 91 | - Thank you Reddit User /u/AladW for [identifying an issue with hostnames](https://www.reddit.com/r/archlinux/comments/u0kh1a/shobuarch_automated_arch_linux_tools_written_in_go/i46kvsk?utm_medium=android_app&utm_source=share&context=3) 92 | - Thank you Reddit user /u/Max_yask for [suggesting significant feature requests such as YAML and sourcing dotfiles](https://www.reddit.com/r/linuxadmin/comments/u0ki4j/comment/i49qxag/?utm_source=share&utm_medium=web2x&context=3) 93 | -------------------------------------------------------------------------------- /debug.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package main 19 | 20 | import ( 21 | "fmt" 22 | 23 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 24 | // i "github.com/ShobuPrime/ShobuArch/pkg/install" 25 | u "github.com/ShobuPrime/ShobuArch/pkg/util" 26 | ) 27 | 28 | func debug() { 29 | 30 | // Change values as you'd like here, and call relevant functions below 31 | cdb := conf.Config{ 32 | Format: "YAML", 33 | Bootloader: "", 34 | Kernel: "linux-zen", 35 | Hostname: "", 36 | Timezone: "", 37 | Modules: []string{``}, 38 | User: conf.User{ 39 | Username: "shobuprime", 40 | Password: "demo", 41 | Language: conf.Language{ 42 | Locale: "en_US.UTF-8", 43 | CharSet: "UTF-8", 44 | Keyboard: "us", 45 | }, 46 | }, 47 | Storage: conf.Storage{ 48 | SystemDisk: "", 49 | SystemDiskID: "", 50 | MirrorInstall: false, 51 | MirrorDisk: "", 52 | MirrorDiskID: "", 53 | Filesystem: "", 54 | EncryptionKey: "", 55 | EncryptionUUID: "", 56 | }, 57 | Desktop: conf.Desktop{ 58 | Environment: "", 59 | InstallType: "", 60 | }, 61 | Pacman: conf.Pacman{ 62 | AUR: conf.AURs{ 63 | Helper: "", 64 | Packages: []string{``}, 65 | }, 66 | Packages: []string{ 67 | `keepassxc`, 68 | }, 69 | }, 70 | Flatpak: conf.Flatpaks{ 71 | Packages: []string{ 72 | `com.brave.Browser`, 73 | `com.microsoft.Edge`, 74 | `com.synology.SynologyDrive`, 75 | }, 76 | }, 77 | PWA: conf.PWAs{ 78 | Sites: []conf.Site{ 79 | { 80 | Name: "Messages", 81 | Description: "Simple, helpful messaging by Google", 82 | StartUrl: "https://messages.google.com/web", 83 | Manifest: "manifest.json", 84 | }, 85 | { 86 | Name: "YouTube", 87 | Description: "Share your videos with friends, family, and the world.", 88 | StartUrl: "https://www.youtube.com", 89 | Manifest: "manifest.webmanifest", 90 | }, 91 | }, 92 | }, 93 | } 94 | 95 | _ = cdb 96 | 97 | // Call functions you would like to test 98 | fmt.Println(u.PrettyJson(u.ListUSB())) 99 | // u.BiometricIDs() 100 | // i.SetupBiometrics(&cdb) 101 | // fmt.Println(u.PrettyJson(u.ListPCI())) 102 | // fmt.Println(u.PrettyJson(u.SecureBootStatus())) 103 | // i.UserPWAs(&cdb) 104 | } 105 | 106 | /* 107 | --Generate Keyfile: https://wiki.archlinux.org/title/Dm-crypt/Device_encryption#Keyfiles 108 | dd if=/dev/random of=/.luks/.ata--part1 bs=32 count=1 109 | cryptsetup luksAddKey /dev/sda1 /.luks/.key 110 | 111 | --Get UUID of parent partition 112 | lsblk -dno UUID /dev/sda1 113 | 114 | --Add entry to /etc/crypttab: https://kifarunix.com/automount-luks-encrypted-device-in-linux/ 115 | # 116 | luks_DATA UUID= /.luks/ata--part1 117 | 118 | --Get UUID of encryped partition (Open device if not done so already) 119 | cryptsetup open /dev/disk/by-id/ata--part1 luks_DATA --key-file /.luks/ata--part1 120 | mount -o rw,noatime,compress=zstd:3,ssd,discard,space_cache=v2,commit=120,subvol=@ /dev/mapper/luks_DATA /mnt/ata--part1 121 | lsblk -dno UUID /dev/mapper/luks_DATA 122 | 123 | --Print new fstab and verify if it looks ok before saving 124 | genfstab -U / 125 | 126 | --Unmount encrypted drive and run the following to verify if done correctly 127 | mount -av 128 | 129 | 130 | VSCode install extensions from CMD line (online): 131 | code --list-extensions 132 | 133 | golang.go 134 | ms-python.python 135 | ms-azuretools.vscode-docker 136 | shardulm94.trailing-spaces 137 | 138 | code --install-extension 139 | 140 | https://stackoverflow.com/questions/37071388/how-can-i-install-visual-studio-code-extensions-offline#38866913 141 | https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/python/2022.19.13351014/vspackage 142 | */ 143 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ShobuPrime/ShobuArch 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/manifoldco/promptui v0.9.0 7 | golang.org/x/crypto v0.5.0 8 | gopkg.in/yaml.v2 v2.4.0 9 | ) 10 | 11 | require ( 12 | github.com/chzyer/readline v1.5.1 // indirect 13 | golang.org/x/sys v0.4.0 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 2 | github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= 3 | github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= 4 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 5 | github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= 6 | github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= 7 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 8 | github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= 9 | github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= 10 | github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= 11 | github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= 12 | golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= 13 | golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= 14 | golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 15 | golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 16 | golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= 17 | golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 18 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 19 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 20 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 21 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 22 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package main 19 | 20 | import ( 21 | "flag" 22 | "fmt" 23 | "io" 24 | "log" 25 | "os" 26 | "os/exec" 27 | "runtime" 28 | 29 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 30 | i "github.com/ShobuPrime/ShobuArch/pkg/install" 31 | 32 | "github.com/manifoldco/promptui" 33 | ) 34 | 35 | func clear() { 36 | 37 | switch host_os := runtime.GOOS; host_os { 38 | case "windows": 39 | clear := exec.Command("cmd", "/c", "cls") //Windows example, its tested 40 | clear.Stdout = os.Stdout 41 | err := clear.Run() 42 | if err != nil { 43 | log.Println(err) 44 | } 45 | default: 46 | clear := exec.Command("clear") //Linux example, its tested 47 | clear.Stdout = os.Stdout 48 | err := clear.Run() 49 | if err != nil { 50 | log.Println(err) 51 | } 52 | } 53 | } 54 | 55 | func MainLogo() { 56 | 57 | fmt.Println(` 58 | ------------------------------------------------------------------------- 59 | ███████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗██╗ ██╗ 60 | ██╔════╝██║ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝██║ ██║ 61 | ███████╗███████║██║ ██║██████╔╝██║ ██║███████║██████╔╝██║ ███████║ 62 | ╚════██║██╔══██║██║ ██║██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ 63 | ███████║██║ ██║╚██████╔╝██████╔╝╚██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ 64 | ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ 65 | ------------------------------------------------------------------------- 66 | Automated Arch Linux Tools 67 | ------------------------------------------------------------------------- 68 | `) 69 | } 70 | 71 | func getFormat(c *conf.Config) { 72 | prompt := promptui.Select{ 73 | Label: "Preferred configuration format?", 74 | Items: []string{"JSON", "YAML"}, 75 | } 76 | _, format_choice, err := prompt.Run() 77 | if err != nil { 78 | log.Printf("Format selection failed %v\n", err) 79 | return 80 | } 81 | 82 | c.Format = format_choice 83 | log.Printf("Config format is %q", c.Format) 84 | } 85 | 86 | func config(c *conf.Config) { 87 | 88 | conf.Logo() 89 | conf.SetKernel(c) 90 | conf.SetBootloader(c) 91 | conf.BasePkgs(c) 92 | clear() 93 | 94 | conf.Logo() 95 | conf.SetUserInfo(c) 96 | clear() 97 | 98 | conf.Logo() 99 | conf.SetHostInfo(c) 100 | clear() 101 | 102 | conf.Logo() 103 | c.Storage.SystemDisk, c.Storage.SystemDiskID, c.Storage.SystemDiskRota = conf.SelectDisk() 104 | conf.SetFilesystem(c) 105 | clear() 106 | 107 | conf.Logo() 108 | conf.SetInstallType(c) 109 | conf.SelectDesktopEnv(c) 110 | conf.SelectAUR(c) 111 | conf.Flatpak(c) 112 | conf.PWA(c) 113 | clear() 114 | 115 | conf.Logo() 116 | conf.SetTimezone(c) 117 | conf.SetKeyboardLayout(c) 118 | clear() 119 | 120 | conf.Logo() 121 | conf.SetLocale(c) 122 | clear() 123 | } 124 | 125 | func preinstall(c *conf.Config) { 126 | i.PreInstallLogo() 127 | i.Prerequisites(c) 128 | i.FormatDisks(c) 129 | i.Mirrors(c) 130 | i.ArchInstall(c) 131 | clear() 132 | 133 | log.Println(` 134 | ------------------------------------------------------------------------- 135 | SYSTEM READY FOR SETUP 136 | ------------------------------------------------------------------------- 137 | `) 138 | } 139 | 140 | func setup(c *conf.Config) { 141 | i.SetupLogo() 142 | i.SetupHostname(c) 143 | i.SetupNetwork(c) 144 | i.SetupMirrors(c) 145 | 146 | // Remember, exec.Command doesn't use quotes. trying without them first 147 | 148 | i.SetupResources(c) 149 | i.SetupLanguage(c) 150 | i.SetupBaseSystem(c) 151 | i.SetupServices(c) 152 | i.SetupCustomRepos(c) 153 | i.SetupProcessor(c) 154 | i.SetupGraphics(c) 155 | i.SetupBiometrics(c) 156 | i.SetupMiscHardware(c) 157 | i.SetupUser(c) 158 | i.SetupSecurityModules(c) 159 | i.SetupAUR(c) 160 | i.SetupFlatpaks(c) 161 | i.SetupEFI(c) 162 | i.SetupSecureBoot(c) 163 | 164 | clear() 165 | 166 | log.Println(` 167 | ------------------------------------------------------------------------- 168 | SYSTEM READY FOR USER 169 | ------------------------------------------------------------------------- 170 | `) 171 | } 172 | 173 | func user(c *conf.Config) { 174 | i.UserLogo() 175 | i.UserLocale(c) 176 | i.UserPackages(c) 177 | i.UserKeyring(c) 178 | i.UserPWAs(c) 179 | i.UserVariables(c) 180 | i.UserDotFiles(c) 181 | i.UserShell(c) 182 | clear() 183 | 184 | log.Println(` 185 | ------------------------------------------------------------------------- 186 | SYSTEM READY FOR POST-CHECKS 187 | ------------------------------------------------------------------------- 188 | `) 189 | } 190 | 191 | func postinstall(c *conf.Config) { 192 | i.PostInstallLogo() 193 | i.PostInstallCleanup(c) 194 | i.PostInstallUnmount(c) 195 | 196 | log.Println(` 197 | ------------------------------------------------------------------------- 198 | INSTALLATION COMPLETE!!! 199 | ------------------------------------------------------------------------- 200 | `) 201 | } 202 | 203 | func main() { 204 | 205 | // Initialize Logs 206 | LOG_FILE := "./shobuarch.log" 207 | log_file, err := os.OpenFile(LOG_FILE, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644) 208 | if err != nil { 209 | log.Panic(err) 210 | } 211 | log_out := io.MultiWriter(os.Stdout, log_file) 212 | defer log_file.Close() 213 | 214 | log.SetOutput(log_out) 215 | 216 | // optional: log date-time, filename, and line number 217 | log.SetFlags(log.Lshortfile | log.LstdFlags) 218 | 219 | log.Println("Initializing ShobuArch logs...") 220 | 221 | clear() 222 | MainLogo() 223 | c := conf.Config{} 224 | 225 | // https://gobyexample.com/command-line-flags 226 | method_flag := flag.String("method", "m", `'a': Automated, 'm': Manual`) 227 | config_flag := flag.String("config", "n", `'y': Load config, 'n': Fresh config`) 228 | format_flag := flag.String("format", "json", `Accepted: 'JSON' || 'YAML'`) 229 | flag.Parse() 230 | 231 | c.Format = *format_flag 232 | 233 | if *method_flag == "a" { 234 | if *config_flag != "y" { 235 | log.Println("Automated installation detected, but 'config' flag is not set properly.") 236 | log.Fatalln("Type '--help' as a command-line argument to see available flag options") 237 | } else { 238 | conf.LoadConfig(&c) 239 | preinstall(&c) 240 | setup(&c) 241 | user(&c) 242 | postinstall(&c) 243 | } 244 | } else { 245 | log.Println("Manual installation detected.") 246 | prompt := promptui.Select{ 247 | Label: "Start fresh, or load existing config?", 248 | Items: []string{"Start fresh", "Load config", "Debug"}, 249 | } 250 | _, prompt_choice, err := prompt.Run() 251 | if err != nil { 252 | log.Printf("Config selection failed %v\n", err) 253 | return 254 | } 255 | 256 | getFormat(&c) 257 | 258 | if prompt_choice == "Debug" { 259 | debug() 260 | } else if *config_flag == "y" || prompt_choice == "Load config" { 261 | // Future release: load directory and use recursive ui to find config in file system 262 | // Or, we can accept filename as flag, config as singleline json, etc. 263 | conf.LoadConfig(&c) 264 | preinstall(&c) 265 | setup(&c) 266 | user(&c) 267 | postinstall(&c) 268 | } else { 269 | clear() 270 | config(&c) 271 | preinstall(&c) 272 | setup(&c) 273 | user(&c) 274 | postinstall(&c) 275 | } 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /pkg/config/config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package config 19 | 20 | import ( 21 | "bufio" 22 | "encoding/json" 23 | "fmt" 24 | "log" 25 | "os" 26 | "strings" 27 | 28 | "gopkg.in/yaml.v2" 29 | 30 | u "github.com/ShobuPrime/ShobuArch/pkg/util" 31 | 32 | "github.com/manifoldco/promptui" 33 | "golang.org/x/crypto/bcrypt" 34 | ) 35 | 36 | type Config struct { 37 | Format string `json:"-" yaml:"-"` 38 | Kernel string `json:"kernel" yaml:"kernel"` 39 | Bootloader string `json:"bootloader" yaml:"bootloader"` 40 | Modules []string `json:"-" yaml:"-"` 41 | Parameters []string `json:"-" yaml:"-"` 42 | Hooks []string `json:"-" yaml:"-"` 43 | Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` 44 | Timezone string `json:"timezone,omitempty" yaml:"timezone,omitempty"` 45 | User User `json:"user" yaml:"user"` 46 | Storage Storage `json:"storage" yaml:"storage"` 47 | Desktop Desktop `json:"desktop,omitempty" yaml:"desktop,omitempty"` 48 | Pacman Pacman `json:"pacman,omitempty" yaml:"pacman,omitempty"` 49 | Flatpak Flatpaks `json:"flatpak,omitempty" yaml:"flatpak,omitempty"` 50 | PWA PWAs `json:"pwa,omitempty" yaml:"pwa,omitempty"` 51 | } 52 | 53 | type User struct { 54 | Username string `json:"username" yaml:"username"` 55 | Password string `json:"password" yaml:"password"` 56 | Language Language `json:"language" yaml:"language"` 57 | Shell string `json:"user_shell,omitempty" yaml:"shell,omitempty"` 58 | Git Git `json:"git,omitempty" yaml:"git,omitempty"` 59 | } 60 | 61 | type Language struct { 62 | Locale string `json:"locale,omitempty" yaml:"locale,omitempty"` 63 | CharSet string `json:"charset,omitempty" yaml:"charset,omitempty"` 64 | Keyboard string `json:"keyboard_layout,omitempty" yaml:"keyboard,omitempty"` 65 | } 66 | 67 | type Git struct { 68 | Username string `json:"git_username,omitempty" yaml:"git_username,omitempty"` 69 | Email string `json:"git_email,omitempty" yaml:"git_password,omitempty"` 70 | } 71 | 72 | type Storage struct { 73 | SystemDisk string `json:"system_disk" yaml:"system_disk"` 74 | SystemDiskID string `json:"system_disk_id,omitempty" yaml:"system_disk_id,omitempty"` 75 | SystemDiskRota bool `json:"system_disk_rota,omitempty" yaml:"sysem_disk_rota,omitempty"` 76 | MirrorInstall bool `json:"mirror_install" yaml:"mirror_install"` 77 | MirrorDisk string `json:"mirror_disk,omitempty" yaml:"mirror_disk,omitempty"` 78 | MirrorDiskID string `json:"mirror_disk_id,omitempty" yaml:"mirror_disk_id,omitempty"` 79 | MirrorDiskRota bool `json:"mirror_disk_rota,omitempty" yaml:"mirror_disk_rota,omitempty"` 80 | Filesystem string `json:"filesystem,omitempty" yaml:"filesystem,omitempty"` 81 | EncryptionKey string `json:"encryption_key,omitempty" yaml:"encryption_key,omitempty"` 82 | EncryptionUUID string `json:"encryption_uuid,omitempty" yaml:"encryption_uuid,omitempty"` 83 | } 84 | 85 | type Desktop struct { 86 | Environment string `json:"environment,omitempty" yaml:"environment,omitempty"` 87 | InstallType string `json:"install_type,omitempty" yaml:"install_type,omitempty"` 88 | } 89 | 90 | type Pacman struct { 91 | AUR AURs `json:"aur,omitempty" yaml:"aur,omitempty"` 92 | Packages []string `json:"packages,omitempty" yaml:"packages,omitempty"` 93 | } 94 | 95 | type AURs struct { 96 | Helper string `json:"aur_helper,omitempty" yaml:"aur_helper,omitempty"` 97 | Packages []string `json:"aur_packages,omitempty" yaml:"aur_packages,omitempty"` 98 | } 99 | 100 | type Flatpaks struct { 101 | Packages []string `json:"packages" yaml:"packages"` 102 | } 103 | 104 | type PWAs struct { 105 | Sites []Site `json:"sites" yaml:"sites"` 106 | } 107 | 108 | type Site struct { 109 | Name string `json:"name" yaml:"name"` 110 | Description string `json:"description" yaml:"description"` 111 | StartUrl string `json:"start_url,omitempty" yaml:"start_url,omitempty"` 112 | Manifest string `json:"manifest" yaml:"manifest"` 113 | } 114 | 115 | func Logo() { 116 | 117 | log.Println(` 118 | ------------------------------------------------------------------------- 119 | ███████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗██╗ ██╗ 120 | ██╔════╝██║ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝██║ ██║ 121 | ███████╗███████║██║ ██║██████╔╝██║ ██║███████║██████╔╝██║ ███████║ 122 | ╚════██║██╔══██║██║ ██║██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ 123 | ███████║██║ ██║╚██████╔╝██████╔╝╚██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ 124 | ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ 125 | ------------------------------------------------------------------------- 126 | Please select presetup settings for your system 127 | ------------------------------------------------------------------------- 128 | `) 129 | } 130 | 131 | func InitConfig() *Config { 132 | c := Config{} 133 | return &c 134 | } 135 | 136 | func SetKernel(c *Config) { 137 | prompt := promptui.Select{ 138 | Label: "Please select your Linux kernel", 139 | Items: []string{"Stable", "Hardened", "Longterm", "Zen"}, 140 | Size: 4, 141 | } 142 | 143 | _, kernel_choice, err := prompt.Run() 144 | 145 | if err != nil { 146 | log.Printf("Kernel selection failed %v\n", err) 147 | return 148 | } 149 | 150 | // https://wiki.archlinux.org/title/Kernel#Officially_supported_kernels 151 | switch kernel_choice { 152 | case "Stable": 153 | c.Kernel = "linux" 154 | case "Hardened": 155 | c.Kernel = "linux-hardened" 156 | case "Longterm": 157 | c.Kernel = "linux-lts" 158 | case "Zen": 159 | c.Kernel = "linux-zen" 160 | } 161 | 162 | log.Printf("Selected %q kernel -- %q\n", kernel_choice, c.Kernel) 163 | 164 | SaveConfig(c) 165 | } 166 | 167 | func SetBootloader(c *Config) { 168 | prompt := promptui.Select{ 169 | Label: "Please select your preferred bootloader", 170 | Items: []string{"grub", "systemd-boot"}, 171 | Size: 4, 172 | } 173 | 174 | _, bootloader_choice, err := prompt.Run() 175 | 176 | if err != nil { 177 | log.Printf("Kernel selection failed %v\n", err) 178 | return 179 | } 180 | 181 | switch bootloader_choice { 182 | case "grub": 183 | c.Bootloader = "grub" 184 | case "systemd-boot": 185 | c.Bootloader = "systemd-boot" 186 | } 187 | 188 | log.Printf("Selected %q to boot with -- %q\n", bootloader_choice, c.Bootloader) 189 | } 190 | 191 | func SetUserInfo(c *Config) { 192 | input := bufio.NewReader(os.Stdin) 193 | fmt.Print("Please enter your username: ") 194 | username, _ := input.ReadString('\n') 195 | username = strings.TrimSuffix(username, "\n") 196 | log.Printf("Your username is: %q\n", username) 197 | c.User.Username = strings.ToLower(username) 198 | c.User.Password = SetPassword("user") 199 | SaveConfig(c) 200 | } 201 | 202 | func SetPassword(target string) string { 203 | input := bufio.NewReader(os.Stdin) 204 | fmt.Print("Please enter " + target + " password: ") 205 | password, _ := input.ReadString('\n') 206 | password = strings.TrimSuffix(password, "\n") 207 | 208 | // Generate "hash" to store from user password 209 | hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) 210 | if err != nil { 211 | // TODO: Properly handle error 212 | log.Fatal(err) 213 | } 214 | log.Printf("Hash to store: %v\n", string(hash)) 215 | log.Println("Store this 'hash' somewhere safe") 216 | 217 | // After a while, the user wants to log in and you need to check the password he entered 218 | input = bufio.NewReader(os.Stdin) 219 | fmt.Print("Please confirm " + target + " password: ") 220 | confirmed_pass, _ := input.ReadString('\n') 221 | confirmed_pass = strings.TrimSuffix(confirmed_pass, "\n") 222 | hashFromDatabase := hash 223 | 224 | // Comparing the password with the hash 225 | if err := bcrypt.CompareHashAndPassword(hashFromDatabase, []byte(confirmed_pass)); err != nil { 226 | // TODO: Properly handle error 227 | log.Println("Encryption Keys do not match") 228 | log.Fatal(err) 229 | } else { 230 | log.Println("Encryption Keys match!") 231 | return password 232 | } 233 | 234 | // Placeholder statement 235 | return "" 236 | } 237 | 238 | func SetHostInfo(c *Config) { 239 | input := bufio.NewReader(os.Stdin) 240 | fmt.Print("Please enter your hostname: ") 241 | hostname, _ := input.ReadString('\n') 242 | hostname = strings.TrimSuffix(hostname, "\n") 243 | log.Printf("Your username is: %q\n", hostname) 244 | c.Hostname = hostname 245 | 246 | SaveConfig(c) 247 | } 248 | 249 | // To-do: Ask for git info 250 | func SetGitInfo() { 251 | 252 | } 253 | 254 | func SelectAUR(c *Config) { 255 | prompt := promptui.Select{ 256 | Label: "Please select desired AUR helper", 257 | Items: []string{"yay", "aura", "pacaur", "pakku", "paru", "pikaur", "trizen", "none"}, 258 | Size: 7, 259 | } 260 | 261 | _, aur_choice, err := prompt.Run() 262 | 263 | if err != nil { 264 | log.Printf("AUR selection failed %v\n", err) 265 | return 266 | } 267 | 268 | c.Pacman.AUR.Helper = aur_choice 269 | 270 | AUR(c) 271 | SaveConfig(c) 272 | } 273 | 274 | func SelectDesktopEnv(c *Config) { 275 | prompt := promptui.Select{ 276 | Label: "Please select your desired Desktop Environment", 277 | Items: []string{ 278 | "kde", "gnome", "cinnamon", 279 | "xfce", "mate", "budgie", 280 | "lxde", "deepin", "openbox", 281 | "server", 282 | }, 283 | } 284 | 285 | _, desktop_choice, err := prompt.Run() 286 | 287 | if err != nil { 288 | log.Printf("Desktop selection failed %v\n", err) 289 | return 290 | } 291 | 292 | c.Desktop.Environment = desktop_choice 293 | log.Printf("Your desktop environment is: %q\n", c.Desktop.Environment) 294 | 295 | switch c.Desktop.Environment { 296 | case "gnome": 297 | Gnome(c) 298 | case "kde": 299 | KDE(c) 300 | case "cinnamon": 301 | Cinnamon(c) 302 | case "xfce": 303 | XFCE(c) 304 | case "mate": 305 | Mate(c) 306 | case "budgie": 307 | Budgie(c) 308 | case "lxde": 309 | LXDE(c) 310 | case "deepin": 311 | Deepin(c) 312 | case "openbox": 313 | Openbox(c) 314 | case "server": 315 | Server(c) 316 | } 317 | 318 | SaveConfig(c) 319 | } 320 | 321 | func SetInstallType(c *Config) { 322 | 323 | prompt := promptui.Select{ 324 | Label: "Please select Desktop Install Type", 325 | Items: []string{"FULL", "MINIMAL"}, 326 | } 327 | 328 | _, choice, err := prompt.Run() 329 | 330 | if err != nil { 331 | log.Printf("Desktop Install Type selection failed %v\n", err) 332 | return 333 | } 334 | 335 | log.Printf("Your install method is: %q\n", choice) 336 | 337 | switch choice { 338 | case "FULL": 339 | c.Desktop.InstallType = choice 340 | case "MINIMAL": 341 | c.Desktop.InstallType = choice 342 | } 343 | } 344 | 345 | func SetFilesystem(c *Config) { 346 | prompt := promptui.Select{ 347 | Label: "Select Filesystem", 348 | Items: []string{"btrfs", "ext4", "luks", "zfs"}, 349 | } 350 | 351 | _, fs_choice, err := prompt.Run() 352 | 353 | if err != nil { 354 | fmt.Printf("Filesystem selection failed %v\n", err) 355 | return 356 | } 357 | 358 | c.Storage.Filesystem = fs_choice 359 | 360 | switch c.Storage.Filesystem { 361 | case "btrfs": 362 | SetMirror(c) 363 | case "luks": 364 | c.Storage.EncryptionKey = SetPassword("luks") 365 | case "zfs": 366 | SetMirror(c) 367 | } 368 | 369 | log.Printf("Filesystem: %q\n", c.Storage.Filesystem) 370 | SaveConfig(c) 371 | } 372 | 373 | func SetMirror(c *Config) { 374 | 375 | input := bufio.NewReader(os.Stdin) 376 | fmt.Printf("Would you like to configure a mirrored %s pool (Y/N): ", c.Storage.Filesystem) 377 | mirror_choice, _ := input.ReadString('\n') 378 | mirror_choice = strings.TrimSuffix(mirror_choice, "\n") 379 | switch strings.ToLower(mirror_choice) { 380 | case "y", "yes": 381 | log.Printf("%s mirror selected! Please select mirror disk.\n", c.Storage.Filesystem) 382 | c.Storage.MirrorInstall = true 383 | // Go version of "do while" -- Keep prompting user if mirrored disk matches root disk 384 | for same_disk := true; same_disk; same_disk = (c.Storage.MirrorDisk == c.Storage.SystemDisk) { 385 | c.Storage.MirrorDisk, c.Storage.MirrorDiskID, c.Storage.SystemDiskRota = SelectDisk() 386 | if c.Storage.MirrorDisk == c.Storage.SystemDisk { 387 | log.Println("WARNING: Same disk selected for mirror! Please select a different disk") 388 | } 389 | SaveConfig(c) 390 | } 391 | case "n", "no": 392 | log.Printf("%s will be installed on a single disk.\n", c.Storage.Filesystem) 393 | c.Storage.MirrorInstall = false 394 | } 395 | 396 | SaveConfig(c) 397 | } 398 | 399 | func SelectDisk() (string, string, bool) { 400 | 401 | lsblk := u.ListDisk() 402 | 403 | device_paths := []string{} 404 | device_ids := []string{} 405 | device_list := []string{} 406 | for i := range lsblk.Blockdevices { 407 | device_paths = append(device_paths, lsblk.Blockdevices[i].Path) 408 | lsblk.Blockdevices[i].Model = strings.ReplaceAll(lsblk.Blockdevices[i].Model, " ", "_") 409 | device_ids = append(device_ids, lsblk.Blockdevices[i].Model+"-"+lsblk.Blockdevices[i].Serial) 410 | lsblk.Blockdevices[i].Serial = strings.ReplaceAll(lsblk.Blockdevices[i].Serial, " ", "_") 411 | device_list = append(device_list, lsblk.Blockdevices[i].Path+" --> "+lsblk.Blockdevices[i].Model+"-"+lsblk.Blockdevices[i].Serial) 412 | } 413 | 414 | prompt := promptui.Select{ 415 | Label: "Select Disk", 416 | Items: device_list, 417 | } 418 | i, choice, err := prompt.Run() 419 | if err != nil { 420 | log.Fatalf("Prompt failed %v\n", err) 421 | } 422 | log.Printf("Selected disk: %v\n", choice) 423 | return device_paths[i], device_ids[i], lsblk.Blockdevices[i].Rota 424 | } 425 | 426 | func SetTimezone(c *Config) { 427 | 428 | input := bufio.NewReader(os.Stdin) 429 | fmt.Print("Enter timezone (IANA Format -- ex: America/New_York): ") 430 | tz, _ := input.ReadString('\n') 431 | tz = strings.TrimSuffix(tz, "\n") 432 | switch tz { 433 | case "": 434 | tz = `America/New_York` 435 | } 436 | log.Printf("Your timezone is: %v\n", tz) 437 | c.Timezone = tz 438 | SaveConfig(c) 439 | } 440 | 441 | func SetKeyboardLayout(c *Config) { 442 | 443 | // These are default key maps as presented in official arch repo archinstall 444 | prompt := promptui.Select{ 445 | Label: "What is your keyboard layout?", 446 | Items: []string{ 447 | "us", "by", "ca", "cf", "cz", 448 | "de", "es", "et", "fa", "fi", 449 | "fr", "gr", "hu", "il", "it", 450 | "lt", "lv", "mk", "nl", "no", 451 | "pl", "ro", "ru", "sg", "ua", 452 | "uk", 453 | }, 454 | Size: 13, 455 | } 456 | 457 | _, kb_layout, err := prompt.Run() 458 | 459 | if err != nil { 460 | log.Printf("Keyboard selection failed %v\n", err) 461 | return 462 | } 463 | 464 | c.User.Language.Keyboard = kb_layout 465 | SaveConfig(c) 466 | } 467 | 468 | func SetLocale(c *Config) { 469 | 470 | // Using UTF-8 as default for now since it's recommended from Arch's own wiki 471 | c.User.Language.CharSet = "UTF-8" 472 | 473 | prompt := promptui.Select{ 474 | Label: "What is your locale?", 475 | Items: []string{ 476 | fmt.Sprintf("aa_DJ.%s", c.User.Language.CharSet), 477 | "aa_ER", "aa_ET", 478 | fmt.Sprintf("af_ZA.%s", c.User.Language.CharSet), 479 | "agr_PE", "ak_GH", "am_ET", 480 | fmt.Sprintf("an_ES.%s", c.User.Language.CharSet), 481 | "anp_IN", 482 | fmt.Sprintf("ar_AE.%s", c.User.Language.CharSet), 483 | fmt.Sprintf("ar_BH.%s", c.User.Language.CharSet), 484 | fmt.Sprintf("ar_DZ.%s", c.User.Language.CharSet), 485 | fmt.Sprintf("ar_EG.%s", c.User.Language.CharSet), 486 | "ar_IN", 487 | fmt.Sprintf("ar_IQ.%s", c.User.Language.CharSet), 488 | fmt.Sprintf("ar_JO.%s", c.User.Language.CharSet), 489 | fmt.Sprintf("ar_KW.%s", c.User.Language.CharSet), 490 | fmt.Sprintf("ar_LB.%s", c.User.Language.CharSet), 491 | fmt.Sprintf("ar_LY.%s", c.User.Language.CharSet), 492 | fmt.Sprintf("ar_MA.%s", c.User.Language.CharSet), 493 | fmt.Sprintf("ar_OM.%s", c.User.Language.CharSet), 494 | fmt.Sprintf("ar_QA.%s", c.User.Language.CharSet), 495 | fmt.Sprintf("ar_SA.%s", c.User.Language.CharSet), 496 | fmt.Sprintf("ar_SD.%s", c.User.Language.CharSet), 497 | "ar_SS", 498 | fmt.Sprintf("ar_SY.%s", c.User.Language.CharSet), 499 | fmt.Sprintf("ar_TN.%s", c.User.Language.CharSet), 500 | fmt.Sprintf("ar_YE.%s", c.User.Language.CharSet), 501 | "ayc_PE", "az_AZ", "az_IR", "as_IN", 502 | fmt.Sprintf("ast_ES.%s", c.User.Language.CharSet), 503 | fmt.Sprintf("be_BY.%s", c.User.Language.CharSet), 504 | "bem_ZM", "ber_DZ", "ber_MA", 505 | fmt.Sprintf("bg_BG.%s", c.User.Language.CharSet), 506 | fmt.Sprintf("bhb_IN.%s", c.User.Language.CharSet), 507 | "bho_NP", "bi_VU", "bn_BD", "bn_IN", "bo_CN", "bo_IN", 508 | fmt.Sprintf("br_FR.%s", c.User.Language.CharSet), 509 | "brx_IN", 510 | fmt.Sprintf("bs_BA.%s", c.User.Language.CharSet), 511 | "byn_ER", 512 | fmt.Sprintf("C.%s", c.User.Language.CharSet), 513 | fmt.Sprintf("ca_AD.%s", c.User.Language.CharSet), 514 | fmt.Sprintf("ca_ES.%s", c.User.Language.CharSet), 515 | fmt.Sprintf("ca_FR.%s", c.User.Language.CharSet), 516 | fmt.Sprintf("ca_IT.%s", c.User.Language.CharSet), 517 | "ce_RU", "chr_US", "ckb_IQ", "cmn_TW", "crh_UA", 518 | fmt.Sprintf("cs_CZ.%s", c.User.Language.CharSet), 519 | "csb_PL", "cv_RU", 520 | fmt.Sprintf("cy_GB.%s", c.User.Language.CharSet), 521 | fmt.Sprintf("da_DK.%s", c.User.Language.CharSet), 522 | fmt.Sprintf("de_AT.%s", c.User.Language.CharSet), 523 | fmt.Sprintf("de_BE.%s", c.User.Language.CharSet), 524 | fmt.Sprintf("de_CH.%s", c.User.Language.CharSet), 525 | fmt.Sprintf("de_DE.%s", c.User.Language.CharSet), 526 | fmt.Sprintf("de_IT.%s", c.User.Language.CharSet), 527 | fmt.Sprintf("de_LI.%s", c.User.Language.CharSet), 528 | fmt.Sprintf("de_LU.%s", c.User.Language.CharSet), 529 | "doi_IN", "dsb_DE", "dv_MV", "dz_BT", 530 | fmt.Sprintf("el_GR.%s", c.User.Language.CharSet), 531 | fmt.Sprintf("el_CY.%s", c.User.Language.CharSet), 532 | "en_AG", 533 | fmt.Sprintf("en_AU.%s", c.User.Language.CharSet), 534 | fmt.Sprintf("en_BW.%s", c.User.Language.CharSet), 535 | fmt.Sprintf("en_CA.%s", c.User.Language.CharSet), 536 | fmt.Sprintf("en_DK.%s", c.User.Language.CharSet), 537 | fmt.Sprintf("en_GB.%s", c.User.Language.CharSet), 538 | fmt.Sprintf("en_HK.%s", c.User.Language.CharSet), 539 | fmt.Sprintf("en_IE.%s", c.User.Language.CharSet), 540 | "en_IL", "en_IN", "en_NG", 541 | fmt.Sprintf("en_NZ.%s", c.User.Language.CharSet), 542 | fmt.Sprintf("en_PH.%s", c.User.Language.CharSet), 543 | fmt.Sprintf("en_SC.%s", c.User.Language.CharSet), 544 | fmt.Sprintf("en_SG.%s", c.User.Language.CharSet), 545 | fmt.Sprintf("en_US.%s", c.User.Language.CharSet), 546 | fmt.Sprintf("en_ZA.%s", c.User.Language.CharSet), 547 | "en_ZM", 548 | fmt.Sprintf("en_ZW.%s", c.User.Language.CharSet), 549 | "eo", 550 | fmt.Sprintf("es_AR.%s", c.User.Language.CharSet), 551 | fmt.Sprintf("es_BO.%s", c.User.Language.CharSet), 552 | fmt.Sprintf("es_CL.%s", c.User.Language.CharSet), 553 | fmt.Sprintf("es_CO.%s", c.User.Language.CharSet), 554 | fmt.Sprintf("es_CR.%s", c.User.Language.CharSet), 555 | "es_CU", 556 | fmt.Sprintf("es_DO.%s", c.User.Language.CharSet), 557 | fmt.Sprintf("es_EC.%s", c.User.Language.CharSet), 558 | fmt.Sprintf("es_ES.%s", c.User.Language.CharSet), 559 | fmt.Sprintf("es_GT.%s", c.User.Language.CharSet), 560 | fmt.Sprintf("es_HN.%s", c.User.Language.CharSet), 561 | fmt.Sprintf("es_MX.%s", c.User.Language.CharSet), 562 | fmt.Sprintf("es_NI.%s", c.User.Language.CharSet), 563 | fmt.Sprintf("es_PA.%s", c.User.Language.CharSet), 564 | fmt.Sprintf("es_PE.%s", c.User.Language.CharSet), 565 | fmt.Sprintf("es_PR.%s", c.User.Language.CharSet), 566 | fmt.Sprintf("es_PY.%s", c.User.Language.CharSet), 567 | fmt.Sprintf("es_SV.%s", c.User.Language.CharSet), 568 | fmt.Sprintf("es_US.%s", c.User.Language.CharSet), 569 | fmt.Sprintf("es_UY.%s", c.User.Language.CharSet), 570 | fmt.Sprintf("es_VE.%s", c.User.Language.CharSet), 571 | fmt.Sprintf("et_EE.%s", c.User.Language.CharSet), 572 | fmt.Sprintf("eu_US.%s", c.User.Language.CharSet), 573 | "fa_IR", "ff_SN", 574 | fmt.Sprintf("fi_FI.%s", c.User.Language.CharSet), 575 | "fil_PH", 576 | fmt.Sprintf("fo_FO.%s", c.User.Language.CharSet), 577 | fmt.Sprintf("fr_BE.%s", c.User.Language.CharSet), 578 | fmt.Sprintf("fr_CA.%s", c.User.Language.CharSet), 579 | fmt.Sprintf("fr_CH.%s", c.User.Language.CharSet), 580 | fmt.Sprintf("fr_FR.%s", c.User.Language.CharSet), 581 | fmt.Sprintf("fr_LU.%s", c.User.Language.CharSet), 582 | "fur_IT", "fy_NL", "fy_DE", 583 | fmt.Sprintf("ga_IE.%s", c.User.Language.CharSet), 584 | fmt.Sprintf("gd_GB.%s", c.User.Language.CharSet), 585 | "gez_ER", "gez_ET", 586 | fmt.Sprintf("gl_ES.%s", c.User.Language.CharSet), 587 | "gu_IN", 588 | fmt.Sprintf("gv_GB.%s", c.User.Language.CharSet), 589 | "ha_NG", "hak_TW", 590 | fmt.Sprintf("he_IL.%s", c.User.Language.CharSet), 591 | "hi_IN", "hif_FJ", "hne_IN", 592 | fmt.Sprintf("hr_HR.%s", c.User.Language.CharSet), 593 | fmt.Sprintf("hsb_DE.%s", c.User.Language.CharSet), 594 | "ht_HT", 595 | fmt.Sprintf("hu_HU.%s", c.User.Language.CharSet), 596 | "hy_AM", "ia_FR", 597 | fmt.Sprintf("id_ID.%s", c.User.Language.CharSet), 598 | "ig_NG", "ik_CA", 599 | fmt.Sprintf("is_IS.%s", c.User.Language.CharSet), 600 | fmt.Sprintf("it_CH.%s", c.User.Language.CharSet), 601 | fmt.Sprintf("it_IT.%s", c.User.Language.CharSet), 602 | "iu_CA", 603 | fmt.Sprintf("ja_JP.%s", c.User.Language.CharSet), 604 | fmt.Sprintf("ka_GE.%s", c.User.Language.CharSet), 605 | "kab_DZ", 606 | fmt.Sprintf("kk_KZ.%s", c.User.Language.CharSet), 607 | fmt.Sprintf("kl_GL.%s", c.User.Language.CharSet), 608 | "km_KH", "kn_IN", 609 | fmt.Sprintf("ko_KR.%s", c.User.Language.CharSet), 610 | "kok_IN", "ks_IN", 611 | fmt.Sprintf("ku_TR.%s", c.User.Language.CharSet), 612 | fmt.Sprintf("kw_GB.%s", c.User.Language.CharSet), 613 | "ky_KG", "lb_LU", 614 | fmt.Sprintf("lg_UG.%s", c.User.Language.CharSet), 615 | "li_BE", "li_NL", "lij_IT", "ln_CD", "lo_LA", 616 | fmt.Sprintf("lt_LT.%s", c.User.Language.CharSet), 617 | fmt.Sprintf("lv_LV.%s", c.User.Language.CharSet), 618 | "lzh_TW", "mag_IN", "mai_IN", "mai_NP", "mfe_MU", 619 | fmt.Sprintf("mg_MG.%s", c.User.Language.CharSet), 620 | "mhr_RU", 621 | fmt.Sprintf("mi_NZ.%s", c.User.Language.CharSet), 622 | "miq_NI", "mjw_IN", 623 | fmt.Sprintf("mg_MK.%s", c.User.Language.CharSet), 624 | "ml_IN", "mn_MN", "mni_MN", "mnw_MM", "mr_IN", 625 | fmt.Sprintf("ms_MY.%s", c.User.Language.CharSet), 626 | fmt.Sprintf("mt_MT.%s", c.User.Language.CharSet), 627 | "my_MM", "nan_TW", 628 | fmt.Sprintf("nb_NO.%s", c.User.Language.CharSet), 629 | "nds_DE", "nds_NL", "ne_NP", "nhn_MX", "niu_NU", "niu_NZ", "nl_AW", 630 | fmt.Sprintf("nl_BE.%s", c.User.Language.CharSet), 631 | fmt.Sprintf("nl_NL.%s", c.User.Language.CharSet), 632 | fmt.Sprintf("nn_NO.%s", c.User.Language.CharSet), 633 | "nr_ZA", 634 | "nso_ZA", 635 | fmt.Sprintf("oc_FR.%s", c.User.Language.CharSet), 636 | "om_ET", 637 | fmt.Sprintf("om_KE.%s", c.User.Language.CharSet), 638 | "or_IN", "os_RU", "pa_IN", "pa_PK", "pap_AW", "pap_CW", 639 | fmt.Sprintf("pl_PL.%s", c.User.Language.CharSet), 640 | "ps_AF", 641 | fmt.Sprintf("pt_BR.%s", c.User.Language.CharSet), 642 | fmt.Sprintf("pt_PT.%s", c.User.Language.CharSet), 643 | "quz_PE", "raj_IN", 644 | fmt.Sprintf("ro_RO.%s", c.User.Language.CharSet), 645 | fmt.Sprintf("ru_RU.%s", c.User.Language.CharSet), 646 | fmt.Sprintf("ru_UA.%s", c.User.Language.CharSet), 647 | "rw_RW", "sa_IN", "sah_RU", "sat_IN", "sc_IT", "sd_IN", "se_NO", "sgs_LT", "shn_MM", "shs_CA", "si_LK", "sid_ET", 648 | fmt.Sprintf("sk_SK.%s", c.User.Language.CharSet), 649 | fmt.Sprintf("sl_SI.%s", c.User.Language.CharSet), 650 | "sm_WS", 651 | fmt.Sprintf("so_DJ.%s", c.User.Language.CharSet), 652 | "so_ET", 653 | fmt.Sprintf("so_KE.%s", c.User.Language.CharSet), 654 | fmt.Sprintf("so_SO.%s", c.User.Language.CharSet), 655 | fmt.Sprintf("sq_AL.%s", c.User.Language.CharSet), 656 | "sq_MK", "sr_ME", "sr_RS", "ss_ZA", 657 | fmt.Sprintf("st_ZA.%s", c.User.Language.CharSet), 658 | fmt.Sprintf("sv_FI.%s", c.User.Language.CharSet), 659 | fmt.Sprintf("sv_SE.%s", c.User.Language.CharSet), 660 | "sw_KE", "sw_TZ", "szl_PL", "ta_IN", "ta_LK", 661 | fmt.Sprintf("tcy_IN.%s", c.User.Language.CharSet), 662 | "te_IN", 663 | fmt.Sprintf("tg_TJ.%s", c.User.Language.CharSet), 664 | fmt.Sprintf("th_TH.%s", c.User.Language.CharSet), 665 | "the_NP", "ti_ER", "ti_ET", "tig_ER", "tk_TM", 666 | fmt.Sprintf("tl_PH.%s", c.User.Language.CharSet), 667 | "tn_ZA", "to_TO", "tpi_PG", 668 | fmt.Sprintf("tr_CY.%s", c.User.Language.CharSet), 669 | fmt.Sprintf("tr_TR.%s", c.User.Language.CharSet), 670 | "ts_ZA", "tt_RU", "ug_CN", 671 | fmt.Sprintf("uk_UA.%s", c.User.Language.CharSet), 672 | "unm_US", "ur_IN", "ur_PK", 673 | fmt.Sprintf("uz_UZ.%s", c.User.Language.CharSet), 674 | "ve_ZA", "vi_VN", 675 | fmt.Sprintf("wa_BE.%s", c.User.Language.CharSet), 676 | "wae_CH", "wal_ET", "wo_SN", 677 | fmt.Sprintf("xh_ZA.%s", c.User.Language.CharSet), 678 | fmt.Sprintf("yi_US.%s", c.User.Language.CharSet), 679 | "yo_NG", "yue_HK", "yuw_PG", 680 | fmt.Sprintf("zh_CN.%s", c.User.Language.CharSet), 681 | fmt.Sprintf("zh_HK.%s", c.User.Language.CharSet), 682 | fmt.Sprintf("zh_SG.%s", c.User.Language.CharSet), 683 | fmt.Sprintf("zh_TW.%s", c.User.Language.CharSet), 684 | fmt.Sprintf("zh_ZA.%s", c.User.Language.CharSet), 685 | }, 686 | Size: 15, 687 | } 688 | 689 | _, locale_choice, err := prompt.Run() 690 | 691 | if err != nil { 692 | log.Printf("Locale selection failed %v\n", err) 693 | return 694 | } 695 | 696 | c.User.Language.Locale = locale_choice 697 | SaveConfig(c) 698 | } 699 | 700 | func LoadConfig(c *Config) { 701 | switch c.Format { 702 | case "yaml", "YAML": 703 | config_file, err := os.ReadFile("shobuarch_config.yaml") 704 | log.Printf("\n%s\n", config_file) 705 | if err != nil { 706 | log.Panic("Config file not found!") 707 | } 708 | _ = yaml.Unmarshal([]byte(config_file), &c) 709 | default: 710 | config_file, err := os.ReadFile("shobuarch_config.json") 711 | log.Printf("\n%s\n", config_file) 712 | if err != nil { 713 | log.Panic("Config file not found!") 714 | } 715 | _ = json.Unmarshal([]byte(config_file), &c) 716 | } 717 | 718 | log.Println("Config successfully loaded!") 719 | } 720 | 721 | func SaveConfig(c *Config) { 722 | switch c.Format { 723 | case "yaml", "YAML": 724 | file, _ := yaml.Marshal(c) 725 | _ = os.WriteFile("./shobuarch_config.yaml", file, 0644) 726 | default: 727 | file, _ := json.MarshalIndent(c, "", " ") 728 | _ = os.WriteFile("./shobuarch_config.json", file, 0644) 729 | } 730 | } 731 | -------------------------------------------------------------------------------- /pkg/config/pacman.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package config 19 | 20 | func BasePkgs(c *Config) { 21 | 22 | c.Pacman.Packages = append(c.Pacman.Packages, 23 | "apparmor", // Mandatory Access Control (MAC) using Linux Security Module (LSM) 24 | "arch-wiki-docs", // Arch Wiki Documentation (Offline) 25 | "cockpit", // A systemd web based user interface for Linux servers 26 | "cockpit-machines", // Cockpit UI for virtual machines 27 | "cockpit-packagekit", // Packages UI for Cockpit 28 | "cockpit-storaged", // Storage UI for Cockpit 29 | "code", // The Open Source build of Visual Studio Code (vscode) editor 30 | "dmidecode", // Desktop Management Interface table related utilities 31 | "dnsmasq", // Lightweight, easy to configure DNS forwarder and DHCP server 32 | "docker", // Pack, ship and run any application as a lightweight container 33 | "efibootmgr", // Linux user-space application to modify the EFI Boot Manager 34 | "firefox", // "Default" Web Browser 35 | "firewalld", // Firewall daemon with D-Bus interface 36 | "flatpak", // Sandboxed desktop applications on Linux. 37 | "freerdp", // Free implementation of the Remote Desktop Protocol (RDP) 38 | "fwupd", // Daemon to update some devices' firmware 39 | "go", // Core compiler tools for the Go programming language 40 | "gnu-netcat", // GNU rewrite of netcat, the network piping application (QEMU) 41 | "iptables-nft", // Linux kernel packet control tool (using nft interface) 42 | "jq", // Command-line JSON processor 43 | //"keepassxc", // Cross-platform community-driven port of Keepass password manager 44 | "libdbusmenu-glib", // Library for passing menus over DBus 45 | "lib32-pipewire", // Low-latency audio/video router and processor -- 32bit 46 | "lib32-pipewire-jack", // Pipewire JACK support -- 32bit 47 | "lib32-pipewire-v4l2", // Pipewire V4L2 interceptor -- 32bit 48 | "networkmanager", // Network connection manager and user applications 49 | "network-manager-applet", // Applet for managing network connections 50 | "noto-fonts-emoji", // Google Noto emoji fonts 51 | "openssh", // Premier connectivity tool for remote login with the SSH protocol 52 | "os-prober", // Utility to detect other OSes on a set of drives 53 | "packagekit", // A system designed to make installation and updates of packages easier 54 | "pipewire", // Low-latency audio/video router and processor 55 | "pipewire-docs", // Pipewire Documentation 56 | "pipewire-jack", // Pipewire JACK support 57 | "pipewire-pulse", // Pipewire PulseAudio replacement 58 | "pipewire-v4l2", // Pipewire V4L2 interceptor 59 | "python", // Next generation of the python high-level scripting language 60 | "python-black", // Uncompromising Python code formatter 61 | "python-pip", // The PyPA recommended tool for installing Python packages 62 | "python-pipx", // Install and Run Python Applications in Isolated Environments 63 | "qemu-full", // A generic and open source machine emulator and virtualizer 64 | "reflector", // A Python 3 module and script to retrieve and filter the latest Pacman mirror list. 65 | "rsync", // A fast and versatile file copying tool for remote and local files 66 | "steam", // Valve's digital software delivery system 67 | "system-config-printer", // A CUPS printer configuration tool and status applet 68 | "terminus-font", // Monospace bitmap font (for X11 and console) 69 | "virt-manager", // Desktop user interface for managing virtual machines 70 | "v4l2loopback-dkms", // Virtual Camera for OBS-Studio 71 | "wget", // Network utility to retrieve files from the 72 | "wireplumber", // Session & policy manager implementation for PipeWire 73 | "wpa_supplicant", // A utility providing key negotiation for WPA wireless networks 74 | //"x11-ssh-askpass", // Lightweight passphrase dialog for SSH (QEMU) 75 | "xdg-desktop-portal-gtk", // Prevent blurry text from GTK Flatpaks 76 | "xdg-user-dirs", // Manage user directories like ~/Desktop and ~/Music 77 | "xdg-utils", // Command line tools that assist applications with a variety of desktop integration tasks 78 | ) 79 | 80 | SaveConfig(c) 81 | } 82 | 83 | func Gnome(c *Config) { 84 | 85 | switch c.Desktop.InstallType { 86 | case "MINIMAL": 87 | c.Pacman.Packages = append(c.Pacman.Packages, 88 | "gnome", 89 | ) 90 | case "FULL": 91 | c.Pacman.Packages = append(c.Pacman.Packages, 92 | "gnome", 93 | "gnome-extra", 94 | ) 95 | } 96 | 97 | SaveConfig(c) 98 | } 99 | 100 | func KDE(c *Config) { 101 | 102 | switch c.Desktop.InstallType { 103 | case "MINIMAL": 104 | c.Pacman.Packages = append(c.Pacman.Packages, 105 | "plasma-desktop", 106 | "sddm", 107 | ) 108 | case "FULL": 109 | // Consider `kde-applications-meta` if you want the default "Full" experience 110 | c.Pacman.Packages = append(c.Pacman.Packages, 111 | "ark", // Archiving tool 112 | "audiocd-kio", // Kioslave for accessing audio CDs 113 | "bluedevil", // Integrate the Bluetooth technology within KDE workspace and applications 114 | "breeze-gtk", // Breeze widget theme for GTK 2 and 3 115 | "discover", // KDE and Plasma resources management GUI 116 | "dolphin", // KDE File Manager 117 | "dragon", // A simple multimedia player 118 | "drkonqi", // The KDE crash handler 119 | "ffmpegthumbs", // Video thumbnail generator for KDE file managers. 120 | "filelight", // View disk usage information 121 | "gwenview", // Fast and easy to use image viewer 122 | "juk", // A jukebox, tagger and music collection manager 123 | "k3b", // CD burning application 124 | "kamera", // KDE integration for gphoto2 cameras 125 | "kamoso", // A webcam recorder 126 | "kalarm", // Personal alarm scheduler 127 | "kate", // Advanced Text Editor 128 | "kbackup", // Backup directories or files 129 | "kcalc", // Scientific Calculator 130 | "kcharselect", // Character selector 131 | "kcolorchooser", // Color Chooser 132 | "kcodecs", // Manipulate strings using various encodings 133 | "kcron", // Configure and schedule tasks 134 | "kde-gtk-config", // GTK2 and GTK3 Configurator for KDE 135 | "kde-network-meta", // KDE network applications 136 | "kdebugsettings", // Enable/disable qCDebug 137 | "kdegraphics-thumbnailers", // Thumbnailers for various graphics file formats 138 | "kdeplasma-addons", // All kind of addons to improve your Plasma experience 139 | "kdialog", // Display dialog boxes from shell scripts 140 | "kdf", // View Disk Usage 141 | "keditbookmarks", // Bookmark Organizer and Editor 142 | "kfind", // Find files/folders 143 | "kgamma", // Adjust monitor gamma settings 144 | "kgpg", // GnuPG frontend 145 | "khelpcenter", // KDE Applications documentation 146 | "khotkeys", // KHotKeys 147 | "kimagemapeditor", // HTML Image Map Editor 148 | "kinfocenter", // Provides information about a computer system 149 | "kleopatra", // Certificate Manager and Unified Crypto GUI 150 | "kmag", // Screen Magnifier 151 | "kmousetool", // Clicks the mouse for you, reducing the effects of RSI 152 | "kmouth", // Speech Synthesizer Frontend 153 | "kolourpaint", // Paint Program 154 | "konsole", // KDE terminal emulator 155 | "kontrast", // Check contrast for colors that allows verifying they are accessible 156 | "kruler", // Screen ruler 157 | "kscreen", // KDE screen management software 158 | "ksshaskpass", // ssh-add helper that uses kwallet and kpassworddialog 159 | "ksystemlog", // System log viewer tool 160 | "kteatime", // Handy timer for steeping tea 161 | "ktimer", // Countdown launcher 162 | "kwallet-pam", // KWallet PAM integration 163 | "kwalletmanager", // Wallet management tool 164 | "kwave", // Sound editor 165 | "kwayland-integration", // Integration plugins for KDE frameworks and Wayland 166 | "kwrited", // KDE daemon listening for wall and write messages 167 | "maliit-keyboard", // Virtual keyboard based on Maliit framework 168 | "markdownpart", // KPart for rendering Markdown content 169 | "merkuro", // A calendar application using Akonadi to sync with external services 170 | "okular", // Document Viewer 171 | "oxygen", // KDE Oxygen style 172 | "packagekit-qt5", // Qt5 bindings for PackageKit 173 | "partitionmanager", // Manage disks, partitions, and file systems 174 | "plasma-browser-integration", // Integrate browsers into the Plasma Desktop 175 | "plasma-desktop", // KDE Plasma Desktop 176 | "plasma-disks", // Monitors S.M.A.R.T. capable devices 177 | "plasma-firewall", // Control Panel for your system firewall 178 | "plasma-nm", // Plasma applet written in QML for managing network connections 179 | "plasma-pa", // Plasma applet for audio volume management using PulseAudio 180 | "plasma-systemmonitor", // Interface for monitoring system sensors, process information and other system resources 181 | "plasma-thunderbolt", // Control Thunderbolt devices 182 | "plasma-vault", // Plasma applet and services for creating encrypted vaults 183 | "plasma-workspace", // KDE Plasma Workspace 184 | "plasma-workspace-wallpapers", // Additional wallpapers for the Plasma Workspace 185 | "powerdevil", // Manages the power consumption settings of a Plasma Shell 186 | "print-manager", // Tool for managing print jobs and printers 187 | "sddm", // QML based X11 and Wayland display manager 188 | "sddm-kcm", // KDE Config Module for SDDM 189 | "skanpage", // Utility to scan images and multi-page documents 190 | "spectacle", // KDE screenshot capture utility 191 | "svgpart", // A KPart for viewing SVGs 192 | "sweeper", // System Cleaner 193 | "xdg-desktop-portal-kde", // Backend implementation for x-d-p using Qt/KF5 194 | "yakuake", // Drop-down terminal emulator based on KDE konsole technology 195 | ) 196 | case "FLATPAK": 197 | c.Flatpak.Packages = append(c.Flatpak.Packages, 198 | "org.kde.ark", 199 | "org.kde.dolphin", 200 | "org.kde.filelight", 201 | "org.kde.gwenview", 202 | "org.kde.kile", 203 | "org.kde.okular", 204 | "org.kde.kdenlive", 205 | "org.kde.koko", 206 | "org.kde.spectacle", 207 | "org.kde.okteta", 208 | "org.kde.kasts", 209 | "org.kde.kmplayer", 210 | "org.kde.haruna", 211 | "org.kde.neochat", 212 | "org.kde.tokodon", 213 | "org.kde.kxstitch", 214 | "org.kde.skrooge", 215 | "org.kde.itinerary", 216 | "org.kde.skanpage", 217 | "org.kde.kontact", 218 | "org.kde.konsole", 219 | "org.kde.akregator", 220 | "org.kde.arianna", 221 | "org.kde.kopete", 222 | "org.kde.elisa", 223 | "org.kde.kdevelop", 224 | "org.kde.lokalize", 225 | "org.kde.umbrello", 226 | "org.kde.ktechlab", 227 | "org.kde.peruse", 228 | "org.kde.ktorrent", 229 | "org.kde.kget", 230 | "org.kde.kgeotag", 231 | "org.kde.massif-visualizer", 232 | "org.kde.tellico", 233 | "org.kde.krdc", 234 | "org.kde.ksirk", 235 | "org.kde.konversation", 236 | "org.kde.gcompris", 237 | "org.kde.kpat", 238 | "org.kde.kbibtex", 239 | "org.kde.labplot2", 240 | "org.kde.cantor", 241 | "org.kde.digikam", 242 | "org.kde.kphotoalbum", 243 | "org.kde.krita", 244 | "org.kde.plasmatube", 245 | "org.kde.amarok", 246 | "org.kde.trojita", 247 | "org.kde.rocs", 248 | "org.kde.kleopatra", 249 | "org.kde.kdiff3", 250 | "org.kde.kgraphviewer", 251 | "org.kde.qmlkonsole", 252 | "org.kde.kjumpingcube", 253 | "org.kde.klickety", 254 | "org.kde.klettres", 255 | "org.kde.yakuake", 256 | "org.kde.kimagemapeditor", 257 | "org.kde.kweather", 258 | "org.kde.ktrip", 259 | "org.kde.kongress", 260 | "org.kde.keysmith", 261 | "org.kde.pix", 262 | "org.kde.picmi", 263 | "org.kde.parley", 264 | "org.kde.palapeli", 265 | "org.kde.minuet", 266 | "org.kde.marble", 267 | "org.kde.kwrite", 268 | "org.kde.kwordquiz", 269 | "org.kde.kwalletmanager5", 270 | "org.kde.kuiviewer", 271 | "org.kde.kubrick", 272 | "org.kde.kturtle", 273 | "org.kde.ktuberling", 274 | "org.kde.artikulate", 275 | "org.kde.atlantik", 276 | "org.kde.audiotube", 277 | "org.kde.blinken", 278 | "org.kde.bomber", 279 | "org.kde.bovo", 280 | "org.kde.alligator", 281 | "org.kde.angelfish", 282 | "org.kde.falkon", 283 | "org.kde.granatier", 284 | "org.kde.juk", 285 | "org.kde.kalgebra", 286 | "org.kde.kalzium", 287 | "org.kde.kamoso", 288 | "org.kde.kate", 289 | "org.kde.kblocks", 290 | "org.kde.kigo", 291 | "org.kde.killbots", 292 | "org.kde.kanagram", 293 | "org.kde.kapman", 294 | "org.kde.katomic", 295 | "org.kde.kblackbox", 296 | "org.kde.kreversi", 297 | "org.kde.kruler", 298 | "org.kde.ksnakeduel", 299 | "org.kde.kdf", 300 | "org.kde.kcolorchooser", 301 | "org.kde.kcalc", 302 | "org.kde.kcachegrind", 303 | "org.kde.kbreakout", 304 | "org.kde.kbruch", 305 | "org.kde.kfourinline", 306 | "org.kde.kfind", 307 | "org.kde.kdiamond", 308 | "org.kde.kgeography", 309 | "org.kde.khangman", 310 | "org.kde.kgoldrunner", 311 | "org.kde.kig", 312 | "org.kde.kiriki", 313 | "org.kde.kiten", 314 | "org.kde.kmahjongg", 315 | "org.kde.klines", 316 | "org.kde.kmines", 317 | "org.kde.vvave", 318 | "org.kde.krename", 319 | "org.kde.kmymoney", 320 | "org.kde.kontrast", 321 | "org.kde.kmplot", 322 | "org.kde.knetwalk", 323 | "org.kde.konquest", 324 | "org.kde.kompare", 325 | "org.kde.kolourpaint", 326 | "org.kde.kollision", 327 | "org.kde.kolf", 328 | "org.kde.knights", 329 | "org.kde.knavalbattle", 330 | "org.kde.ktouch", 331 | "org.kde.kteatime", 332 | "org.kde.ksudoku", 333 | "org.kde.ksquares", 334 | "org.kde.lskat", 335 | "org.kde.kclock", 336 | "org.kde.kalk", 337 | "org.kde.index", 338 | "org.kde.nota", 339 | "org.kde.kommit", 340 | "org.kde.subtitlecomposer", 341 | "org.kde.isoimagewriter", 342 | "org.kde.PlatformTheme.QGnomePlatform", 343 | "org.kde.kronometer", 344 | "org.kde.skanlite", 345 | "org.kde.krusader", 346 | "org.kde.francis", 347 | "org.kde.WaylandDecoration.QAdwaitaDecorations", 348 | "org.kde.kid3", 349 | "org.kde.ruqola", 350 | "org.kde.KStyle.Kvantum", 351 | "org.kde.telly-skout", 352 | "org.kde.kst", 353 | "org.kde.KStyle.Adwaita", 354 | "org.kde.KStyle.HighContrast", 355 | "org.kde.kstars", 356 | "org.kde.ktimetracker", 357 | "org.kde.SymbolEditor", 358 | "org.kde.kaffeine", 359 | "org.kde.Ikona", 360 | "org.kde.choqok", 361 | "org.kde.WaylandDecoration.QGnomePlatform-decoration", 362 | "org.kde.PlatformInputContexts.MaliitSailfishOS", 363 | "org.kde.PlatformTheme.QtSNI", 364 | ) 365 | } 366 | 367 | SaveConfig(c) 368 | } 369 | 370 | func Cinnamon(c *Config) { 371 | 372 | switch c.Desktop.InstallType { 373 | case "MINIMAL": 374 | c.Pacman.Packages = append(c.Pacman.Packages, 375 | "cinnamon", 376 | "metacity", 377 | "gnome-shell", 378 | ) 379 | case "FULL": 380 | c.Pacman.Packages = append(c.Pacman.Packages, 381 | "cinnamon", 382 | "metacity", 383 | "gnome-shell", 384 | ) 385 | } 386 | 387 | SaveConfig(c) 388 | } 389 | 390 | func XFCE(c *Config) { 391 | 392 | switch c.Desktop.InstallType { 393 | case "MINIMAL": 394 | c.Pacman.Packages = append(c.Pacman.Packages, 395 | "xfce4", 396 | "xfce-goodies", 397 | ) 398 | case "FULL": 399 | c.Pacman.Packages = append(c.Pacman.Packages, 400 | "xfce4", 401 | "xfce-goodies", 402 | ) 403 | } 404 | 405 | SaveConfig(c) 406 | } 407 | 408 | func Mate(c *Config) { 409 | 410 | switch c.Desktop.InstallType { 411 | case "MINIMAL": 412 | c.Pacman.Packages = append(c.Pacman.Packages, 413 | "mate", 414 | "mate-extra", 415 | ) 416 | case "FULL": 417 | c.Pacman.Packages = append(c.Pacman.Packages, 418 | "mate", 419 | "mate-extra", 420 | ) 421 | } 422 | 423 | SaveConfig(c) 424 | } 425 | 426 | func Budgie(c *Config) { 427 | 428 | switch c.Desktop.InstallType { 429 | case "MINIMAL": 430 | c.Pacman.Packages = append(c.Pacman.Packages, 431 | "budgie-desktop", 432 | "gnome", 433 | ) 434 | case "FULL": 435 | c.Pacman.Packages = append(c.Pacman.Packages, 436 | "budgie-desktop", 437 | "gnome", 438 | ) 439 | } 440 | 441 | SaveConfig(c) 442 | } 443 | 444 | func LXDE(c *Config) { 445 | 446 | switch c.Desktop.InstallType { 447 | case "MINIMAL": 448 | c.Pacman.Packages = append(c.Pacman.Packages, 449 | "lxde", 450 | ) 451 | case "FULL": 452 | c.Pacman.Packages = append(c.Pacman.Packages, 453 | "lxde", 454 | ) 455 | } 456 | 457 | SaveConfig(c) 458 | } 459 | 460 | func Deepin(c *Config) { 461 | 462 | switch c.Desktop.InstallType { 463 | case "MINIMAL": 464 | c.Pacman.Packages = append(c.Pacman.Packages, 465 | "deepin", 466 | "deepin-extra", 467 | ) 468 | case "FULL": 469 | c.Pacman.Packages = append(c.Pacman.Packages, 470 | "deepin", 471 | "deepin-extra", 472 | ) 473 | } 474 | 475 | SaveConfig(c) 476 | } 477 | 478 | func Openbox(c *Config) { 479 | 480 | switch c.Desktop.InstallType { 481 | case "MINIMAL": 482 | c.Pacman.Packages = append(c.Pacman.Packages, 483 | "lightdm", 484 | "lightdm-gtk-greeter", 485 | "lxsession", 486 | "openbox", 487 | "rxvt-unicode", 488 | "thunar", 489 | ) 490 | case "FULL": 491 | c.Pacman.Packages = append(c.Pacman.Packages, 492 | "alsa-utils", 493 | "dunst", 494 | "feh", 495 | "geany", 496 | "gsimplecal", 497 | "gtk2-perl", 498 | "htop", 499 | "imagemagick", 500 | "jq", 501 | "lightdm", 502 | "lightdm-gtk-greeter", 503 | "lightdm-webkit2-greeter", 504 | "lightdm-webkit-theme-litarvan", 505 | "lxappearance", 506 | "lxsession", 507 | "nano", 508 | "neofetch", 509 | "obconf", 510 | "openbox", 511 | "parcellite", 512 | "pavucontrol", 513 | "picom", 514 | "playerctl", 515 | "pulseaudio", 516 | "pulseaudio-alsa", 517 | "qt5ct", 518 | "rofi", 519 | "rxvt-unicode", 520 | "scrot", 521 | "thunar", 522 | "thunar-archive-plugin", 523 | "thunar-media-tags-plugin", 524 | "thunar-volman", 525 | "tint2", 526 | "tumbler", 527 | "viewnior", 528 | "w3m", 529 | "wireless_tools", 530 | "xautolock", 531 | "xclip", 532 | "xfce4-power-manager", 533 | "xsettingsd", 534 | "zsh", 535 | ) 536 | } 537 | 538 | SaveConfig(c) 539 | } 540 | 541 | func Server(c *Config) { 542 | 543 | switch c.Desktop.InstallType { 544 | case "MINIMAL": 545 | c.Pacman.Packages = append(c.Pacman.Packages, 546 | "binutils", 547 | "dosfstools", 548 | "linux-headers", 549 | "mesa", 550 | "noto-fonts-emoji", 551 | "usbutils", 552 | "xdg-user-dirs", 553 | "xorg", 554 | "xorg-apps", 555 | "xorg-drivers", 556 | "xorg-server", 557 | "xorg-xinit", 558 | "xorg-xkill", 559 | "xterm", 560 | ) 561 | case "FULL": 562 | c.Pacman.Packages = append(c.Pacman.Packages, 563 | "alsa-plugins", 564 | "alsa-utils", 565 | "autoconf", 566 | "automake", 567 | "awesome-terminal-fonts", 568 | "bash-completion", 569 | "bind", 570 | "binutils", 571 | "bison", 572 | "bluez", 573 | "bluez-libs", 574 | "bluez-utils", 575 | "bridge-utils", 576 | "btrfs-progs", 577 | "celluloid", 578 | "cmatrix", 579 | "code", 580 | "cronie", 581 | "cups", 582 | "dialog", 583 | "dmidecode", 584 | "dnsmasq", 585 | "dosfstools", 586 | "dtc", 587 | "efibootmgr", 588 | "egl-wayland", 589 | "exfat-utils", 590 | "flex", 591 | "fuse2", 592 | "fuse3", 593 | "fuseiso", 594 | "gamemode", 595 | "gcc", 596 | "gimp", 597 | "gparted", 598 | "gptfdisk", 599 | "grub-customizer", 600 | "gst-libav", 601 | "gst-plugins-good", 602 | "gst-plugins-ugly", 603 | "haveged", 604 | "htop", 605 | "jdk-openjdk", 606 | "kitty", 607 | "libdvdcss", 608 | "libtool", 609 | "linux-headers", 610 | "lsof", 611 | "lutris", 612 | "lzop", 613 | "m4", 614 | "make", 615 | "mesa", 616 | "neofetch", 617 | "noto-fonts-emoji", 618 | "ntfs-3g", 619 | "ntp", 620 | "openbsd-netcat", 621 | "openssh", 622 | "os-prober", 623 | "p7zip", 624 | "papirus-icon-theme", 625 | "patch", 626 | "picom", 627 | "pkgconf", 628 | "powerline-fonts", 629 | "pulseaudio", 630 | "pulseaudio-alsa", 631 | "pulseaudio-bluetooth", 632 | "python-notify2", 633 | "python-pip", 634 | "python-psutil", 635 | "python-pyqt5", 636 | "qemu", 637 | "snap-pac", 638 | "snapper", 639 | "steam", 640 | "swtpm", 641 | "synergy", 642 | "terminus-font", 643 | "traceroute", 644 | "ttf-droid", 645 | "ttf-hack", 646 | "ttf-roboto", 647 | "ufw", 648 | "unrar", 649 | "unzip", 650 | "usbutils", 651 | "virt-manager", 652 | "virt-viewer", 653 | "which", 654 | "wine-gecko", 655 | "wine-mono", 656 | "winetricks", 657 | "xdg-user-dirs", 658 | "xorg", 659 | "xorg-apps", 660 | "xorg-drivers", 661 | "xorg-server", 662 | "xorg-xinit", 663 | "xorg-xkill", 664 | "xterm", 665 | "zip", 666 | "zsh", 667 | "zsh-autosuggestions", 668 | "zsh-syntax-highlighting", 669 | ) 670 | } 671 | 672 | SaveConfig(c) 673 | } 674 | 675 | func AUR(c *Config) { 676 | 677 | switch c.Desktop.InstallType { 678 | case "MINIMAL": 679 | // Nothing yet 680 | // c.Pacman.AUR.Packages = append(c.Pacman.AUR.Packages, 681 | // ) 682 | case "FULL": 683 | c.Pacman.AUR.Packages = append(c.Pacman.AUR.Packages, 684 | "bcompare", // Beyond Compare 4 685 | "cockpit-navigator-git", // File Browser for Cockpit 686 | "enpass-bin", // A multiplatform password manager 687 | "firefox-pwa-bin", // Install, manage and use PWAs in Firefox (native component) 688 | "macchina-bin", // A system information fetcher/frontend, with an (unhealthy) emphasis on performance 689 | //"mcmojave-cursors", // X-cursor theme inspired by macOS and based on capitaine-cursors (Currently refuses to install via arch-chroot) 690 | //"morgen-bin", // Modern, intuitive and smart calendar application (Successor to MineTime) 691 | //"nerd-dictation-git", // Simple, hackable offline speech to text - using the VOSK-API. 692 | //"sddm-sugar-dark", // "Sweetest" Dark theme for SDDM 693 | // "ttf-ms-win11-auto", // Microsoft Windows 11 TrueType fonts (Currently refuses to install via arch-chroot) 694 | ) 695 | 696 | switch c.Storage.Filesystem { 697 | case "zfs": 698 | c.Pacman.AUR.Packages = append(c.Pacman.AUR.Packages, 699 | "cockpit-zfs-manager", // ZFS on Linux admin package for Cockpit 700 | ) 701 | } 702 | } 703 | 704 | SaveConfig(c) 705 | } 706 | 707 | func Flatpak(c *Config) { 708 | 709 | switch c.Desktop.InstallType { 710 | case "MINIMAL": 711 | case "FULL": 712 | c.Flatpak.Packages = append(c.Flatpak.Packages, 713 | "com.belmoussaoui.Obfuscate", // Censor private information from images 714 | "com.brave.Browser", // Web browser from Brave 715 | "com.getmailspring.Mailspring", // Email client 716 | "com.github.alainm23.planner", // Never worry about forgetting things again 717 | "com.github.jeromerobert.pdfarranger", // PDF Merging, Rearranging, Splitting, Rotating and Cropping 718 | "com.github.liferooter.textpieces", // Transform text without random websites 719 | "com.github.Matoking.protontricks", // Winetricks for Proton enabled games 720 | "io.github.prateekmedia.appimagepool", // Simple, modern AppImageHub client 721 | "com.gitlab.bitseater.meteo", // Weather forecast app 722 | "com.gitlab.davem.ClamTk", // GUI for Clam Antivirus (ClamAV) 723 | "com.github.tchx84.Flatseal", // Manage Flatpak permissions 724 | "com.github.wwmm.easyeffects", // Audio Effects for PipeWire Applications 725 | "com.leinardi.gst", // System utility designed to stress and monitor various hardware components 726 | "com.obsproject.Studio", // Live streaming and video recording software 727 | "com.protonvpn.www", // High-speed Swiss VPN that safeguards your privacy 728 | "com.steamgriddb.steam-rom-manager", // Manage ROMs in Steam 729 | "com.snes9x.Snes9x", // Super Nintendo Emulator 730 | "com.stepmania.StepMania", // Rhythm and Dance Game (DDR for PC) 731 | "com.synology.SynologyDrive", // Powerful private cloud storage with no recurring fees 732 | "com.usebottles.bottles", // Sandox Windows Applications in Linux 733 | //"com.visualstudio.code-oss", // Visual Studio Code. Code editing. Redefined. 734 | "im.riot.Riot", // Element -- Matrix Chat Client 735 | "in.srev.guiscrcpy", // Android Screen Mirroring Software 736 | "io.github.antimicrox.antimicrox", // Map gamepad buttons 737 | "io.github.peazip.PeaZip", // File Archiver Utility (RAR, TAR, ZIP) 738 | "io.github.simple64.simple64", // Nintendo 64 Emulator 739 | "io.github.seadve.Kooha", // Record your screen 740 | "io.mgba.mGBA", // Nintendo Game Boy Advance Emulator 741 | "io.missioncenter.MissionCenter", // Monitor system resource usage 742 | "it.cuteworks.pacmanlogviewer", // Inspect pacman logs 743 | "md.obsidian.Obsidian", // Markdown-based knowledge base 744 | "media.emby.EmbyTheater", // Emby (Media Server) client for desktop computers 745 | "net.davidotek.pupgui2", // ProtonUp-QT (Install Wine and Proton-based compatibility tools) 746 | "net.filebot.FileBot", // Ultimate TV and Movie Renamer 747 | "net.kuribo64.melonDS", // Nintendo DS and DSi emulator 748 | "net.pcsx2.PCSX2", // Playstation 2 emulator 749 | "org.citra_emu.citra", // Nintendo 3DS emulator 750 | "org.DolphinEmu.dolphin-emu", // Nintendo GameCube and Wii emulator 751 | "org.gimp.GIMP", // Create images and edit photographs 752 | "org.gnome.Firmware", // Install firmware on devices 753 | //"org.gnome.Maps", // Find places around the world 754 | "org.kde.kdenlive", // Non-linear video editor for Linux 755 | //"org.keepassxc.KeePassXC", // Cross-platform community-driven port of Keepass password manager 756 | "org.libreoffice.LibreOffice", // LibreOffice productivity suite 757 | "org.libretro.RetroArch", // Frontend for emulators, game engines and media players 758 | "org.mixxx.Mixxx", // DJ Mixing software (Traktor alternative) 759 | "org.mozilla.Thunderbird", // Email, RSS, and newsgroup client with integrated spam filter 760 | //"org.onlyoffice.desktopeditors", // OnlyOffice productivity suite 761 | "org.ppsspp.PPSSPP", // PlayStation Portable emulator 762 | "org.rncbc.qpwgraph", // PipeWire Graph Qt GUI Interface 763 | "org.upscayl.Upscayl", // Free and Open Source AI Image Upscaler 764 | "org.yuzu_emu.yuzu", // Nintendo Switch emulator 765 | "tv.plex.PlexDesktop", // Plex client for desktop computers 766 | "tv.plex.PlexHTPC", // Plex HTPC client for the big screen 767 | ) 768 | } 769 | 770 | SaveConfig(c) 771 | } 772 | 773 | func PWA(c *Config) { 774 | 775 | messages := Site{ 776 | Name: "Messages", 777 | Description: "Simple, helpful messaging by Google", 778 | StartUrl: "https://messages.google.com/web", 779 | Manifest: "manifest.json", 780 | } 781 | 782 | c.PWA.Sites = append(c.PWA.Sites, messages) 783 | 784 | youtube := Site{ 785 | Name: "YouTube", 786 | Description: "Share your videos with friends, family, and the world.", 787 | StartUrl: "https://www.youtube.com", 788 | Manifest: "manifest.webmanifest", 789 | } 790 | 791 | c.PWA.Sites = append(c.PWA.Sites, youtube) 792 | 793 | SaveConfig(c) 794 | } 795 | 796 | // Make a note to update /usr/bin/steam-runtime to include `env LD_PRELOAD=/usr/lib32/libextest.so` between `exec` and `/usr/lib/steam/steam "$@"` 797 | -------------------------------------------------------------------------------- /pkg/install/postinstall.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package install 19 | 20 | import ( 21 | "fmt" 22 | "log" 23 | "os" 24 | "strings" 25 | 26 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 27 | z "github.com/ShobuPrime/ShobuArch/pkg/shell" 28 | ) 29 | 30 | func PostInstallLogo() { 31 | 32 | log.Println(` 33 | ------------------------------------------------------------------------- 34 | ███████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗██╗ ██╗ 35 | ██╔════╝██║ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝██║ ██║ 36 | ███████╗███████║██║ ██║██████╔╝██║ ██║███████║██████╔╝██║ ███████║ 37 | ╚════██║██╔══██║██║ ██║██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ 38 | ███████║██║ ██║╚██████╔╝██████╔╝╚██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ 39 | ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ 40 | ------------------------------------------------------------------------- 41 | Automated Arch Linux (Installer) 42 | PROGRESS: Post-Install 43 | SCRIPTHOME: ShobuArch 44 | ------------------------------------------------------------------------- 45 | `) 46 | } 47 | 48 | func PostInstallCleanup(c *conf.Config) { 49 | 50 | log.Println(` 51 | ------------------------------------------------------------------------- 52 | Post-Install Cleanup 53 | ------------------------------------------------------------------------- 54 | `) 55 | 56 | cmd := []string{`sudo`, `sed`, `-i`, `s/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/g`, `/etc/sudoers`} 57 | z.Arch_chroot(&cmd, false, c) 58 | 59 | cmd = []string{`sudo`, `sed`, `-i`, `s/%sudo ALL=(ALL:ALL) ALL/# %sudo ALL=(ALL:ALL) ALL/g`, `/etc/sudoers`} 60 | z.Arch_chroot(&cmd, false, c) 61 | 62 | log.Println("Saving config to user profile") 63 | config_bytes, err := os.ReadFile(fmt.Sprintf("./shobuarch_config.%s", strings.ToLower(c.Format))) 64 | if err != nil { 65 | log.Fatalln(err) 66 | } 67 | 68 | err = os.WriteFile(fmt.Sprintf("/mnt/home/%s/Desktop/shobuarch_config.%s", c.User.Username, strings.ToLower(c.Format)), config_bytes, 0755) 69 | if err != nil { 70 | log.Fatalln(err) 71 | } 72 | 73 | log.Println("Saving log to user profile") 74 | log_bytes, err := os.ReadFile("./shobuarch.log") 75 | if err != nil { 76 | log.Fatalln(err) 77 | } 78 | 79 | err = os.WriteFile(fmt.Sprintf("/mnt/home/%s/Desktop/shobuarch.log", c.User.Username), log_bytes, 0755) 80 | if err != nil { 81 | log.Fatalln(err) 82 | } 83 | } 84 | 85 | func PostInstallUnmount(c *conf.Config) { 86 | 87 | log.Println(` 88 | ------------------------------------------------------------------------- 89 | Unmounting Drives 90 | ------------------------------------------------------------------------- 91 | `) 92 | 93 | var disk1_part1, disk1_part2, disk2_part1 string 94 | var cmd_list []string 95 | 96 | switch strings.HasPrefix(c.Storage.SystemDisk, "/dev/nvme") { 97 | case true: 98 | disk1_part1 = fmt.Sprintf(`%vp1`, c.Storage.SystemDisk) 99 | disk1_part2 = fmt.Sprintf(`%vp2`, c.Storage.SystemDisk) 100 | case false: 101 | disk1_part1 = fmt.Sprintf(`%v1`, c.Storage.SystemDisk) 102 | disk1_part2 = fmt.Sprintf(`%v2`, c.Storage.SystemDisk) 103 | } 104 | 105 | switch c.Storage.MirrorInstall { 106 | case true: 107 | switch strings.HasPrefix(c.Storage.MirrorDisk, "/dev/nvme") { 108 | case true: 109 | disk2_part1 = fmt.Sprintf(`%vp1`, c.Storage.MirrorDisk) 110 | case false: 111 | disk2_part1 = fmt.Sprintf(`%v1`, c.Storage.MirrorDisk) 112 | } 113 | 114 | log.Println("Cloning EFI Partitions") 115 | cmd_list = append(cmd_list, 116 | fmt.Sprintf(`dd if=%v of=%v`, disk1_part1, disk2_part1), 117 | ) 118 | } 119 | 120 | cmd_list = append(cmd_list, 121 | fmt.Sprintf(`umount -A %s`, disk1_part1), 122 | ) 123 | 124 | switch c.Storage.Filesystem { 125 | case "luks": 126 | cmd_list = append(cmd_list, 127 | `umount -A /dev/mapper/luks_ROOT`, 128 | ) 129 | case "zfs": 130 | cmd_list = append(cmd_list, 131 | `zfs umount -a`, 132 | `zpool export zroot`, 133 | ) 134 | default: 135 | cmd_list = append(cmd_list, 136 | fmt.Sprintf(`umount -A %s`, disk1_part2), 137 | ) 138 | } 139 | 140 | for i := range cmd_list { 141 | z.Shell(&cmd_list[i]) 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /pkg/install/preinstall.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package install 19 | 20 | import ( 21 | "fmt" 22 | "log" 23 | "path/filepath" 24 | "strings" 25 | 26 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 27 | z "github.com/ShobuPrime/ShobuArch/pkg/shell" 28 | u "github.com/ShobuPrime/ShobuArch/pkg/util" 29 | ) 30 | 31 | func PreInstallLogo() { 32 | 33 | log.Println(` 34 | ------------------------------------------------------------------------- 35 | ███████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗██╗ ██╗ 36 | ██╔════╝██║ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝██║ ██║ 37 | ███████╗███████║██║ ██║██████╔╝██║ ██║███████║██████╔╝██║ ███████║ 38 | ╚════██║██╔══██║██║ ██║██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ 39 | ███████║██║ ██║╚██████╔╝██████╔╝╚██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ 40 | ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ 41 | ------------------------------------------------------------------------- 42 | Automated Arch Linux (Installer) 43 | PROGRESS: Pre-Install 44 | SCRIPTHOME: ShobuArch 45 | ------------------------------------------------------------------------- 46 | `) 47 | } 48 | 49 | func Prerequisites(c *conf.Config) { 50 | fmt.Println(` 51 | ------------------------------------------------------------------------- 52 | Installing Prerequisites 53 | ------------------------------------------------------------------------- 54 | `) 55 | 56 | prereqs := `pacman -Syy --noconfirm --needed btrfs-progs glibc gptfdisk sbctl sed sudo iptables-nft` 57 | z.Shell(&prereqs) 58 | } 59 | 60 | func Mirrors(c *conf.Config) { 61 | 62 | // cmd := `(curl -4 ifconfig.co/country-iso)` 63 | // iso, _ := z.Shell(&cmd) 64 | 65 | // Hard-coded ISO 66 | // To-do: Fix receiving ISO from ifconfig 67 | iso := "US" 68 | 69 | log.Printf(` 70 | ------------------------------------------------------------------------- 71 | Setting up %s mirrors for faster downloads 72 | ------------------------------------------------------------------------- 73 | `, iso) 74 | 75 | cmd_list := []string{} 76 | 77 | cmd_list = append(cmd_list, 78 | `timedatectl set-ntp true`, 79 | `pacman -Syy --noconfirm archlinux-keyring`, 80 | `pacman -Syy --noconfirm --needed pacman-contrib terminus-font`, 81 | // `sed -n 's/^#ParallelDownloads/ParallelDownloads/g' /etc/pacman.conf`, 82 | `pacman -Syy --noconfirm --needed reflector rsync`, 83 | `cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak`, 84 | fmt.Sprintf(`reflector --protocol https --country %s --latest 10 --sort rate --ipv6 --fastest 5 --save /etc/pacman.d/mirrorlist`, iso), 85 | ) 86 | 87 | for i := range cmd_list { 88 | z.Shell(&cmd_list[i]) 89 | } 90 | } 91 | 92 | func FormatDisks(c *conf.Config) { 93 | log.Println(` 94 | ------------------------------------------------------------------------- 95 | Creating Filesystems 96 | ------------------------------------------------------------------------- 97 | `) 98 | 99 | cmd_list := []string{} 100 | 101 | var mount_options, disk1_part1, disk1_part2, disk2_part1, disk2_part2 string 102 | 103 | cmd_list = append(cmd_list, 104 | fmt.Sprintf(`wipefs -a %v`, c.Storage.SystemDisk), 105 | fmt.Sprintf(`sgdisk --zap-all %v`, c.Storage.SystemDisk), 106 | fmt.Sprintf(`sgdisk -o %v`, c.Storage.SystemDisk), 107 | fmt.Sprintf(`sgdisk -n 1::+550M --typecode=1:ef00 --change-name=1:'EFIBOOT' %v`, c.Storage.SystemDisk), 108 | fmt.Sprintf(`sgdisk -n 2:: --typecode=2:bf00 --change-name=2:'ROOT' %v`, c.Storage.SystemDisk), 109 | ) 110 | 111 | if strings.HasPrefix(c.Storage.SystemDisk, "/dev/nvme") { 112 | disk1_part1 = fmt.Sprintf(`%vp1`, c.Storage.SystemDisk) 113 | disk1_part2 = fmt.Sprintf(`%vp2`, c.Storage.SystemDisk) 114 | } else { 115 | disk1_part1 = fmt.Sprintf(`%v1`, c.Storage.SystemDisk) 116 | disk1_part2 = fmt.Sprintf(`%v2`, c.Storage.SystemDisk) 117 | } 118 | 119 | cmd_list = append(cmd_list, fmt.Sprintf(`mkfs.vfat -F32 -n "EFIBOOT" %v`, disk1_part1)) 120 | 121 | if c.Storage.MirrorInstall { 122 | 123 | cmd_list = append(cmd_list, 124 | fmt.Sprintf(`wipefs -a %v`, c.Storage.MirrorDisk), 125 | fmt.Sprintf(`sgdisk --zap-all %v`, c.Storage.MirrorDisk), 126 | fmt.Sprintf(`sgdisk -o %v`, c.Storage.MirrorDisk), 127 | fmt.Sprintf(`sgdisk -n 1::+550M --typecode=1:ef00 --change-name=1:'EFIBOOT' %v`, c.Storage.MirrorDisk), 128 | fmt.Sprintf(`sgdisk -n 2:: --typecode=2:bf00 --change-name=2:'ROOT' %v`, c.Storage.MirrorDisk), 129 | ) 130 | 131 | if strings.HasPrefix(c.Storage.SystemDisk, "/dev/nvme") { 132 | disk2_part1 = fmt.Sprintf(`%vp1`, c.Storage.MirrorDisk) 133 | disk2_part2 = fmt.Sprintf(`%vp2`, c.Storage.MirrorDisk) 134 | } else { 135 | disk2_part1 = fmt.Sprintf(`%v1`, c.Storage.MirrorDisk) 136 | disk2_part2 = fmt.Sprintf(`%v2`, c.Storage.MirrorDisk) 137 | } 138 | 139 | cmd_list = append(cmd_list, fmt.Sprintf(`mkfs.vfat -F32 -n "EFIBOOT" %v`, disk2_part1)) 140 | } 141 | 142 | log.Println("Detecting SSD...") 143 | if c.Storage.SystemDiskRota || strings.Contains(c.Storage.SystemDiskID, "SSD") { 144 | // MOUNT_OPTIONS if SSD: noatime,compress=zstd,ssd,commit=120 145 | mount_options = `discard=async,noatime,compress=zstd,ssd,commit=120` 146 | log.Printf("SSD detected! MOUNT_OPTIONS=%v\n", mount_options) 147 | } else { 148 | // MOUNT_OPTIONS if HDD: noatime,compress=zstd,commit=120 149 | mount_options = `noatime,compress=zstd,commit=120` 150 | log.Printf("HDD detected! MOUNT_OPTIONS=%v\n", mount_options) 151 | } 152 | 153 | switch c.Storage.Filesystem { 154 | case "btrfs": 155 | switch c.Storage.MirrorInstall { 156 | case true: 157 | cmd_list = append(cmd_list, 158 | fmt.Sprintf(`mkfs.btrfs -L ROOT -m raid1 -d raid1 %v %v -f`, disk1_part2, disk2_part2), 159 | ) 160 | case false: 161 | cmd_list = append(cmd_list, 162 | fmt.Sprintf(`mkfs.btrfs -L ROOT %v -f`, disk1_part2), 163 | ) 164 | } 165 | cmd_list = append(cmd_list, 166 | fmt.Sprintf(`mount -t btrfs %v /mnt`, disk1_part2), 167 | `btrfs subvolume create /mnt/@`, // createsubvolumes 168 | `btrfs subvolume create /mnt/@home`, 169 | `btrfs subvolume create /mnt/@var`, 170 | `btrfs subvolume create /mnt/@tmp`, 171 | `btrfs subvolume create /mnt/@.snapshots`, 172 | `umount /mnt`, 173 | fmt.Sprintf(`mount -o %v,subvol=@ %v /mnt`, mount_options, disk1_part2), 174 | `mkdir -p /mnt/{home,var,tmp,.snapshots}`, 175 | fmt.Sprintf(`mount -o %v,subvol=@home %v /mnt/home`, mount_options, disk1_part2), 176 | fmt.Sprintf(`mount -o %v,subvol=@tmp %v /mnt/tmp`, mount_options, disk1_part2), 177 | fmt.Sprintf(`mount -o %v,subvol=@var %v /mnt/var`, mount_options, disk1_part2), 178 | fmt.Sprintf(`mount -o %v,subvol=@.snapshots %v /mnt/.snapshots`, mount_options, disk1_part2), 179 | `mkdir -p /mnt/boot/EFI`, 180 | fmt.Sprintf(`mount -t vfat %s /mnt/boot/`, disk1_part1), 181 | ) 182 | case "ext4": 183 | cmd_list = append(cmd_list, 184 | fmt.Sprintf(`mkfs.ext4 -L ROOT %v -f`, disk1_part2), 185 | fmt.Sprintf(`mount -t ex4 %v /mnt`, disk1_part2), 186 | ) 187 | case "luks": 188 | cmd_list = append(cmd_list, 189 | fmt.Sprintf(`echo -n "%v" | cryptsetup -y -v luksFormat --type=luks2 --label=ROOT %v -`, c.Storage.EncryptionKey, disk1_part2), 190 | fmt.Sprintf(`echo -n "%v" | cryptsetup -v luksOpen %v luks_ROOT -`, c.Storage.EncryptionKey, disk1_part2), 191 | `lsblk`, 192 | // fmt.Sprintf(`mkfs.btrfs -L ROOT %v -f`, disk1_part2), 193 | `mkfs.btrfs /dev/mapper/luks_ROOT -f`, 194 | // fmt.Sprintf(`mount -t btrfs %v /mnt`, disk1_part2), 195 | `mount /dev/mapper/luks_ROOT /mnt`, 196 | `btrfs subvolume create /mnt/@`, // subvolumesetup 197 | `btrfs subvolume create /mnt/@home`, 198 | `btrfs subvolume create /mnt/@var`, 199 | `btrfs subvolume create /mnt/@tmp`, 200 | `btrfs subvolume create /mnt/@.snapshots`, 201 | `umount /mnt`, 202 | fmt.Sprintf(`mount -o %v,subvol=@ /dev/mapper/luks_ROOT /mnt`, mount_options), // mountallsubvol 203 | `mkdir -p /mnt/{home,var,tmp,.snapshots}`, 204 | fmt.Sprintf(`mount -o %v,subvol=@home /dev/mapper/luks_ROOT /mnt/home`, mount_options), 205 | fmt.Sprintf(`mount -o %v,subvol=@tmp /dev/mapper/luks_ROOT /mnt/tmp`, mount_options), 206 | fmt.Sprintf(`mount -o %v,subvol=@var /dev/mapper/luks_ROOT /mnt/var`, mount_options), 207 | fmt.Sprintf(`mount -o %v,subvol=@.snapshots /dev/mapper/luks_ROOT /mnt/.snapshots`, mount_options), 208 | `mkdir -p /mnt/boot/EFI`, 209 | fmt.Sprintf(`mount -t vfat %s /mnt/boot/`, disk1_part1), 210 | ) 211 | case "zfs": 212 | zfs_cmd := `zpool create -f -o ashift=12 \ 213 | -O acltype=posixacl \ 214 | -O relatime=on \ 215 | -O xattr=sa \ 216 | -O dnodesize=legacy \ 217 | -O normalization=formD \ 218 | -O mountpoint=none \ 219 | -O canmount=off \ 220 | -O devices=off \ 221 | -R /mnt \ 222 | -O compression=zstd \ 223 | -O dedup=on \ 224 | zroot` 225 | 226 | switch c.Storage.MirrorInstall { 227 | case true: 228 | cmd_list = append(cmd_list, 229 | `modprobe zfs`, 230 | fmt.Sprintf(`%v mirror %v %v`, zfs_cmd, disk1_part2, disk2_part2), 231 | ) 232 | case false: 233 | cmd_list = append(cmd_list, 234 | `modprobe zfs`, 235 | fmt.Sprintf(`%v %v`, zfs_cmd, disk1_part2), 236 | ) 237 | } 238 | 239 | cmd_list = append(cmd_list, 240 | `zpool status`, 241 | `zfs create -o mountpoint=none zroot/data`, 242 | `zfs create -o mountpoint=none zroot/ROOT`, 243 | `zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default`, 244 | `zfs create -o mountpoint=/home zroot/data/home`, 245 | `zfs create -o mountpoint=/var -o canmount=off zroot/var`, // Future: Figure out how to add zfs create zroot/var/log without freeze on shutdown 246 | `zfs create -o mountpoint=/var/lib -o canmount=off zroot/var/lib`, 247 | `zfs create zroot/var/lib/libvirt`, 248 | `zfs create zroot/var/lib/docker`, 249 | `zpool export zroot`, 250 | fmt.Sprintf(`zpool import -d %v -R /mnt zroot -N`, disk1_part2), 251 | `zfs mount zroot/ROOT/default`, 252 | `zfs mount -a`, 253 | `zpool set bootfs=zroot/ROOT/default zroot`, 254 | `zpool set cachefile=/etc/zfs/zpool.cache zroot`, 255 | `mkdir -p /mnt/{etc/zfs,boot}`, 256 | `cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache`, 257 | fmt.Sprintf(`mount %v /mnt/boot`, disk1_part1), 258 | ) 259 | } 260 | 261 | cmd_list = append(cmd_list, `df -HT`) 262 | 263 | log.Println("Formatting Disks...") 264 | for i := range cmd_list { 265 | z.Shell(&cmd_list[i]) 266 | } 267 | } 268 | 269 | func ArchInstall(c *conf.Config) { 270 | log.Println(` 271 | ------------------------------------------------------------------------- 272 | Arch Install on Main Drive 273 | ------------------------------------------------------------------------- 274 | `) 275 | 276 | cmd_list := []string{} 277 | 278 | // Temp: Adding openssl-1.1 to fix libcrypto.so.1.1 error 279 | // pacman: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory 280 | cmd_list = append(cmd_list, 281 | fmt.Sprintf(`pacstrap /mnt --noconfirm --needed archlinux-keyring base base-devel dkms libnewt %s linux-firmware %s-docs %s-headers nano openssl-1.1 packagekit sbctl sed sudo vim sudo wget`, c.Kernel, c.Kernel, c.Kernel), 282 | `echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf`, 283 | `cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist`, 284 | ) 285 | 286 | switch c.Storage.Filesystem { 287 | case "zfs": 288 | log.Printf("Generating fstab for %s\n", c.Storage.Filesystem) 289 | cmd_list = append(cmd_list, 290 | `genfstab -L /mnt >> /mnt/etc/fstab`, 291 | ) 292 | log.Println("Commenting out zroot entries in fstab. ZFS handles this by itself") 293 | cmd_list = append(cmd_list, 294 | `sed -i 's/zroot/# zroot/g' /mnt/etc/fstab`, 295 | `sed -i 's/# # zroot/# zroot/g' /mnt/etc/fstab`, 296 | `cat /mnt/etc/fstab`, 297 | ) 298 | default: 299 | log.Printf("Generating fstab for %s\n", c.Storage.Filesystem) 300 | cmd_list = append(cmd_list, 301 | `genfstab -U -p /mnt >> /mnt/etc/fstab`, 302 | ) 303 | } 304 | 305 | for i := range cmd_list { 306 | z.Shell(&cmd_list[i]) 307 | } 308 | 309 | fstab_path := filepath.Join("/", "mnt", "etc") 310 | fstab_file := `fstab` 311 | u.ReadFile(&fstab_path, &fstab_file) 312 | } 313 | -------------------------------------------------------------------------------- /pkg/install/user.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package install 19 | 20 | import ( 21 | "encoding/base64" 22 | "encoding/json" 23 | "fmt" 24 | "log" 25 | "os" 26 | "path/filepath" 27 | "strings" 28 | 29 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 30 | z "github.com/ShobuPrime/ShobuArch/pkg/shell" 31 | u "github.com/ShobuPrime/ShobuArch/pkg/util" 32 | ) 33 | 34 | func UserLogo() { 35 | 36 | log.Println(` 37 | ------------------------------------------------------------------------- 38 | ███████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗██╗ ██╗ 39 | ██╔════╝██║ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝██║ ██║ 40 | ███████╗███████║██║ ██║██████╔╝██║ ██║███████║██████╔╝██║ ███████║ 41 | ╚════██║██╔══██║██║ ██║██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ 42 | ███████║██║ ██║╚██████╔╝██████╔╝╚██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ 43 | ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ 44 | ------------------------------------------------------------------------- 45 | Automated Arch Linux (Installer) 46 | PROGRESS: User 47 | SCRIPTHOME: ShobuArch 48 | ------------------------------------------------------------------------- 49 | `) 50 | } 51 | 52 | func UserLocale(c *conf.Config) { 53 | log.Println(` 54 | ------------------------------------------------------------------------- 55 | Enforcing Desktop Environment Locale 56 | ------------------------------------------------------------------------- 57 | `) 58 | 59 | // As other desktop environments are played around with, their locale configs will be modified as needed 60 | switch c.Desktop.Environment { 61 | case "kde": 62 | cmd_list := []string{ 63 | `touch`, 64 | fmt.Sprintf(`/home/%s/.config/plasma-localerc`, c.User.Username), 65 | } 66 | z.Arch_chroot(&cmd_list, true, c) 67 | 68 | cmd_list = []string{ 69 | `awk`, 70 | fmt.Sprintf(`BEGIN{ printf "[Formats]\nLANG=%s\n" >> "/home/%s/.config/plasma-localerc" }`, c.User.Language.Locale, c.User.Username), 71 | } 72 | z.Arch_chroot(&cmd_list, true, c) 73 | } 74 | } 75 | 76 | func UserKeyring(c *conf.Config) { 77 | log.Println(` 78 | ------------------------------------------------------------------------- 79 | Initializing System Keyring 80 | ------------------------------------------------------------------------- 81 | `) 82 | 83 | for i := range c.Pacman.Packages { 84 | switch c.Pacman.Packages[i] { 85 | case "keepassxc": 86 | log.Println("Configuring KeePassXC as System Keyring") 87 | 88 | pwd, err := os.Getwd() 89 | if err != nil { 90 | log.Fatalln(err) 91 | } 92 | 93 | config_dir := filepath.Join("/", "mnt", "home", c.User.Username, ".config") 94 | log.Printf("Changing directory to %q\n", config_dir) 95 | if err := os.Chdir(config_dir); err != nil { 96 | log.Fatalln(err) 97 | } 98 | 99 | log.Println("Making Keepass directory") 100 | if err := os.MkdirAll("keepassxc", 0755); err != nil { 101 | log.Fatalln(err) 102 | } 103 | 104 | keepass_config := filepath.Join(config_dir, "keepassxc", "keepassxc.ini") 105 | 106 | config_settings := []string{ 107 | `[General]`, 108 | `ConfigVersion=2`, 109 | `MinimizeAfterUnlock=true`, 110 | ``, 111 | `[Browser]`, 112 | `CustomProxyLocation=`, 113 | ``, 114 | `[FdoSecrets]`, 115 | `Enabled=true`, 116 | ``, 117 | `[GUI]`, 118 | `AdvancedSettings=true`, 119 | `MinimizeOnClose=true`, 120 | `MinimizeOnStartup=true`, 121 | `ShowExpiredEntriesOnDatabaseUnlockOffsetDays=0`, 122 | `ShowTrayIcon=true`, 123 | `TrayIconAppearance=colorful`, 124 | ``, 125 | `[PasswordGenerator]`, 126 | `AdditionalChars=`, 127 | `ExcludedChars=`, 128 | ``, 129 | `[SSHAgent]`, 130 | `Enabled=true`, 131 | } 132 | log.Println(`Creating "keepassxc.ini"`) 133 | f, err := os.OpenFile(keepass_config, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 134 | if err != nil { 135 | log.Fatalln(err) 136 | } 137 | log.Println(`Saving settings`) 138 | if _, err := f.Write([]byte(strings.Join(config_settings, "\n"))); err != nil { 139 | log.Fatalln(err) 140 | } 141 | log.Println(`Closing file`) 142 | if err := f.Close(); err != nil { 143 | log.Fatalln(err) 144 | } 145 | 146 | // keepassxc-cli db-create .kbdx --set-key-file 147 | // keepasscx-cli db-info .kbdx --key-file --no-password 148 | // Default password `shobuarch` 149 | database := `A9mimmf7S7UAAAQAAhAAAAAxwfLmv3FDUL5YBSFq/Fr/AwQAAAABAAAABCAAAAA6gIwPGKUKHY7tiznPSf+tOKAaofJx0/dXwJwzhUDPiAcQAAAAlUosWDY0KACeIQAEQBY/9QuLAAAAAAFCBQAAACRVVUlEEAAAAO9jbd+MKURLkfeppAPjCgwFAQAAAEkIAAAACgAAAAAAAAAFAQAAAE0IAAAAAAAABAAAAAAEAQAAAFAEAAAAEAAAAEIBAAAAUyAAAAAjkwIV6OEByQOujHV5OOkm8zx2RArSVpyMCAuCgFsmbQQBAAAAVgQAAAATAAAAAAAEAAAADQoNCmLMN98TJfsNuFrKZSspbQtP/nBNuEQ4I6CO83eMhDlss9yWOR4sedvhPxYpjwla3NtoTlvTeY3fhqnwDk4COnkQgLyATEl23l5cLDmPJcfIwJBvNUljPmII41wK0a+HXAAEAACZjhMpkaJb6J7OLSLoAjsDREHabM3+HlQ3uKnpOKsRVbAgaup63fR97nEDfVdSdGBONSpNdKSpfaZBsg3qJrVfJZ308sQ+zSVVFkOo78NBjCLhNMerGJ2ALzFnJHli0ESOsCDRO4SynI5i1aEJ/gKCjEk/DHyDZYyXehIBhcsU5a61p8B2xOgpvOZ/m6ilWJKDBiN18R5uxZAABxlaIMaU1/f0UwAsoe60GHZ8DAN1hYHE7CTCyTjn/vMlKRq8pyOJAJ9f0MoZ0eq3TrYmYdGR+G2zVVWhMBF9uYYcEcBEaDx6MFf+/J/2vrRkmZM1GjSV+gn+yFByqrY83fjBYtHuQSUO65/KS1cQPSOCjTQ1vuGlhPSEgDS8Wi3QpwNWgvYDWmwRc0fUGeL+of10hnAOq8f5aGGuvGr3nI4uzDufE3QD1338cSQ3krEY/85xNE7lCViT85eC+GZDTArWAVoJfKIsdEL5hgUey7rMOLhHpA+TihbTNvI3XYi43/1UIWeqQZxQYBDhFplDlp5qSTCHi55jlyCxgRXXeZyRhrn5DhLQCteFhVjApRKgyzZU6uk0KsrSY1oNSFDprO1OrKOiJOEDTHUJ9083oInYMZXAqVdGUc0m5PxnNxYDFyXS6OXp0PUb/MSezVLhf1/xd4jvNeOIfVVX8TvNdaKRtJ72KJxSH1uH23ETSmOeN8vxKKJKJCEq62QZbRTdnI4xmuoO1foZS312lWhyLfU2dU5CzQp+nHBXf3sS32zXFD5V+5TOdOSWGZNM45V4NWiFA8PUzFWsexknJ5SpFp+jap9Gi0fcq310dw6teDLzE41IzEkg4X27H2SqZA4d/J+9AGSa6r0lRWUBeF8PXFR8iFhIjG95eUYxUa4M/UUMTb6z/1qjEPqIUjLPybK98vWfAEICBA5YT+1WXsOzA0zZ9ex+wTRSIp0t8xs4XMlF3ONKVgyG5S9uOxdaBGiRXg+TDk8kcVzT5GOoAT7BdIE/hgedGbNB8QNrk7B62jCZUOSgd4lkHKh1fOLk3qGTVPg2g9OiLrJBZsiDHPodi613dbBZTpJOQjdAMUh4D5M3W8rLmN/ydXWrd9euYx/KH0b6UOuiDRZoe0/tygeSgGn0QPFQadrOVDMsy4mTwYgqeBvUGQh10YBfdmgvoF6ATvt/WnE9g6RLE3Eip7iUQL4Osb7brzouDgroXw8pD++4hI0e3D+xpOmRzpAxo0C5/T45WcP9X2US1264TTwkh8+hI8p7+Kjr5TM5n+BZvfHd2rVF2cul8wc10HQqr8S22vB223AUilKccnVVHs0o64i7N4vZNkizxsEPVwBJyr0NdhGOqjUOUR67Up8d2pv2BFhGxxFKUWbm8MgcyDtUl64Kc+APpOPSDAZ3q012Yv26qUO7N6UAAAAA` 150 | dec, err := base64.StdEncoding.DecodeString(database) 151 | if err != nil { 152 | log.Fatalln(err) 153 | } 154 | 155 | user_home := filepath.Join("/", "mnt", "home", c.User.Username) 156 | log.Printf("Changing directory to %q\n", user_home) 157 | if err := os.Chdir(user_home); err != nil { 158 | log.Fatalln(err) 159 | } 160 | 161 | log.Println(`Creating "system-keyring" database`) 162 | f, err = os.Create("system-keyring.kdbx") 163 | if err != nil { 164 | log.Fatalln(err) 165 | } 166 | defer f.Close() 167 | 168 | log.Println(`Writing data to database`) 169 | if _, err := f.Write(dec); err != nil { 170 | log.Fatalln(err) 171 | } 172 | 173 | log.Println(`Waiting for data to synchronize`) 174 | if err := f.Sync(); err != nil { 175 | log.Fatalln(err) 176 | } 177 | 178 | log.Println(`Enforcing permissions`) 179 | //os.Chown(filepath.Base(keepass_config), 1000, 1000) 180 | cmd := []string{ 181 | `chown`, 182 | `-R`, 183 | fmt.Sprintf(`%s:%s`, c.User.Username, c.User.Username), 184 | fmt.Sprintf(`/home/%s/`, c.User.Username), 185 | } 186 | z.Arch_chroot(&cmd, false, c) 187 | 188 | log.Println("Done!") 189 | // Return to original directory 190 | if err := os.Chdir(pwd); err != nil { 191 | log.Fatalln(err) 192 | } 193 | } 194 | } 195 | } 196 | 197 | func UserPackages(c *conf.Config) { 198 | 199 | log.Println(` 200 | ------------------------------------------------------------------------- 201 | Installing AUR Packages 202 | ------------------------------------------------------------------------- 203 | `) 204 | 205 | cmd_list := []string{c.Pacman.AUR.Helper, `-Syyu`, `--needed`, `--noconfirm`} 206 | cmd_list = append(cmd_list, c.Pacman.AUR.Packages...) 207 | z.Arch_chroot(&cmd_list, true, c) 208 | 209 | for i := range c.Pacman.AUR.Packages { 210 | switch c.Pacman.AUR.Packages[i] { 211 | case "bcompare": 212 | log.Println("Service menus for Beyond Compare 4") 213 | cmd_list = []string{c.Pacman.AUR.Helper, `-Syyu`, `--needed`, `--noconfirm`} 214 | switch c.Desktop.Environment { 215 | case "cinnamon": 216 | cmd_list = append(cmd_list, `bcompare-cinnamon`) 217 | z.Arch_chroot(&cmd_list, true, c) 218 | case "gnome": 219 | cmd_list = append(cmd_list, `bcompare-nautilus`) 220 | z.Arch_chroot(&cmd_list, true, c) 221 | case "mate": 222 | cmd_list = append(cmd_list, `bcompare-mate`) 223 | z.Arch_chroot(&cmd_list, true, c) 224 | case "kde": 225 | cmd_list = append(cmd_list, `bcompare-kde5`) 226 | z.Arch_chroot(&cmd_list, true, c) 227 | case "xfce": 228 | cmd_list = append(cmd_list, `bcompare-thunar`) 229 | z.Arch_chroot(&cmd_list, true, c) 230 | } 231 | case "firefox-pwa", "firefox-pwa-bin": 232 | log.Println("Configuring Firefox for PWAs") 233 | cmd_list = []string{`firefoxpwa`, `runtime`, `install`} 234 | z.Arch_chroot(&cmd_list, true, c) 235 | case "openrazer-daemon": 236 | log.Println("Enabling OpenRazer Daemon") 237 | cmd_list = []string{`systemctl`, `--user`, `enable`, `openrazer-daemon.service`} 238 | z.Arch_chroot(&cmd_list, true, c) 239 | case "openrazer-driver-dkms": 240 | log.Println("Configuring Razer Drivers...") 241 | cmd_list = []string{`sudo`, `gpasswd`, `-a`, c.User.Username, `plugdev`} 242 | z.Arch_chroot(&cmd_list, true, c) 243 | case "openrazer-meta": 244 | log.Println("Configuring Razer Drivers...") 245 | cmd_list = []string{`sudo`, `gpasswd`, `-a`, c.User.Username, `plugdev`} 246 | z.Arch_chroot(&cmd_list, true, c) 247 | 248 | log.Println("Enabling OpenRazer Daemon") 249 | cmd_list = []string{`systemctl`, `--user`, `enable`, `openrazer-daemon.service`} 250 | z.Arch_chroot(&cmd_list, true, c) 251 | default: 252 | } 253 | } 254 | } 255 | 256 | func UserPWAs(c *conf.Config) { 257 | 258 | log.Println(` 259 | ------------------------------------------------------------------------- 260 | Installing Progressive Web Apps 261 | ------------------------------------------------------------------------- 262 | `) 263 | 264 | cmd_list := []string{} 265 | 266 | pwa_struct := &u.FIREFOX_PWA{} 267 | 268 | log.Println("Configuring separate profiles for each PWA...") 269 | create_profile := []string{`firefoxpwa`, `profile`, `create`, `--name`} 270 | 271 | for i := range c.PWA.Sites { 272 | cmd_list = append(create_profile, c.PWA.Sites[i].Name) 273 | z.Arch_chroot(&cmd_list, true, c) 274 | } 275 | 276 | log.Println("Reading PWA Config...") 277 | pwa_path := filepath.Join("/", "mnt", "home", c.User.Username, ".local", "share", "firefoxpwa") 278 | pwa_file := `config.json` 279 | firefoxpwa_config := u.ReadFile(&pwa_path, &pwa_file) 280 | 281 | _ = json.Unmarshal([]byte(strings.Join(*firefoxpwa_config, "\n")), pwa_struct) 282 | log.Println(u.PrettyJson(pwa_struct)) 283 | 284 | log.Println("Installing PWAs into their respective profiles...") 285 | for _, profile := range pwa_struct.Profiles { 286 | cmd_list = []string{`firefoxpwa`, `site`, `install`} 287 | for i := range c.PWA.Sites { 288 | if profile.Name == c.PWA.Sites[i].Name { 289 | cmd_list = append(cmd_list, 290 | fmt.Sprintf(`%s/%s`, c.PWA.Sites[i].StartUrl, c.PWA.Sites[i].Manifest), 291 | `--start-url`, 292 | c.PWA.Sites[i].StartUrl, 293 | `--name`, 294 | c.PWA.Sites[i].Name, 295 | `--description`, 296 | c.PWA.Sites[i].Description, 297 | `--profile`, 298 | profile.Ulid, 299 | ) 300 | } 301 | } 302 | z.Arch_chroot(&cmd_list, true, c) 303 | } 304 | } 305 | 306 | func UserVariables(c *conf.Config) { 307 | 308 | log.Println(` 309 | ------------------------------------------------------------------------- 310 | Configuring User Variables 311 | ------------------------------------------------------------------------- 312 | `) 313 | 314 | log.Println("Configuring Environmental Variables") 315 | config_dir := filepath.Join("/", "mnt", "home", c.User.Username, ".config") 316 | environment_dir := filepath.Join(config_dir, "environment.d") 317 | 318 | log.Println("Making environment.d directory") 319 | if err := os.MkdirAll(environment_dir, 0755); err != nil { 320 | log.Fatalln(err) 321 | } 322 | 323 | environment_config := "environment.conf" 324 | 325 | config_settings := []string{ 326 | // `MOZ_ENABLE_WAYLAND=1`, // Firefox 121.0 is supposed to have Wayland support enabled by default 327 | `MOZ_DBUS_REMOTE=1`, 328 | `AMD_VULKAN_ICD=RADV`, // https://wiki.archlinux.org/title/Vulkan#Selecting_via_environment_variable 329 | } 330 | 331 | switch c.Desktop.Environment { 332 | case "kde": 333 | config_settings = append(config_settings, 334 | `SSH_ASKPASS='/usr/bin/ksshaskpass'`, 335 | `SSH_ASKPASS_REQUIRE=prefer`, 336 | ) 337 | } 338 | 339 | log.Println(`Creating "environment.conf"`) 340 | u.WriteFile(&environment_dir, &environment_config, &config_settings, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 341 | 342 | log.Println("Configuring Electron") 343 | 344 | electron_config := "electron-flags.conf" 345 | 346 | config_settings = []string{ 347 | `--enable-features=WaylandWindowDecorations`, 348 | `--ozone-platform-hint=auto`, 349 | } 350 | 351 | log.Println(`Creating "electron-flags.conf"`) 352 | u.WriteFile(&environment_dir, &electron_config, &config_settings, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 353 | 354 | electron_config = "electron19-flags.conf" 355 | 356 | config_settings = []string{ 357 | `--enable-features=UseOzonePlatform`, 358 | `--ozone-platform=wayland`, 359 | } 360 | log.Println(`Creating "electron19-flags.conf"`) 361 | u.WriteFile(&environment_dir, &electron_config, &config_settings, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 362 | 363 | for i := range c.Pacman.Packages { 364 | switch c.Pacman.Packages[i] { 365 | case "code": 366 | log.Println("Configuring Visual Studio Code") 367 | 368 | electron_config := "code-flags.conf" 369 | 370 | config_settings = []string{ 371 | `--enable-features=UseOzonePlatform`, 372 | `--ozone-platform=wayland`, 373 | } 374 | log.Println(`Creating "code-flags.conf"`) 375 | u.WriteFile(&environment_dir, &electron_config, &config_settings, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 376 | } 377 | } 378 | 379 | // To-Do: 380 | // For some applications, like bcompare, we need to make sure to export to PATH if not done already 381 | // ex) export PATH = /home//.cache//clone/bcompare/src/install/bin/bcompare:$PATH 382 | 383 | log.Println(`Enforcing permissions on home directory...`) 384 | //os.Chown(filepath.Base(keepass_config), 1000, 1000) 385 | cmd := []string{ 386 | `chown`, 387 | `-R`, 388 | fmt.Sprintf(`%s:%s`, c.User.Username, c.User.Username), 389 | fmt.Sprintf(`/home/%s/`, c.User.Username), 390 | } 391 | z.Arch_chroot(&cmd, false, c) 392 | 393 | log.Println(`Adding .zshrc aliases...`) 394 | zshrc_dir := filepath.Join("/", "mnt", "home", c.User.Username) 395 | zshrc_file := ".zshrc" 396 | 397 | zshrc_contents := []string{ 398 | fmt.Sprintf(`alias ARCH_UP='%s -Syyu --needed --noconfirm; flatpak update --assumeyes'`, c.Pacman.AUR.Helper), 399 | fmt.Sprintf(`alias DELETE_ORPHAN_PACKAGES='%s -Qtdq | %s -Rns -; flatpak uninstall --assumeyes --unused'`, c.Pacman.AUR.Helper, c.Pacman.AUR.Helper), 400 | fmt.Sprintf(`alias LIST_ALL_PACKAGES='%s -Qq; flatpak list --columns=application | tail -n +1'`, c.Pacman.AUR.Helper), // Ignore first line of output for Flatpak. Alternatives: awk '{if(NR>1)print}', sed -n '1!p' 401 | fmt.Sprintf(`alias LIST_BROKEN_PACKAGES="%s -Qk | grep -v ' 0 missing files'"`, c.Pacman.AUR.Helper), 402 | fmt.Sprintf(`#alias REPAIR_ALL_PACKAGES='for package in $(%s -Qq); do %s -S "$package" --noconfirm; done'`, c.Pacman.AUR.Helper, c.Pacman.AUR.Helper), 403 | fmt.Sprintf(`alias REPAIR_ALL_PACKAGES='%s -Qq | %s -S -; flatpak repair'`, c.Pacman.AUR.Helper, c.Pacman.AUR.Helper), 404 | fmt.Sprintf(`alias REPAIR_BROKEN_PACKAGES="%s -Qk | grep -v ' 0 missing files' | cut -d: -f1 | %s -S -"`, c.Pacman.AUR.Helper, c.Pacman.AUR.Helper), 405 | `alias sshme='killall ssh-agent; eval $(ssh-agent -s); ssh-add ~/.ssh/id_ed25519'`, // To Do: Create SSH key 406 | } 407 | 408 | for i := range c.Pacman.Packages { 409 | switch c.Pacman.Packages[i] { 410 | case "go": 411 | zshrc_contents = append(zshrc_contents, ``, `export PATH=$PATH:$(go env GOPATH)/bin`) 412 | } 413 | } 414 | u.WriteFile(&zshrc_dir, &zshrc_file, &zshrc_contents, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755) // Overwrite 415 | u.ReadFile(&zshrc_dir, &zshrc_file) 416 | } 417 | 418 | func UserAutostart(c *conf.Config) { 419 | 420 | log.Println(` 421 | ------------------------------------------------------------------------- 422 | Configuring User's AutoStart Programs 423 | ------------------------------------------------------------------------- 424 | `) 425 | 426 | for i := range c.Pacman.Packages { 427 | switch c.Pacman.Packages[i] { 428 | case "keepassxc": 429 | log.Println(`Creating autostart for KeePassXC`) 430 | autostart_dir := filepath.Join("/", "mnt", "home", c.User.Username, ".config", "autostart") 431 | autostart_file := "org.keepassxc.KeePassXC.desktop" 432 | autostart_contents := []string{ 433 | `[Desktop Entry]`, 434 | `Name=KeePassXC`, 435 | `GenericName=Password Manager`, 436 | `Exec=/usr/bin/keepassxc`, 437 | `TryExec=/usr/bin/keepassxc`, 438 | `Icon=keepassxc`, 439 | `StartupWMClass=keepassxc`, 440 | `StartupNotify=true`, 441 | `Terminal=false`, 442 | `Type=Application`, 443 | `Version=1.0`, 444 | `Categories=Utility;Security;Qt;`, 445 | `MimeType=application/x-keepass2;`, 446 | `X-GNOME-Autostart-enabled=true`, 447 | `X-GNOME-Autostart-Delay=2`, 448 | `X-KDE-autostart-after=panel`, 449 | `X-LXQt-Need-Tray=true`, 450 | } 451 | u.WriteFile(&autostart_dir, &autostart_file, &autostart_contents, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755) // Overwrite 452 | } 453 | } 454 | 455 | for i := range c.Pacman.AUR.Packages { 456 | switch c.Pacman.AUR.Packages[i] { 457 | case "enpass", "enpass-bin": 458 | log.Println(`Creating autostart for Enpass`) 459 | autostart_dir := filepath.Join("/", "mnt", "home", c.User.Username, ".config", "autostart") 460 | autostart_file := "Enpass.desktop" 461 | autostart_contents := []string{ 462 | `[Desktop Entry]`, 463 | `Type=Application`, 464 | `Name=Enpass`, 465 | `Exec= /opt/enpass/Enpass -minimize`, 466 | `Icon=enpass.png`, 467 | `Comment=The best password manager`, 468 | `X-GNOME-Autostart-Delay=12`, 469 | `X-GNOME-Autostart-enabled=true`, 470 | } 471 | u.WriteFile(&autostart_dir, &autostart_file, &autostart_contents, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755) // Overwrite 472 | } 473 | } 474 | } 475 | 476 | func UserDotFiles(c *conf.Config) { 477 | log.Println(` 478 | ------------------------------------------------------------------------- 479 | Configuring User DotFiles 480 | ------------------------------------------------------------------------- 481 | `) 482 | 483 | log.Println("Preparing environment for automatic systemd-nspawn scripts...") 484 | 485 | log.Println(`Creating AutoLogin for systemd-nspawn container...`) 486 | autologin_dir := filepath.Join("/", "mnt", "etc", "systemd", "system", "console-getty.service.d") 487 | err := os.MkdirAll(autologin_dir, 0755) 488 | if err != nil { 489 | log.Fatal(err) 490 | } 491 | 492 | autologin_file := "autologin.conf" 493 | autologin_contents := []string{ 494 | `[Service]`, 495 | `ExecStart=`, 496 | fmt.Sprintf(`ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --keep-baud --autologin %s - 115200,38400,9600 $TERM`, c.User.Username), 497 | } 498 | u.WriteFile(&autologin_dir, &autologin_file, &autologin_contents, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 499 | 500 | log.Println("Compiling VSCode extension commands...") 501 | // Missing X server or $DISPLAY. The platform failed to initialize. Exiting. The futex facility returned an unexpected error code. 502 | cmd_list := []string{`sleep 3`} 503 | for i := range c.Pacman.Packages { 504 | switch c.Pacman.Packages[i] { 505 | case "code": 506 | // Install extensions 507 | log.Println(`Installing VSCode Extensions`) 508 | code_extensions := []string{`shardulm94.trailing-spaces`} 509 | for i := range c.Pacman.Packages { 510 | switch c.Pacman.Packages[i] { 511 | case "docker": 512 | code_extensions = append(code_extensions, `ms-azuretools.vscode-docker`) 513 | case "go": 514 | code_extensions = append(code_extensions, `golang.go`) 515 | case "python": 516 | code_extensions = append(code_extensions, `ms-python.python`) 517 | } 518 | } 519 | 520 | // Aider Chat 521 | // https://marketplace.visualstudio.com/items?itemName=MattFlower.aider 522 | code_extensions = append(code_extensions, `MattFlower.aider`) 523 | 524 | // Github CoPilot 525 | // https://marketplace.visualstudio.com/items?itemName=GitHub.copilot 526 | code_extensions = append(code_extensions, `GitHub.copilot`) 527 | 528 | for i := range code_extensions { 529 | cmd_list = append(cmd_list, fmt.Sprintf(`code --install-extension %s`, code_extensions[i])) 530 | } 531 | 532 | cmd_list := append(cmd_list, `code --list-extensions`) 533 | 534 | log.Println("Appending systemd-nspawn 'Get out of Jail for free' command...") 535 | cmd_list = append(cmd_list, `sudo poweroff`) 536 | 537 | log.Println("Ensuring VSCode extensions will automatically execute after mounting systemd-nspawn container...") 538 | systemd_autorun_dir := filepath.Join("/", "mnt", "etc", "profile.d") 539 | code_script := "install_code_extensions.sh" 540 | 541 | log.Println(`Creating VSCode script for systemd-nspawn container...`) 542 | u.WriteFile(&systemd_autorun_dir, &code_script, &cmd_list, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755) 543 | 544 | log.Println("Making executable...") 545 | cmd := fmt.Sprintf(`chmod +x %v`, filepath.Join(systemd_autorun_dir, code_script)) 546 | z.Shell(&cmd) 547 | 548 | log.Println("Installing Code extensions via systemd-nspawn...") 549 | z.Systemd_nspawn(&[]string{}, true, c) 550 | 551 | log.Println("Cleaning up cruft...") 552 | log.Println("Deleting: ", autologin_dir) 553 | err = os.RemoveAll(autologin_dir) 554 | if err != nil { 555 | log.Fatalln(err) 556 | } 557 | 558 | log.Println("Deleting: ", filepath.Join(systemd_autorun_dir, code_script)) 559 | err = os.Remove(filepath.Join(systemd_autorun_dir, code_script)) 560 | if err != nil { 561 | log.Fatalln(err) 562 | } 563 | 564 | log.Println(`Creating config for VSCode...`) 565 | code_dir := filepath.Join("/", "mnt", "home", c.User.Username, ".config", "Code - OSS", "User") 566 | code_file := "settings.json" 567 | code_contents := []string{ 568 | `{`, 569 | ` "files.autoSave": "afterDelay",`, 570 | ` "go.toolsManagement.autoUpdate": true,`, 571 | ` "git.autofetch": true,`, 572 | ` "launch": {`, 573 | ` "configurations": [`, 574 | ` {`, 575 | ` "name": "Launch Go",`, 576 | ` "type": "go",`, 577 | ` "request": "launch",`, 578 | ` "mode": "auto",`, 579 | ` "program": "${fileDirname}",`, 580 | ` "console": "integratedTerminal"`, 581 | ` },`, 582 | ` {`, 583 | ` "name": "Launch Python",`, 584 | ` "type": "python",`, 585 | ` "request": "launch",`, 586 | ` "program": "${file}",`, 587 | ` "console": "integratedTerminal"`, 588 | ` }`, 589 | ` ],`, 590 | ` "compounds": []`, 591 | ` },`, 592 | ` "debug.allowBreakpointsEverywhere": true,`, 593 | ` "git.confirmSync": false,`, 594 | ` "git.enableSmartCommit": true,`, 595 | ` "diffEditor.ignoreTrimWhitespace": false,`, 596 | ` "go.formatTool": "gofmt",`, 597 | ` "go.formatFlags": [`, 598 | ` "[\"-s\", \"-w\"]"`, 599 | ` ],`, 600 | ` "python.formatting.provider": "black",`, 601 | ` "editor.formatOnSave": true,`, 602 | ` "workbench.colorTheme": "Visual Studio Dark",`, 603 | ` "editor.largeFileOptimizations": false`, 604 | `}`, 605 | } 606 | u.WriteFile(&code_dir, &code_file, &code_contents, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755) // Overwrite 607 | 608 | code_dir = filepath.Join("/", "mnt", "home", c.User.Username, ".vscode-oss") 609 | code_file = "argv.json" 610 | 611 | // This configuration file allows you to pass permanent command line arguments to VS Code. 612 | // https://github.com/microsoft/vscode-python/issues/20247#issuecomment-1350342224 613 | // https://github.com/orgs/community/discussions/11509 614 | code_contents = []string{ 615 | `{`, 616 | ` "enable-proposed-api": ["ms-python.python", "github.copilot"],`, 617 | `}`, 618 | } 619 | u.WriteFile(&code_dir, &code_file, &code_contents, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755) // Overwrite 620 | } 621 | } 622 | } 623 | 624 | func UserShell(c *conf.Config) { 625 | 626 | log.Println(` 627 | ------------------------------------------------------------------------- 628 | Configuring User Shell 629 | ------------------------------------------------------------------------- 630 | `) 631 | 632 | log.Println(`Enforcing permissions`) 633 | //os.Chown(filepath.Base(keepass_config), 1000, 1000) 634 | cmd := []string{ 635 | `chown`, 636 | `-R`, 637 | fmt.Sprintf(`%s:%s`, c.User.Username, c.User.Username), 638 | fmt.Sprintf(`/home/%s/`, c.User.Username), 639 | } 640 | z.Arch_chroot(&cmd, false, c) 641 | 642 | // To-do: Add Shell Option during `Fresh Start` 643 | // Hard-coding ZSH shell 644 | c.User.Shell = "zsh" 645 | 646 | cmd_list := []string{`sudo`, `pacman`, `-Syyu`, `--needed`, `--noconfirm`} 647 | 648 | switch c.User.Shell { 649 | case "zsh": 650 | cmd_list = append(cmd_list, 651 | `zsh`, 652 | `grml-zsh-config`, 653 | ) 654 | z.Arch_chroot(&cmd_list, true, c) 655 | 656 | cmd_list = []string{`sudo`, `chsh`, `--shell`, `/bin/zsh`, c.User.Username} 657 | z.Arch_chroot(&cmd_list, false, c) 658 | 659 | file_list := []string{ 660 | `.bashrc`, 661 | `.bash_logout`, 662 | `.bash_profile`, 663 | } 664 | for file := range file_list { 665 | os.Remove(fmt.Sprintf(`/mnt/home/%s/%s`, c.User.Username, file_list[file])) 666 | } 667 | 668 | default: 669 | log.Println("User is configured with default shell") 670 | } 671 | } 672 | -------------------------------------------------------------------------------- /pkg/interfaces/interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package interfaces 19 | 20 | import ( 21 | "io" 22 | 23 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 24 | ) 25 | 26 | type Configurator interface { 27 | conf.Config 28 | io.Writer 29 | } 30 | -------------------------------------------------------------------------------- /pkg/shell/shell.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package shell 19 | 20 | import ( 21 | "bufio" 22 | "fmt" 23 | "io" 24 | "log" 25 | "os/exec" 26 | "strings" 27 | 28 | conf "github.com/ShobuPrime/ShobuArch/pkg/config" 29 | ) 30 | 31 | func Shell(cmd *string) string { 32 | 33 | program := exec.Command("/bin/bash", "-c", *cmd) 34 | stdout, err := program.StdoutPipe() 35 | // // https://stackoverflow.com/a/35995372 36 | // program.Stderr = program.Stdout 37 | if err != nil { 38 | log.Println(err) 39 | } 40 | 41 | stderr, err := program.StderrPipe() 42 | if err != nil { 43 | log.Println(err) 44 | } 45 | 46 | combined_output := io.MultiReader(stdout, stderr) 47 | 48 | err = program.Start() 49 | log.Printf("Executing: %q\n", program) 50 | if err != nil { 51 | log.Println(err) 52 | } 53 | 54 | output_log := "" 55 | 56 | // print the output of the subprocess 57 | // scanner := bufio.NewScanner(stdout) 58 | scanner := bufio.NewScanner(combined_output) 59 | for scanner.Scan() { 60 | m := scanner.Text() 61 | output_log += m + "\n" 62 | log.Printf("%s\n", m) 63 | } 64 | 65 | err = program.Wait() 66 | if err != nil { 67 | log.Println(err) 68 | } 69 | 70 | fmt.Println() 71 | 72 | return string(output_log) 73 | } 74 | 75 | // For whatever reason, arch_chroot is giving me lots of problems at the moment with commands like sed and echo 76 | // Unlike shell function above, we will attempt each command as a list of args, rather than raw string 77 | // Nuances include: Shell needs single quote for sed, but exec.Command does not use shell. 78 | // Consequently, no single quotes around argument 79 | func Arch_chroot(cmd_args *[]string, runuser bool, c *conf.Config) string { 80 | 81 | log.Println("Preparing arch-chroot command---------------------------") 82 | 83 | arch_chroot := []string{`arch-chroot`, `/mnt`} 84 | 85 | switch runuser { 86 | case true: 87 | arch_chroot = []string{"arch-chroot", "/mnt", "/usr/bin/runuser", "-u", c.User.Username, "--"} 88 | // arch_chroot = []string{"arch-chroot", "-u", c.Username, "/mnt",} 89 | } 90 | 91 | cmd := []string{} 92 | cmd = append(cmd, arch_chroot...) 93 | cmd = append(cmd, *cmd_args...) 94 | 95 | program := exec.Command(cmd[0], cmd[1:]...) 96 | stdout, err := program.StdoutPipe() 97 | if err != nil { 98 | log.Println(err) 99 | } 100 | 101 | stderr, err := program.StderrPipe() 102 | if err != nil { 103 | log.Println(err) 104 | } 105 | 106 | combined_output := io.MultiReader(stdout, stderr) 107 | 108 | err = program.Start() 109 | log.Printf("Executing: %q\n", program) 110 | if err != nil { 111 | log.Println(err) 112 | } 113 | 114 | output_log := "" 115 | 116 | // print the output of the subprocess 117 | // scanner := bufio.NewScanner(stdout) 118 | scanner := bufio.NewScanner(combined_output) 119 | for scanner.Scan() { 120 | m := scanner.Text() 121 | output_log += m + "\n" 122 | log.Printf("%s\n", m) 123 | } 124 | 125 | err = program.Wait() 126 | if err != nil { 127 | log.Println(err) 128 | } 129 | 130 | fmt.Println() 131 | 132 | return string(output_log) 133 | } 134 | 135 | func Systemd_nspawn(cmd_args *[]string, boot bool, c *conf.Config) string { 136 | // https://wiki.archlinux.org/title/Systemd-nspawn 137 | log.Println("Preparing systemd-nspawn command---------------------------") 138 | 139 | systemd_nspawn := []string{`systemd-nspawn`, `-D`, `/mnt`} 140 | 141 | switch boot { 142 | case true: 143 | systemd_nspawn = []string{"systemd-nspawn", `-bnq`, `-D`, `/mnt`} 144 | } 145 | 146 | cmd := []string{} 147 | cmd = append(cmd, systemd_nspawn...) 148 | cmd = append(cmd, *cmd_args...) 149 | 150 | program := exec.Command(cmd[0], cmd[1:]...) 151 | stdout, err := program.StdoutPipe() 152 | if err != nil { 153 | log.Println(err) 154 | } 155 | 156 | stderr, err := program.StderrPipe() 157 | if err != nil { 158 | log.Println(err) 159 | } 160 | 161 | combined_output := io.MultiReader(stdout, stderr) 162 | 163 | err = program.Start() 164 | log.Printf("Executing: %q\n", program) 165 | if err != nil { 166 | log.Println(err) 167 | } 168 | 169 | output_log := "" 170 | 171 | // print the output of the subprocess 172 | // scanner := bufio.NewScanner(stdout) 173 | scanner := bufio.NewScanner(combined_output) 174 | for scanner.Scan() { 175 | m := scanner.Text() 176 | output_log += strings.TrimSpace(m) + "\n" 177 | log.Printf("%s\n", strings.TrimSpace(m)) 178 | } 179 | 180 | err = program.Wait() 181 | if err != nil { 182 | log.Println(err) 183 | } 184 | 185 | fmt.Println() 186 | 187 | return string(output_log) 188 | } 189 | -------------------------------------------------------------------------------- /pkg/util/biometrics.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | type BioSupportedDevices struct { 21 | Face []string 22 | Fingerprint []string 23 | SecurityKey []string 24 | } 25 | 26 | func BiometricIDs() *BioSupportedDevices { 27 | 28 | bsd := &BioSupportedDevices{} 29 | 30 | bsd.Face = []string{ 31 | `04f2:b5ac`, 32 | `04f2:b5cf`, 33 | `04f2:b6d0`, 34 | } 35 | 36 | // List of libfprint supported devices: https://fprint.freedesktop.org/supported-devices.html 37 | bsd.Fingerprint = []string{ 38 | `045e:00bb`, 39 | `045e:00bc`, 40 | `045e:00bd`, 41 | `045e:00ca`, 42 | `0483:2015`, 43 | `0483:2016`, 44 | `04f3:0903`, 45 | `04f3:0907`, 46 | `04f3:0c01`, 47 | `04f3:0c02`, 48 | `04f3:0c03`, 49 | `04f3:0c04`, 50 | `04f3:0c05`, 51 | `04f3:0c06`, 52 | `04f3:0c07`, 53 | `04f3:0c08`, 54 | `04f3:0c09`, 55 | `04f3:0c0a`, 56 | `04f3:0c0b`, 57 | `04f3:0c0c`, 58 | `04f3:0c0d`, 59 | `04f3:0c0e`, 60 | `04f3:0c0f`, 61 | `04f3:0c10`, 62 | `04f3:0c11`, 63 | `04f3:0c12`, 64 | `04f3:0c13`, 65 | `04f3:0c14`, 66 | `04f3:0c15`, 67 | `04f3:0c16`, 68 | `04f3:0c17`, 69 | `04f3:0c18`, 70 | `04f3:0c19`, 71 | `04f3:0c1a`, 72 | `04f3:0c1b`, 73 | `04f3:0c1c`, 74 | `04f3:0c1d`, 75 | `04f3:0c1e`, 76 | `04f3:0c1f`, 77 | `04f3:0c20`, 78 | `04f3:0c21`, 79 | `04f3:0c22`, 80 | `04f3:0c23`, 81 | `04f3:0c24`, 82 | `04f3:0c25`, 83 | `04f3:0c26`, 84 | `04f3:0c27`, 85 | `04f3:0c28`, 86 | `04f3:0c29`, 87 | `04f3:0c2a`, 88 | `04f3:0c2b`, 89 | `04f3:0c2c`, 90 | `04f3:0c2d`, 91 | `04f3:0c2e`, 92 | `04f3:0c2f`, 93 | `04f3:0c30`, 94 | `04f3:0c31`, 95 | `04f3:0c32`, 96 | `04f3:0c33`, 97 | `04f3:0c3d`, 98 | `04f3:0c42`, 99 | `04f3:0c4b`, 100 | `04f3:0c4d`, 101 | `04f3:0c4f`, 102 | `04f3:0c58`, 103 | `04f3:0c63`, 104 | `04f3:0c6e`, 105 | `04f3:0c7d`, 106 | `04f3:0c7e`, 107 | `04f3:0c82`, 108 | `04f3:0c88`, 109 | `04f3:0c8c`, 110 | `04f3:0c8d`, 111 | `05ba:0007`, 112 | `05ba:0008`, 113 | `05ba:000a`, 114 | `061a:0110`, 115 | `06cb:00bd`, 116 | `06cb:00c2`, 117 | `06cb:00df`, 118 | `06cb:00f0`, 119 | `06cb:00f9`, 120 | `06cb:00fc`, 121 | `06cb:0100`, 122 | `06cb:0103`, 123 | `06cb:0104`, 124 | `06cb:0123`, 125 | `06cb:0126`, 126 | `06cb:0129`, 127 | `06cb:015f`, 128 | `06cb:0168`, 129 | `08ff:1600`, 130 | `08ff:1660`, 131 | `08ff:1680`, 132 | `08ff:1681`, 133 | `08ff:1682`, 134 | `08ff:1683`, 135 | `08ff:1684`, 136 | `08ff:1685`, 137 | `08ff:1686`, 138 | `08ff:1687`, 139 | `08ff:1688`, 140 | `08ff:1689`, 141 | `08ff:168a`, 142 | `08ff:168b`, 143 | `08ff:168c`, 144 | `08ff:168d`, 145 | `08ff:168e`, 146 | `08ff:168f`, 147 | `08ff:2500`, 148 | `08ff:2550`, 149 | `08ff:2580`, 150 | `08ff:2660`, 151 | `08ff:2680`, 152 | `08ff:2681`, 153 | `08ff:2682`, 154 | `08ff:2683`, 155 | `08ff:2684`, 156 | `08ff:2685`, 157 | `08ff:2686`, 158 | `08ff:2687`, 159 | `08ff:2688`, 160 | `08ff:2689`, 161 | `08ff:268a`, 162 | `08ff:268b`, 163 | `08ff:268c`, 164 | `08ff:268d`, 165 | `08ff:268e`, 166 | `08ff:268f`, 167 | `08ff:2691`, 168 | `08ff:2810`, 169 | `08ff:5731`, 170 | `138a:0001`, 171 | `138a:0005`, 172 | `138a:0008`, 173 | `138a:0010`, 174 | `138a:0011`, 175 | `138a:0015`, 176 | `138a:0017`, 177 | `138a:0018`, 178 | `138a:0050`, 179 | `138a:0091`, 180 | `147e:1000`, 181 | `147e:1001`, 182 | `147e:2016`, 183 | `147e:2020`, 184 | `147e:3001`, 185 | `1c7a:0570`, 186 | `1c7a:0571`, 187 | `1c7a:0603`, 188 | `27c6:5840`, 189 | `27c6:6094`, 190 | `27c6:609c`, 191 | `27c6:60a2`, 192 | `27c6:631c`, 193 | `27c6:634c`, 194 | `27c6:6384`, 195 | `27c6:639c`, 196 | `27c6:63ac`, 197 | `27c6:63bc`, 198 | `27c6:63cc`, 199 | `27c6:6496`, 200 | `27c6:6584`, 201 | `27c6:658c`, 202 | `27c6:6592`, 203 | `27c6:6594`, 204 | `27c6:659a`, 205 | `27c6:659c`, 206 | `27c6:6a94`, 207 | `298d:1010`, 208 | `5501:08ff`, 209 | } 210 | 211 | // List of FIDO devs: https://github.com/Yubico/libfido2/blob/main/udev/fidodevs 212 | fido_vendors := map[string]string{ 213 | "STMicro": `0483`, // STMicroelectronics 214 | "Infineon": `058b`, // Infineon Technologies 215 | "Synaptics": `06cb`, // Synaptics Inc. 216 | "Feitian": `096e`, // Feitian Technologies Co., Ltd. 217 | "Yubico": `1050`, // Yubico AB 218 | "Silicon": `10c4`, // Silicon Laboratories, Inc. 219 | "pid.codes": `1209`, // pid.codes 220 | "Google": `18d1`, // Google Inc. 221 | "VASCO": `1a44`, // VASCO Data Security NV 222 | "OpenMoko": `1d50`, // OpenMoko, Inc. 223 | "NEOWAVE": `1e0d`, // NEOWAVE 224 | "Excelsecu": `1ea8`, // Shenzhen Excelsecu Data Technology Co., Ltd 225 | "NXP": `1fc9`, // NXP Semiconductors 226 | "ClayLogic": `20a0`, // Clay Logic 227 | "Aladdin": `24dc`, // Aladdin Software Security R.D. 228 | "Plug‐up": `2581`, // Plug‐up 229 | "Bluink": `2abe`, // Bluink Ltd 230 | "LEDGER": `2c97`, // LEDGER 231 | "Hypersecu": `2ccf`, // Hypersecu Information Systems, Inc. 232 | "eWBM": `311f`, // eWBM Co., Ltd. (TrustKey) 233 | "GoTrustID": `32a3`, // GoTrustID Inc. 234 | "Unknown": `4c4d`, // Unknown vendor 235 | "SatoshiLabs": `534c`, // SatoshiLabs 236 | } 237 | 238 | for vendor, id := range fido_vendors { 239 | 240 | switch vendor { 241 | case "STMicro": 242 | products := []string{ 243 | `a2ac`, // ellipticSecure MIRKey 244 | `a2ca`, // Unknown product 245 | `cdab`, // Unknown product 246 | } 247 | CombineIDs(&id, &products, &bsd.SecurityKey) 248 | case "Infineon": 249 | products := []string{ 250 | `022d`, // Infineon FIDO 251 | } 252 | CombineIDs(&id, &products, &bsd.SecurityKey) 253 | case "Synaptics": 254 | products := []string{ 255 | `0088`, // Kensington Verimark 256 | } 257 | CombineIDs(&id, &products, &bsd.SecurityKey) 258 | case "Feitian": 259 | products := []string{ 260 | `0850`, // FS ePass FIDO 261 | `0852`, // Unknown product 262 | `0853`, // Unknown product 263 | `0854`, // Unknown product 264 | `0856`, // Unknown product 265 | `0858`, // Unknown product 266 | `085a`, // FS MultiPass FIDO U2F 267 | `085b`, // Unknown product 268 | `085d`, // Unknown product 269 | `0866`, // BioPass FIDO2 K33 270 | `0867`, // BioPass FIDO2 K43 271 | `0880`, // Hypersecu HyperFIDO 272 | } 273 | CombineIDs(&id, &products, &bsd.SecurityKey) 274 | case "Yubico": 275 | products := []string{ 276 | `0113`, // YubiKey NEO FIDO 277 | `0114`, // YubiKey NEO OTP+FIDO 278 | `0115`, // YubiKey NEO FIDO+CCID 279 | `0116`, // YubiKey NEO OTP+FIDO+CCID 280 | `0120`, // Security Key by Yubico 281 | `0121`, // Unknown product 282 | `0200`, // Gnubby U2F 283 | `0402`, // YubiKey 4 FIDO 284 | `0403`, // YubiKey 4 OTP+FIDO 285 | `0406`, // YubiKey 4 FIDO+CCID 286 | `0407`, // YubiKey 4 OTP+FIDO+CCID 287 | `0410`, // YubiKey Plus 288 | } 289 | CombineIDs(&id, &products, &bsd.SecurityKey) 290 | case "Silicon": 291 | products := []string{ 292 | `8acf`, // U2F Zero 293 | } 294 | CombineIDs(&id, &products, &bsd.SecurityKey) 295 | case "pid.codes": 296 | products := []string{ 297 | `5070`, // SoloKeys SoloHacker 298 | `50b0`, // SoloKeys SoloBoot 299 | `53c1`, // SatoshiLabs TREZOR 300 | `beee`, // SoloKeys v2 301 | } 302 | CombineIDs(&id, &products, &bsd.SecurityKey) 303 | case "Google": 304 | products := []string{ 305 | `5026`, // Google Titan U2F 306 | } 307 | CombineIDs(&id, &products, &bsd.SecurityKey) 308 | case "VASCO": 309 | products := []string{ 310 | `00bb`, // VASCO SecureClick 311 | } 312 | CombineIDs(&id, &products, &bsd.SecurityKey) 313 | case "OpenMoko": 314 | products := []string{ 315 | `60fc`, // OnlyKey (FIDO2/U2F) 316 | } 317 | CombineIDs(&id, &products, &bsd.SecurityKey) 318 | case "NEOWAVE": 319 | products := []string{ 320 | `f1ae`, // Neowave Keydo AES 321 | `f1d0`, // Neowave Keydo 322 | 323 | } 324 | CombineIDs(&id, &products, &bsd.SecurityKey) 325 | case "Excelsecu": 326 | products := []string{ 327 | `f025`, // Thethis Key 328 | `fc25`, // ExcelSecu FIDO2 Security Key 329 | } 330 | CombineIDs(&id, &products, &bsd.SecurityKey) 331 | case "NXP": 332 | products := []string{ 333 | `f143`, // GoTrust Idem Key 334 | } 335 | CombineIDs(&id, &products, &bsd.SecurityKey) 336 | case "ClayLogic": 337 | products := []string{ 338 | `4287`, // Nitrokey FIDO U2F 339 | `42b1`, // Nitrokey FIDO2 340 | `42b2`, // Nitrokey 3C NFC 341 | `42b3`, // Safetech SafeKey 342 | `42d4`, // CanoKey 343 | } 344 | CombineIDs(&id, &products, &bsd.SecurityKey) 345 | case "Alladdin": 346 | products := []string{ 347 | `0101`, // JaCarta U2F 348 | `0501`, // JaCarta U2F 349 | } 350 | CombineIDs(&id, &products, &bsd.SecurityKey) 351 | case "Plug-up": 352 | products := []string{ 353 | `f1d0`, // Happlink Security Key 354 | } 355 | CombineIDs(&id, &products, &bsd.SecurityKey) 356 | case "Bluink": 357 | products := []string{ 358 | `1002`, // Bluink Key 359 | } 360 | CombineIDs(&id, &products, &bsd.SecurityKey) 361 | case "LEDGER": 362 | products := []string{ 363 | `0000`, // Ledger Blue 364 | `0001`, // Ledger Nano S Old firmware 365 | `0004`, // Ledger Nano X Old firmware 366 | `0011`, // Ledger Blue 367 | `0015`, // Ledger Blue Legacy 368 | `1011`, // Ledger Nano S 369 | `1015`, // Ledger Nano S Legacy 370 | `4011`, // Ledger Nano X 371 | `4015`, // Ledger Nano X Legacy 372 | } 373 | CombineIDs(&id, &products, &bsd.SecurityKey) 374 | case "HyperSecu": 375 | products := []string{ 376 | `0880`, // Hypersecu HyperFIDO 377 | } 378 | CombineIDs(&id, &products, &bsd.SecurityKey) 379 | case "eWBM": 380 | products := []string{ 381 | `4a2a`, // TrustKey Solutions FIDO2 G310H/G320H 382 | `4a1a`, // TrustKey Solutions FIDO2 G310 383 | `4c2a`, // TrustKey Solutions FIDO2 G320 384 | `5c2f`, // eWBM FIDO2 Goldengate G500 385 | `a6e9`, // TrustKey Solutions FIDO2 T120 386 | `a7f9`, // TrustKey Solutions FIDO2 T110 387 | `f47c`, // eWBM FIDO2 Goldengate G450 388 | } 389 | CombineIDs(&id, &products, &bsd.SecurityKey) 390 | case "GoTrust": 391 | products := []string{ 392 | `3201`, // Idem Key 393 | } 394 | CombineIDs(&id, &products, &bsd.SecurityKey) 395 | case "Unknown": 396 | products := []string{ 397 | `f703`, // Longmai mFIDO 398 | } 399 | CombineIDs(&id, &products, &bsd.SecurityKey) 400 | case "SatoshiLabs": 401 | products := []string{ 402 | `0001`, // SatoshiLabs TREZOR 403 | } 404 | CombineIDs(&id, &products, &bsd.SecurityKey) 405 | } 406 | } 407 | 408 | return bsd 409 | } 410 | -------------------------------------------------------------------------------- /pkg/util/cpu.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "encoding/json" 22 | "log" 23 | "os/exec" 24 | ) 25 | 26 | type LSCPU struct { 27 | Processor []struct { 28 | Field string `json:"field"` 29 | Data string `json:"data"` 30 | Children []struct { 31 | Field string `json:"field"` 32 | Data string `json:"data"` 33 | } `json:"children"` 34 | } `json:"lscpu"` 35 | } 36 | 37 | func ListCPU() *LSCPU { 38 | lscpu, _ := exec.Command( 39 | "lscpu", 40 | "-J", 41 | ).Output() 42 | 43 | lscpu_struct := LSCPU{} 44 | err := json.Unmarshal(lscpu, &lscpu_struct) 45 | if err != nil { 46 | log.Fatalln("Invalid CPU Struct") 47 | } 48 | 49 | return &lscpu_struct 50 | } 51 | -------------------------------------------------------------------------------- /pkg/util/disk.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "encoding/json" 22 | "log" 23 | "os/exec" 24 | "strings" 25 | ) 26 | 27 | type LSBLK struct { 28 | Blockdevices []BlockDevice 29 | } 30 | 31 | type BlockDevice struct { 32 | // lsblk from util-linux 2.38 33 | Alignment int `json:"alignment"` 34 | DiscAln int `json:"disc-aln"` 35 | Dax bool `json:"dax"` 36 | DiscGran string `json:"disc-gran"` 37 | DiscMax string `json:"disc-max"` 38 | DiscZero bool `json:"disc-zero"` 39 | Fsavail interface{} `json:"fsavail"` 40 | Fsroots []interface{} `json:"fsroots"` 41 | Fssize interface{} `json:"fssize"` 42 | Fstype string `json:"fstype"` 43 | Fsused interface{} `json:"fsused"` 44 | Fsuse interface{} `json:"fsuse%"` 45 | Fsver string `json:"fsver"` 46 | Group string `json:"group"` 47 | Hctl string `json:"hctl"` 48 | Hotplug bool `json:"hotplug"` 49 | Kname string `json:"kname"` 50 | Label string `json:"label"` 51 | LogSec int `json:"log-sec"` 52 | MajMin string `json:"maj:min"` 53 | MinIo int `json:"min-io"` 54 | Mode string `json:"mode"` 55 | Model string `json:"model"` 56 | Name string `json:"name"` 57 | OptIo int `json:"opt-io"` 58 | Owner string `json:"owner"` 59 | Partflags interface{} `json:"partflags"` 60 | Partlabel interface{} `json:"partlabel"` 61 | Parttype interface{} `json:"parttype"` 62 | Parttypename interface{} `json:"parttypename"` 63 | Partuuid interface{} `json:"partuuid"` 64 | Path string `json:"path"` 65 | PhySec int `json:"phy-sec"` 66 | Pkname interface{} `json:"pkname"` 67 | Pttype string `json:"pttype"` 68 | Ptuuid string `json:"ptuuid"` 69 | Ra int `json:"ra"` 70 | Rand bool `json:"rand"` 71 | Rev string `json:"rev"` 72 | Rm bool `json:"rm"` 73 | Ro bool `json:"ro"` 74 | Rota bool `json:"rota"` 75 | RqSize int `json:"rq-size"` 76 | Sched string `json:"sched"` 77 | Serial string `json:"serial"` 78 | Size string `json:"size"` 79 | Start interface{} `json:"start,omitempty"` 80 | State string `json:"state"` 81 | Subsystems string `json:"subsystems"` 82 | Mountpoint interface{} `json:"mountpoint"` 83 | Mountpoints []interface{} `json:"mountpoints"` 84 | Tran string `json:"tran"` 85 | Type string `json:"type"` 86 | UUID string `json:"uuid"` 87 | Vendor string `json:"vendor"` 88 | Wsame string `json:"wsame"` 89 | Wwn interface{} `json:"wwn"` 90 | Zoned string `json:"zoned"` 91 | ZoneSz int `json:"zone-sz,omitempty"` 92 | ZoneWgran int `json:"zone-wgran,omitempty"` 93 | ZoneApp int `json:"zone-app,omitempty"` 94 | ZoneNr int `json:"zone-nr,omitempty"` 95 | ZoneOmax int `json:"zone-omax,omitempty"` 96 | ZoneAmax int `json:"zone-amax,omitempty"` 97 | Children []BlockDevice `json:"children,omitempty"` 98 | } 99 | 100 | func ListDisk() *LSBLK { 101 | // util-linux 2.38 breaks accepting all columns 102 | // lsblk, _ := exec.Command( 103 | // "lsblk", 104 | // "-J", 105 | // "-O", 106 | // ).Output() 107 | 108 | // Temporary fix for util-linux 2.38 until columns are fixed 109 | lsblk_columns := []string{ 110 | "alignment", 111 | "disc-aln", 112 | "dax", 113 | "disc-gran", 114 | "disc-max", 115 | "disc-zero", 116 | "fsavail", 117 | "fsroots", 118 | "fssize", 119 | "fstype", 120 | "fsused", 121 | "fsuse%", 122 | "fsver", 123 | "group", 124 | "hctl", 125 | "hotplug", 126 | "kname", 127 | "label", 128 | "log-sec", 129 | "maj:min", 130 | "min-io", 131 | "mode", 132 | "model", 133 | "name", 134 | "opt-io", 135 | "owner", 136 | "partflags", 137 | "partlabel", 138 | "parttype", 139 | "parttypename", 140 | "partuuid", 141 | "path", 142 | "phy-sec", 143 | "pkname", 144 | "pttype", 145 | "ptuuid", 146 | "ra", 147 | "rand", 148 | "rev", 149 | "rm", 150 | "ro", 151 | "rota", 152 | "rq-size", 153 | "sched", 154 | "serial", 155 | "size", 156 | "state", 157 | "subsystems", 158 | "mountpoint", 159 | "mountpoints", 160 | "tran", 161 | "type", 162 | "uuid", 163 | "vendor", 164 | "wsame", 165 | "wwn", 166 | "zoned", 167 | } 168 | 169 | lsblk, _ := exec.Command( 170 | "lsblk", 171 | "-J", 172 | "-o", 173 | strings.Join(lsblk_columns, ","), 174 | ).Output() 175 | 176 | lsblk_struct := LSBLK{} 177 | err := json.Unmarshal(lsblk, &lsblk_struct) 178 | if err != nil { 179 | log.Fatalln("Invalid LSBLK Struct") 180 | } 181 | 182 | return &lsblk_struct 183 | } 184 | -------------------------------------------------------------------------------- /pkg/util/files.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "io/fs" 22 | "log" 23 | "os" 24 | "path/filepath" 25 | "regexp" 26 | "strings" 27 | ) 28 | 29 | // Define regular expression for Linux and Windows linebreaks 30 | var ( 31 | lineBreakRegExp = regexp.MustCompile(`\r?\n`) 32 | ) 33 | 34 | func ReadFile(filePath *string, fileName *string) *[]string { 35 | 36 | // Grab current directory 37 | pwd, err := os.Getwd() 38 | if err != nil { 39 | log.Fatalln(err) 40 | } 41 | 42 | log.Printf("Changing directory to %q", *filePath) 43 | if err := os.Chdir(*filePath); err != nil { 44 | log.Fatalln(err) 45 | } 46 | 47 | file, err := os.ReadFile(*fileName) 48 | if err != nil { 49 | log.Fatalln(err) 50 | } 51 | 52 | fileContents := lineBreakRegExp.Split(string(file), -1) 53 | 54 | log.Printf("Reading contents of %q", *fileName) 55 | for i, line := range fileContents { 56 | log.Println(i, "\t", line) 57 | } 58 | 59 | log.Println("Returning to original directory") 60 | // Return to original directory 61 | if err := os.Chdir(pwd); err != nil { 62 | log.Fatalln(err) 63 | } 64 | 65 | return &fileContents 66 | } 67 | 68 | func WriteFile(filePath *string, fileName *string, fileContents *[]string, fileFlag int, filePerm int) { 69 | // Grab current directory 70 | pwd, err := os.Getwd() 71 | if err != nil { 72 | log.Fatalln(err) 73 | } 74 | 75 | log.Printf("Changing directory to %q", *filePath) 76 | if err := os.Chdir(*filePath); err != nil { 77 | log.Fatalln(err) 78 | } 79 | 80 | f, err := os.OpenFile(filepath.Join(*filePath, *fileName), fileFlag, fs.FileMode(filePerm)) 81 | if err != nil { 82 | log.Fatalln(err) 83 | } 84 | log.Println(`Saving settings`) 85 | if _, err := f.Write([]byte(strings.Join(*fileContents, "\n") + "\n")); err != nil { 86 | log.Fatalln(err) 87 | } 88 | log.Println(`Closing file`) 89 | if err := f.Close(); err != nil { 90 | log.Fatalln(err) 91 | } 92 | log.Println("Done!") 93 | 94 | log.Println("Returning to original directory") 95 | // Return to original directory 96 | if err := os.Chdir(pwd); err != nil { 97 | log.Fatalln(err) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /pkg/util/firefox_pwa.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | type FIREFOX_PWA struct { 21 | Profiles map[string]Profile `json:"profiles"` 22 | Sites map[string]Site `json:"sites"` 23 | Arguments []interface{} `json:"arguments"` 24 | Variables struct{} `json:"variables"` 25 | Config struct { 26 | AlwaysPatch bool `json:"always_patch"` 27 | RuntimeEnableWayland bool `json:"runtime_enable_wayland"` 28 | RuntimeUseXinput2 bool `json:"runtime_use_xinput2"` 29 | RuntimeUsePortals bool `json:"runtime_use_portals"` 30 | } `json:"config"` 31 | } 32 | 33 | type Profile struct { 34 | Ulid string `json:"ulid"` 35 | Name string `json:"name"` 36 | Description string `json:"description"` 37 | Sites []string `json:"sites"` 38 | } 39 | 40 | type Site struct { 41 | Ulid string `json:"ulid"` 42 | Profile string `json:"profile"` 43 | Config SiteConfig `json:"config"` 44 | Icons []Icon `json:"icons"` 45 | Screenshots []interface{} `json:"screenshots"` 46 | } 47 | 48 | type SiteConfig struct { 49 | Name string `json:"name"` 50 | Description string `json:"description"` 51 | StartURL string `json:"start_url"` 52 | DocumentURL string `json:"document_url"` 53 | ManifestURL string `json:"manifest_url"` 54 | Categories interface{} `json:"categories"` 55 | Keywords interface{} `json:"keywords"` 56 | EnabledURLHandlers []interface{} `json:"enabled_url_handlers"` 57 | EnabledProtocolHandlers []interface{} `json:"enabled_protocol_handlers"` 58 | CustomProtocolHandlers []interface{} `json:"custom_protocol_handlers"` 59 | } 60 | 61 | type SiteManifest struct { 62 | StartURL string `json:"start_url"` 63 | Scope string `json:"scope"` 64 | Name string `json:"name"` 65 | ShortName string `json:"short_name"` 66 | Categories []interface{} `json:"categories"` 67 | Keywords []interface{} `json:"keywords"` 68 | Dir string `json:"dir"` 69 | Display string `json:"display"` 70 | Orientation string `json:"orientation"` 71 | BackgroundColor string `json:"background_color"` 72 | ThemeColor string `json:"theme_color"` 73 | PreferRelatedApplications bool `json:"prefer_related_applications"` 74 | RelatedApplications []interface{} `json:"related_applications"` 75 | ProtocolHandlers []interface{} `json:"protocol_handlers"` 76 | Shortcuts []SiteShortcut `json:"shortcuts"` 77 | Icons []Icon `json:"icons"` 78 | Screenshots []interface{} `json:"screenshots"` 79 | } 80 | 81 | type SiteShortcut struct { 82 | Name string `json:"name"` 83 | URL string `json:"url"` 84 | Icons []Icon `json:"icons"` 85 | } 86 | 87 | type Icon struct { 88 | Src string `json:"src"` 89 | Type string `json:"type"` 90 | Sizes string `json:"sizes"` 91 | Purpose string `json:"purpose"` 92 | } 93 | -------------------------------------------------------------------------------- /pkg/util/host.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "encoding/json" 22 | "log" 23 | "os/exec" 24 | ) 25 | 26 | type HostStatus struct { 27 | Hostname string `json:"Hostname"` 28 | StaticHostname string `json:"StaticHostname"` 29 | PrettyHostname interface{} `json:"PrettyHostname"` 30 | DefaultHostname string `json:"DefaultHostname"` 31 | HostnameSource string `json:"HostnameSource"` 32 | IconName string `json:"IconName"` 33 | Chassis string `json:"Chassis"` 34 | Deployment interface{} `json:"Deployment"` 35 | Location interface{} `json:"Location"` 36 | KernelName string `json:"KernelName"` 37 | KernelRelease string `json:"KernelRelease"` 38 | KernelVersion string `json:"KernelVersion"` 39 | OperatingSystemPrettyName string `json:"OperatingSystemPrettyName"` 40 | OperatingSystemCPEName interface{} `json:"OperatingSystemCPEName"` 41 | OperatingSystemHomeURL string `json:"OperatingSystemHomeURL"` 42 | HardwareVendor string `json:"HardwareVendor"` 43 | HardwareModel string `json:"HardwareModel"` 44 | ProductUUID interface{} `json:"ProductUUID"` 45 | } 46 | 47 | func GetHostStatus() *HostStatus { 48 | hostnamectl, _ := exec.Command( 49 | "hostnamectl", 50 | "status", 51 | "--json=pretty", 52 | ).Output() 53 | 54 | hostnamectl_struct := HostStatus{} 55 | err := json.Unmarshal(hostnamectl, &hostnamectl_struct) 56 | if err != nil { 57 | log.Fatalln("Invalid LSBLK Struct") 58 | } 59 | 60 | return &hostnamectl_struct 61 | } 62 | -------------------------------------------------------------------------------- /pkg/util/pci.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "os/exec" 22 | "strings" 23 | ) 24 | 25 | type LSPCI struct { 26 | PCIDevices []PCIDevice 27 | } 28 | 29 | type PCIDevice struct { 30 | Slot string `json:"Slot,omitempty"` 31 | Class string `json:"Class,omitempty"` 32 | Vendor string `json:"Vendor,omitempty"` 33 | Device string `json:"Device,omitempty"` 34 | SVendor string `json:"SVendor,omitempty"` 35 | SDevice string `json:"SDevice,omitempty"` 36 | Rev string `json:"Rev,omitempty"` //int 37 | ProgIf string `json:"ProgIf,omitempty"` 38 | PhySlot string `json:"PhySlot,omitempty"` //int 39 | NUMANode string `json:"NUMANode,omitempty"` //int 40 | IOMMUGroup string `json:"IOMMUGroup,omitempty"` //int 41 | } 42 | 43 | func ListPCI() *LSPCI { 44 | 45 | lspci, _ := exec.Command( 46 | `lspci`, 47 | `-vmmq`, // [-v] Verbose --[-mm] machine-readable output -- [-q] query database for unknown IDs 48 | ).CombinedOutput() 49 | 50 | pci_devices := string(lspci) 51 | 52 | return PCIJSON(&pci_devices) 53 | } 54 | 55 | func PCIJSON(lspci *string) *LSPCI { 56 | 57 | pci_struct := &LSPCI{} 58 | 59 | device := PCIDevice{} 60 | 61 | pci_list := strings.Split(*lspci, "\n") 62 | 63 | for i := range pci_list { 64 | if strings.HasPrefix(pci_list[i], "Slot:\t") { 65 | device.Slot = strings.TrimPrefix(pci_list[i], "Slot:\t") 66 | } else if strings.HasPrefix(pci_list[i], "Class:\t") { 67 | device.Class = strings.TrimPrefix(pci_list[i], "Class:\t") 68 | } else if strings.HasPrefix(pci_list[i], "Vendor:\t") { 69 | device.Vendor = strings.TrimPrefix(pci_list[i], "Vendor:\t") 70 | } else if strings.HasPrefix(pci_list[i], "Device:\t") { 71 | device.Device = strings.TrimPrefix(pci_list[i], "Device:\t") 72 | } else if strings.HasPrefix(pci_list[i], "SVendor:\t") { 73 | device.SVendor = strings.TrimPrefix(pci_list[i], "SVendor:\t") 74 | } else if strings.HasPrefix(pci_list[i], "SDevice:\t") { 75 | device.SDevice = strings.TrimPrefix(pci_list[i], "SDevice:\t") 76 | } else if strings.HasPrefix(pci_list[i], "Rev:\t") { 77 | device.Rev = strings.TrimPrefix(pci_list[i], "Rev:\t") 78 | } else if strings.HasPrefix(pci_list[i], "ProgIf:\t") { 79 | device.ProgIf = strings.TrimPrefix(pci_list[i], "ProgIf:\t") 80 | } else if strings.HasPrefix(pci_list[i], "PhySlot:\t") { 81 | device.PhySlot = strings.TrimPrefix(pci_list[i], "PhySlot:\t") 82 | } else if strings.HasPrefix(pci_list[i], "NUMANode:\t") { 83 | device.NUMANode = strings.TrimPrefix(pci_list[i], "NUMANode:\t") 84 | } else if strings.HasPrefix(pci_list[i], "IOMMUGroup:\t") { 85 | device.IOMMUGroup = strings.TrimPrefix(pci_list[i], "IOMMUGroup:\t") 86 | } else if pci_list[i] == "" { 87 | // If device is not an empty struct, append 88 | if (device != PCIDevice{}) { 89 | pci_struct.PCIDevices = append(pci_struct.PCIDevices, device) 90 | } 91 | device = PCIDevice{} 92 | } 93 | } 94 | 95 | return pci_struct 96 | } 97 | -------------------------------------------------------------------------------- /pkg/util/pretty.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "bytes" 22 | "encoding/json" 23 | ) 24 | 25 | func PrettyJson(data interface{}) (string, error) { 26 | buffer := new(bytes.Buffer) 27 | encoder := json.NewEncoder(buffer) 28 | encoder.SetIndent("", "\t") 29 | 30 | err := encoder.Encode(data) 31 | if err != nil { 32 | return "", err 33 | } 34 | return buffer.String(), err 35 | } 36 | -------------------------------------------------------------------------------- /pkg/util/secure_boot.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "log" 22 | "os/exec" 23 | "strings" 24 | ) 25 | 26 | type SBCTL struct { 27 | Installed string `json:"Installed,omitempty"` 28 | OwnerGUID string `json:"OwnerGUID,omitempty"` 29 | SetupMode string `json:"SetupMode,omitempty"` 30 | SecureBoot string `json:"SecureBoot,omitempty"` 31 | VendorKeys string `json:"VendorKeys,omitempty"` 32 | } 33 | 34 | func SecureBootStatus() *SBCTL { 35 | 36 | log.Println("Grabbing Secure Boot Status...") 37 | 38 | sbctl, _ := exec.Command( 39 | "sbctl", 40 | "status", 41 | ).CombinedOutput() 42 | 43 | sbctl_status := string(sbctl) 44 | 45 | return SBJSON(&sbctl_status) 46 | } 47 | 48 | func SecureBootCreateKeys() *[]string { 49 | 50 | log.Println("Creating Secure Boot keys...") 51 | 52 | sbctl := []string{ 53 | "sbctl", 54 | "create-keys", 55 | } 56 | 57 | return &sbctl 58 | } 59 | 60 | func SecureBootEnrollKeys() *[]string { 61 | 62 | log.Println("Enrolling Secure Boot keys...") 63 | 64 | sbctl := []string{ 65 | "sbctl", 66 | "enroll-keys", 67 | "--microsoft", 68 | } 69 | 70 | return &sbctl 71 | } 72 | 73 | func SecureBootSign(file *string) *[]string { 74 | log.Printf("Signing %s with Secure Boot Keys", *file) 75 | 76 | sbctl := []string{ 77 | `sbctl`, 78 | `sign`, 79 | `-s`, 80 | *file, 81 | } 82 | 83 | return &sbctl 84 | } 85 | 86 | func SBJSON(sbctl *string) *SBCTL { 87 | 88 | sbctl_struct := &SBCTL{} 89 | 90 | sbctl_status := strings.Split(*sbctl, "\n") 91 | 92 | // ✓ - sbctl has native JSON output 93 | // ✘ - Doesn't work as of Release 0.9 94 | for i := range sbctl_status { 95 | if strings.HasPrefix(sbctl_status[i], "Installed:\t") { 96 | sbctl_struct.Installed = (strings.TrimPrefix(sbctl_status[i], "Installed:\t"))[4:] 97 | } else if strings.HasPrefix(sbctl_status[i], "Owner GUID:\t") { 98 | sbctl_struct.OwnerGUID = strings.TrimPrefix(sbctl_status[i], "Owner GUID:\t") 99 | } else if strings.HasPrefix(sbctl_status[i], "Setup Mode:\t") { 100 | sbctl_struct.SetupMode = (strings.TrimPrefix(sbctl_status[i], "Setup Mode:\t"))[4:] 101 | } else if strings.HasPrefix(sbctl_status[i], "Secure Boot:\t") { 102 | sbctl_struct.SecureBoot = (strings.TrimPrefix(sbctl_status[i], "Secure Boot:\t"))[4:] 103 | } else if strings.HasPrefix(sbctl_status[i], "Vendor Keys:\t") { 104 | sbctl_struct.VendorKeys = strings.TrimPrefix(sbctl_status[i], "Vendor Keys:\t") 105 | } else if sbctl_status[i] == "" { 106 | // Do nothing 107 | do := "nothing" 108 | _ = do 109 | } 110 | } 111 | 112 | return sbctl_struct 113 | } 114 | -------------------------------------------------------------------------------- /pkg/util/usb.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Automated Arch Linux Tools 3 | * Copyright (C) 2022 Anthony Dardano (ShobuPrime) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * ShobuArch is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package util 19 | 20 | import ( 21 | "fmt" 22 | "os/exec" 23 | "strings" 24 | ) 25 | 26 | type LSUSB struct { 27 | USBDevices []USBDevice 28 | } 29 | 30 | type USBDevice struct { 31 | Bus string `json:"bus,omitempty"` 32 | Device string `json:"device,omitempty"` 33 | ID string `json:"id,omitempty"` 34 | Description string `json:"description,omitempty"` 35 | } 36 | 37 | func ListUSB() *LSUSB { 38 | 39 | lsusb, _ := exec.Command( 40 | `lsusb`, 41 | ).CombinedOutput() 42 | 43 | usb_devices := string(lsusb) 44 | 45 | return PCIUSB(&usb_devices) 46 | } 47 | 48 | func PCIUSB(lsusb *string) *LSUSB { 49 | 50 | usb_struct := &LSUSB{} 51 | 52 | device := USBDevice{} 53 | 54 | usb_list := strings.Split(*lsusb, "\n") 55 | 56 | for i := range usb_list { 57 | switch usb_list[i] { 58 | case "": 59 | default: 60 | device.Bus = usb_list[i][4:7] 61 | device.Device = usb_list[i][15:19] 62 | device.ID = usb_list[i][23:32] 63 | device.Description = usb_list[i][33:] 64 | usb_struct.USBDevices = append(usb_struct.USBDevices, device) 65 | device = USBDevice{} 66 | } 67 | } 68 | 69 | return usb_struct 70 | } 71 | 72 | func CombineIDs(vendor_id *string, products *[]string, ids *[]string) { 73 | 74 | for _, product_id := range *products { 75 | (*ids) = append( 76 | (*ids), 77 | fmt.Sprintf(`%s:%s`, (*vendor_id), product_id), 78 | ) 79 | } 80 | } 81 | --------------------------------------------------------------------------------