ソースを参照

automatically log installation to file for reflection

adjust virtualization detection method and relabel comments

change automatic reboot to option

relocate gpu dependent packages to second pacman installation block
Casey DeLorme 3 年 前
コミット
b62d99d305
5 ファイル変更43 行追加30 行削除
  1. 1 0
      .gitignore
  2. 22 19
      arch.sh
  3. 2 2
      packer.json
  4. 15 7
      setup/install.sh
  5. 3 2
      setup/packer.sh

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 packer_cache/
 dist/
 .vagrant/
+arch-install.log

+ 22 - 19
arch.sh

@@ -53,7 +53,7 @@ curl -O https://download.sublimetext.com/sublimehq-pub.gpg && pacman-key --add s
 [ $(grep -c "sublime-text" /etc/pacman.conf) -eq 0 ] && echo -e "\n[sublime-text]\nServer = https://download.sublimetext.com/arch/stable/x86_64" | tee -a /etc/pacman.conf
 
 # update and install all packages
-pacman -Syu --noconfirm sudo bash-completion man-db tmux vim linux-firmware linux-headers dkms smartmontools cryptsetup usbutils btrfs-progs gvfs gvfs-mtp gvfs-afc android-udev dmidecode parted pkgfile pkgconf bison gcc gcc-libs cmake ccache ncurses xmlstarlet jq at bc cronie iptables rsync dhcpcd inetutils net-tools openssh sshfs ntp wget curl wireless_tools bluez bluez-utils lzop unzip p7zip xz unrar unace lrzip arj git mercurial subversion bzr postgresql mesa lib32-mesa dbus polkit xorg-server xorg-server-devel xorg-xinit xorg-xinput xorg-xdpyinfo xorg-xprop xdotool xsel patchelf libpng12 lib32-libpng12 pulseaudio libpulse lib32-libpulse openal lib32-openal giflib lib32-giflib mpg123 lib32-mpg123 v4l-utils lib32-v4l-utils opencl-icd-loader lib32-opencl-icd-loader libva lib32-libva gtk3 lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-tools vulkan-icd-loader lib32-vulkan-icd-loader arandr feh hsetroot openbox archlinux-xdg-menu picom xarchiver innoextract pavucontrol pasystray xdg-utils xdg-user-dirs tint2 conky pcmanfm gmrun rxvt-unicode urxvt-perls gnome-themes-extra gnome-icon-theme arc-gtk-theme gtk-engines gtk-engine-murrine lxappearance graphicsmagick imagemagick lame libwebp libid3tag libvorbis vorbis-tools faac x264 x265 libexif ffmpeg ffmpegthumbnailer tumbler joyutils evtest lm_sensors lshw gparted psensor gparted hardinfo fontconfig ttf-bitstream-vera ttf-droid ttf-dejavu ttf-liberation ttf-hanazono mpv openshot gimp krita transmission-cli discord evince viewnior virtualbox-host-modules-arch virtualbox vagrant obs-studio dia mednafen mame ppsspp lutris steam wine-staging python-pip python-setuptools winetricks sublime-text stress lxsession yt-dlp firefox
+pacman -Syu --noconfirm sudo bash-completion man-db tmux vim linux-firmware linux-headers dkms smartmontools cryptsetup usbutils btrfs-progs gvfs gvfs-mtp gvfs-afc android-udev dmidecode parted pkgfile pkgconf bison gcc gcc-libs cmake ccache ncurses xmlstarlet jq at bc cronie iptables rsync dhcpcd inetutils net-tools openssh sshfs ntp wget curl wireless_tools bluez bluez-utils lzop unzip p7zip xz unrar unace lrzip arj git mercurial subversion bzr postgresql mesa lib32-mesa dbus polkit xorg-server xorg-server-devel xorg-xinit xorg-xinput xorg-xdpyinfo xorg-xprop xdotool xsel patchelf libpng12 lib32-libpng12 pulseaudio libpulse lib32-libpulse openal lib32-openal giflib lib32-giflib mpg123 lib32-mpg123 v4l-utils lib32-v4l-utils opencl-icd-loader lib32-opencl-icd-loader libva lib32-libva gtk3 lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs arandr feh hsetroot openbox archlinux-xdg-menu picom xarchiver innoextract pavucontrol pasystray xdg-utils xdg-user-dirs tint2 conky pcmanfm gmrun rxvt-unicode urxvt-perls gnome-themes-extra gnome-icon-theme arc-gtk-theme gtk-engines gtk-engine-murrine lxappearance graphicsmagick imagemagick lame libwebp libid3tag libvorbis vorbis-tools faac x264 x265 libexif ffmpeg ffmpegthumbnailer tumbler joyutils evtest lm_sensors lshw gparted psensor gparted hardinfo fontconfig ttf-bitstream-vera ttf-droid ttf-dejavu ttf-liberation ttf-hanazono mpv openshot gimp krita transmission-cli evince viewnior virtualbox-host-modules-arch virtualbox vagrant python-pip python-setuptools sublime-text stress lxsession yt-dlp
 
 # install base configuration files from repository
 [ -d /srv/arch-desktop/install ] || git clone https://git.caseydelorme.com/cdelorme/arch-desktop /srv/arch-desktop
@@ -80,29 +80,29 @@ sed -i 's/^#MAKEFLAGS.*/MAKEFLAGS="-j$(($(nproc) + 1)) -l$(nproc)"/' /etc/makepk
 [ $(grep -c "Intel" /proc/cpuinfo) -gt 0 ] && pacman -Syu --noconfirm intel-ucode
 [ $(grep -c "AMD" /proc/cpuinfo) -gt 0 ] && pacman -Syu --noconfirm amd-ucode
 
-# install nvidia related packages
-if [ $(lspci | grep -i " vga" | grep -ci " nvidia") -gt 0 ]; then
-	pacman -Syu --noconfirm nvidia-dkms libglvnd nvidia-utils opencl-nvidia lib32-libglvnd lib32-nvidia-utils lib32-opencl-nvidia nvidia-settings
+# install GPU related packages
+if [ $(lspci | grep -i "vga" | grep -ci "amd") -gt 0 ]; then
+	pacman -Syu --noconfirm xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau vulkan-tools vulkan-icd-loader lib32-vulkan-icd-loader
 
 	# update modules to load
-	[ $(grep -c "nvidia" /etc/mkinitcpio.conf) -eq 0 ] && sed -i 's/MODULES=(\(.*\))/MODULES=(\1 nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' /etc/mkinitcpio.conf
-
-	# automatic updates in pacman.d
-	echo -e "[Trigger]\nOperation=Install\nOperation=Upgrade\nOperation=Remove\nType=Package\nTarget=nvidia\n\n[Action]\nDepends=mkinitcpio\nWhen=PostTransaction\nExec=/usr/bin/mkinitcpio -P" > /etc/pacman.d/hooks/nvidia.hook
-fi
+	[ $(grep -c "amd" /etc/mkinitcpio.conf) -eq 0 ] && sed -i 's/MODULES=(\(.*\))/MODULES=(\1 amdgpu radeon)/' /etc/mkinitcpio.conf
+elif [ $(lspci | grep -i "vga" | grep -ci "intel") -gt 0 ]; then
+	pacman -Syu --noconfirm xf86-video-intel vulkan-intel lib32-vulkan-intel libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau vulkan-tools vulkan-icd-loader lib32-vulkan-icd-loader
 
-# install AMD/Radeon related packages
-if [ $(lspci | grep -i "vga" | grep -ci "amd") -gt 0 ]; then
-	pacman -Syu --noconfirm xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau amdvlk lib32-amdvlk
+	# update modules to load
+	[ $(grep -c "amd" /etc/mkinitcpio.conf) -eq 0 ] && sed -i 's/MODULES=(\(.*\))/MODULES=(\1 i915)/' /etc/mkinitcpio.conf
+elif [ $(lspci | grep -i "vga" | grep -ci "nvidia") -gt 0 ]; then
+	pacman -Syu --noconfirm nvidia-dkms libglvnd lib32-libglvnd opencl-nvidia lib32-opencl-nvidia xf86-video-nouveau nvidia-utils lib32-nvidia-utils libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau vulkan-tools vulkan-icd-loader lib32-vulkan-icd-loader nvidia-settings
 
 	# update modules to load
-	[ $(grep -c "amd" /etc/mkinitcpio.conf) -eq 0 ] && sed -i 's/MODULES=(\(.*\))/MODULES=(\1 amdgpu radeon)/' /etc/mkinitcpio.conf
+	[ $(grep -c "nvidia" /etc/mkinitcpio.conf) -eq 0 ] && sed -i 's/MODULES=(\(.*\))/MODULES=(\1 nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' /etc/mkinitcpio.conf
+
+	# automatic mkinitcpio updates in pacman.d
+	echo -e "[Trigger]\nOperation=Install\nOperation=Upgrade\nOperation=Remove\nType=Package\nTarget=nvidia\n\n[Action]\nDepends=mkinitcpio\nWhen=PostTransaction\nExec=/usr/bin/mkinitcpio -P" > /etc/pacman.d/hooks/nvidia.hook
 fi
 
-# create a user to install aur packages
-export aur_username=$(head /dev/urandom | tr -dc a-z | head -c 13 ; echo '')
-useradd -r -m -s /bin/bash $aur_username
-echo "${aur_username} ALL= NOPASSWD: /usr/bin/pacman" > /etc/sudoers.d/${aur_username}
+# install packages dependent on gpu packages
+pacman -Syu --noconfirm firefox obs-studio dia mednafen mame ppsspp lutris wine-staging winetricks steam discord
 
 # install laptop packages and optimize system configuration
 # @note: alternatively if `/sys/class/power_supply/BAT0` exists, we have a battery, probably laptop
@@ -114,6 +114,11 @@ if [[ "$chassistype" = "Laptop" || "$chassistype" = "Portable" || "$chassistype"
 	systemctl enable acpid
 fi
 
+# create a user to install aur packages
+export aur_username=$(head /dev/urandom | tr -dc a-z | head -c 13 ; echo '')
+useradd -r -m -s /bin/bash $aur_username
+echo "${aur_username} ALL= NOPASSWD: /usr/bin/pacman" > /etc/sudoers.d/${aur_username}
+
 # install xcursor-chameleon-skyblue
 sudo -u $aur_username git clone https://aur.archlinux.org/xcursor-chameleon-skyblue.git /home/${aur_username}/xcursor-chameleon-skyblue
 (cd /home/${aur_username}/xcursor-chameleon-skyblue && sudo -u ${aur_username} makepkg -rcsi --noconfirm)
@@ -259,5 +264,3 @@ echo "default arch" >> /boot/loader/loader.conf
 
 # check boot loader configuration
 bootctl status
-
-echo "instalation complete, please exit, umount -R /mnt, and reboot..."

+ 2 - 2
packer.json

@@ -54,8 +54,8 @@
 			"skip_clean": true,
 			"expect_disconnect": true,
 			"environment_vars": [
-				"PACKER=y",
-				"DEBUG=true",
+				"AUTOREBOOT=y",
+				"DEBUG=y",
 				"enable_hibernation=y",
 				"root_password={{user `root_password`}}",
 				"username={{user `username`}}",

+ 15 - 7
setup/install.sh

@@ -22,13 +22,13 @@ while [ -z "$root_password" ]; do read -p "please enter a root password: " -s ro
 while [ -z "$username" ]; do read -p "please enter your username: " username; done
 while [ -z "$password" ]; do read -p "please enter your password: " -s password && echo ""; done
 
-# export environment variables for arch.sh
+# export environment variables for arch.sh automation
 export root_password
 export username
 export password
 
 # optionally print all commands
-[ -n "$DEBUG" ] && set -x
+[ -n "$DEBUG" ] && set -x && export DEBUG
 
 # test network connection
 ping -c 3 archlinux.org
@@ -92,13 +92,21 @@ mkdir -p /mnt/srv/arch-desktop
 cp -r install /mnt/srv/arch-desktop/
 cp arch.sh /mnt/srv/arch-desktop/
 
-# proceed to automate arch-chroot installation then umount and reboot with an async delay
-arch-chroot /mnt /srv/arch-desktop/arch.sh
-if [ -n "$PACKER" ]; then
+# proceed to automate arch-chroot installation and push output to a log file that gets copied to the new disk
+arch-chroot /mnt /srv/arch-desktop/arch.sh | tee arch-install.log
+cp arch-install.log /mnt/arch-install.log
+
+# if virtualized enable ssh as root for automation support
+if [ $(dmesg | grep -ci "hypervisor") -gt 0 ]; then
 	sed -i "/^#\?PermitRootLogin/d" /mnt/etc/ssh/sshd_config
 	sed -i "/^#\?PasswordAuthentication/d" /mnt/etc/ssh/sshd_config
 	echo "PasswordAuthentication yes" >> /mnt/etc/ssh/sshd_config
 	echo "PermitRootLogin yes" >> /mnt/etc/ssh/sshd_config
 fi
-umount -R /mnt
-(sleep 5 && systemctl reboot) &
+
+# if auto-reboot is enabled then unmount and automatically reboot
+if [ -n "AUTOREBOOT" ]; then
+	sync
+	umount -R /mnt
+	(sleep 5 && systemctl reboot) &
+fi

+ 3 - 2
setup/packer.sh

@@ -6,14 +6,15 @@ sed -i "/^#\?PermitRootLogin/d" /etc/ssh/sshd_config
 echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
 
-# VirtualBox Guest Additions
+# install VirtualBox Guest Additions
 # https://wiki.archlinux.org/index.php/VirtualBox
 pacman -S --noconfirm linux-headers virtualbox-guest-utils virtualbox-guest-modules-arch nfs-utils
 echo -e 'vboxguest\nvboxsf\nvboxvideo' > /etc/modules-load.d/virtualbox.conf
 
+# enable related virtualization and networking services
 systemctl enable vboxservice.service
 systemctl enable rpcbind.service
 
-# Clean the pacman cache.
+# Clean the pacman cache to minify image
 yes | pacman -Scc
 sync