diff --git a/archinstall/archinstall.sh b/archinstall/archinstall.sh index 89c8666..277aa54 100755 --- a/archinstall/archinstall.sh +++ b/archinstall/archinstall.sh @@ -45,8 +45,31 @@ fatalerror "$(T "Pacman error, problems in repositories, apologizes. You have to fi } -function inchroot { -chroot /mnt /bin/bash -c "$*" +function execl { ##This function logs the command executed +local command +echo "------" >> "/tmp/install.log" +if [[ $1 != "chroot" ]];then #If it runs outside chroot +command="$1" +for (( i=2; i<=$#; i++ )) +do + command="$command $(echo $* | cut -f$i -d" ")" +done +echo "$command" >> "/tmp/install.log" +$command +else #else: If it runs in chroot +for (( i=2; i<=$#; i++ )) +do + command="$command $(echo $* | cut -f$i -d" ")" +done +echo "(In the install partition/chroot) $command" >> "/tmp/install.log" +chroot /mnt /bin/bash -c "$command" +fi + +if [[ $? == 0 ]];then +echo "Result Ok " >> "/tmp/install.log" +else +echo "Result Error: Code $?" >> "/tmp/install.log" +fi } function optstate { @@ -277,31 +300,31 @@ clear tput setaf 2 ; echo "$(T "Installing system, this can take about 10 minutes, wait")" ; tput setaf 9 sleep 2 tput setaf 2 ; echo "$(T "Formatting and mounting partitions")" ; tput setaf 9 -$formatoraiz /dev/$particionraiz +execl $formatoraiz /dev/$particionraiz e2label /dev/$particionraiz "JKArch" -mount /dev/$particionraiz /mnt/ +execl mount /dev/$particionraiz /mnt/ if [[ $particionhome ]];then -$formatohome /dev/$particionhome +execl $formatohome /dev/$particionhome mkdir -p /mnt/home/ -mount /dev/$particionhome /mnt/home/ +execl mount /dev/$particionhome /mnt/home/ fi if [[ $partefi ]];then mkdir -p /mnt/boot/efi -mount /dev/$partefi /mnt/boot/efi/ +execl mount /dev/$partefi /mnt/boot/efi/ fi if [[ $isoffline = "0" ]];then wget -nv https://gitlab.com/JKANetwork/JKArch/raw/master/archinstall/pacman.conf -O pacman.conf isanetworkerror #Comprueba si hubo un error de descarga tput setaf 2 ; echo "$(T "Optimizing download")" ; tput setaf 9 - reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist + execl reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist tput setaf 2 ; echo "$(T "Downloading")" ; tput setaf 9 - pacstrap -C pacman.conf /mnt/ base btrfs-progs jkarch-mirrorlist + execl pacstrap -C pacman.conf /mnt/ base btrfs-progs jkarch-mirrorlist pacmanerror mv pacman.conf /mnt/etc/pacman.conf fi if [[ $isoffline = "1" ]];then tput setaf 2 ; echo "$(T "Installing packages")..." ; tput setaf 9 - pacstrap -C pacman-offline.conf /mnt/ base btrfs-progs jkarch-mirrorlist + execl pacstrap -C pacman-offline.conf /mnt/ base btrfs-progs jkarch-mirrorlist mv pacman-offline.conf /mnt/etc/pacman.conf #Move pacman.conf (offline) to pacman chroot location fi @@ -332,7 +355,7 @@ if [[ $isoffline = 1 ]];then mount --bind /run/archiso/bootmnt/ /mnt/run/archiso/bootmnt/ # CD bind fi -inchroot pacman -Syu jka-toolkit git wget netctl iw wpa_supplicant dialog sudo alsa-utils dosfstools ntfs-3g bash-completion --noconfirm --needed #Install base packages +execl chroot pacman -Syu jka-toolkit git wget netctl iw wpa_supplicant dialog sudo alsa-utils dosfstools ntfs-3g bash-completion --noconfirm --needed #Install base packages } ### Date and language ### @@ -362,11 +385,11 @@ echo "LANG=$opclang" > /mnt/etc/locale.conf echo "LANGUAGE=$opclang" >> /mnt/etc/locale.conf echo "LC_COLLATE=$opclang" >> /mnt/etc/locale.conf echo "KEYMAP=$langabr" > /mnt/etc/vconsole.conf -inchroot locale-gen +execl chroot locale-gen clear echo "$(T "Now select your timezone for adjusting the clock")" while [[ $NEW_TIMEZONE == "" ]];do -NEW_TIMEZONE=$(inchroot tzselect) +NEW_TIMEZONE=$(execl chroot tzselect) opt=`dialog --stdout --nocancel --menu "$(T "Your timezone:") $NEW_TIMEZONE" 0 0 4 1 "$(T "It's right")" 2 "$(T "No,edit")"` case $opt in 2) NEW_TIMEZONE="";; @@ -374,13 +397,13 @@ esac done test -n "$NEW_TIMEZONE" && cp -fp /mnt/usr/share/zoneinfo/"$NEW_TIMEZONE" /mnt/etc/localtime -inchroot hwclock --systohc --utc -inchroot pacman -S ntp --noconfirm -inchroot systemctl enable ntpd +execl chroot hwclock --systohc --utc +execl chroot pacman -S ntp --noconfirm +execl chroot systemctl enable ntpd if [[ $isoffline = 0 ]];then #Only sync if its online echo "$(T "Syncing hour to internet")"; -inchroot ntpd -qg -inchroot hwclock -w +execl chroot ntpd -qg +execl chroot hwclock -w else echo "Clock will not be okay until restart and configure manually because you dont have net" fi @@ -397,7 +420,7 @@ fi clear #Aqui hay que añadir los comandos para crear un usuario, aunque esto correrá dentro del chroot y no aqui nameuser=`dialog --stdout --inputbox "Ahora crearemos tu usuario \nNombre para tu usuario:" 10 50` -inchroot useradd -m -G wheel -s /bin/bash $nameuser +execl chroot useradd -m -G wheel -s /bin/bash $nameuser until [[ $pass1 = $pass2 && $pass1 != "" ]] do pass1=`dialog --stdout --insecure --passwordbox "$(T "Password for ") $nameuser" 9 50` @@ -406,13 +429,13 @@ do mostrardialog "$(T "Password")" "$(T "Passwords do not match")" fi done -echo "${nameuser}:${pass1}" | inchroot chpasswd +echo "${nameuser}:${pass1}" | execl chroot chpasswd pass1="" #Reiniciar pass1, por si hace falta de nuevo que el until funcione #See if user wants to edit root password or not. opt=`dialog --stdout --nocancel --menu "$(T "You want to edit root (admin) password or set same as user?")" 0 0 4 1 "$(T "Same as user")" 2 "$(T "Edit")"` case $opt in - 1) echo "root:${pass2}" | inchroot chpasswd;; + 1) echo "root:${pass2}" | execl chroot chpasswd;; 2) until [[ $pass1 = $pass2 && $pass1 != "" ]] do pass1=`dialog --stdout --insecure --passwordbox "$(T "Password for ") . root" 9 50` @@ -421,7 +444,7 @@ case $opt in mostrardialog "$(T "Password")" "$(T "Passwords do not match")" fi done - echo "root:${pass1}" | inchroot chpasswd + echo "root:${pass1}" | execl chroot chpasswd pass1="" #Reiniciar pass1, por si hace falta de nuevo que el until funcione ;; esac @@ -430,7 +453,7 @@ esac sed -i "s/\# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" /mnt/etc/sudoers #Modificar gksu si lleva una sesion grafica if [[ $optentorno != "6" ]];then - inchroot gconftool-2 --set /apps/gksu/sudo-mode --type=bool true --owner=$(echo $nameuser) + execl chroot gconftool-2 --set /apps/gksu/sudo-mode --type=bool true --owner=$(echo $nameuser) fi } @@ -438,16 +461,16 @@ function graficos { optgrafica=`dialog --stdout --nocancel --scrollbar --menu "$(T "What is your graphics card brand?")" 0 0 6 1 "Nvidia" 2 "AMD/ATI" 3 "Intel" 4 "VIA" 5 "Estoy usando VirtualBox" 6 "Estoy usando VMWare" 7 "No se la marca/Otra (Se instalaran todos los drivers graficos estandar)"` case $optgrafica in - 1) inchroot pacman -S xf86-video-nouveau xf86-video-nv libva-vdpau-driver mesa-vdpau --noconfirm;; - 2) inchroot pacman -S xf86-video-ati xf86-video-amdgpu libva-mesa-driver libva-vdpau-driver mesa-vdpau --noconfirm;; - 3) inchroot pacman -S xf86-video-intel libva-intel-driver libvdpau-va-gl --noconfirm;; - 4) inchroot pacman -S xf86-video-openchrome --noconfirm;; - 5) inchroot pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --noconfirm;; - 6) inchroot pacman -S xf86-video-vmware xf86-input-vmmouse open-vm-tools --noconfirm;; - 7) inchroot pacman -S $(inchroot pacman -Ssq xf86-video-*) --noconfirm;; + 1) execl chroot pacman -S xf86-video-nouveau xf86-video-nv libva-vdpau-driver mesa-vdpau --noconfirm;; + 2) execl chroot pacman -S xf86-video-ati xf86-video-amdgpu libva-mesa-driver libva-vdpau-driver mesa-vdpau --noconfirm;; + 3) execl chroot pacman -S xf86-video-intel libva-intel-driver libvdpau-va-gl --noconfirm;; + 4) execl chroot pacman -S xf86-video-openchrome --noconfirm;; + 5) execl chroot pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --noconfirm;; + 6) execl chroot pacman -S xf86-video-vmware xf86-input-vmmouse open-vm-tools --noconfirm;; + 7) execl chroot pacman -S $(execl chroot pacman -Ssq xf86-video-*) --noconfirm;; esac #Instalar siempre la estandar, por se acaso -inchroot pacman -S xf86-video-vesa mesa-libgl --noconfirm +execl chroot pacman -S xf86-video-vesa mesa-libgl --noconfirm } function programasguiuser { @@ -561,10 +584,10 @@ if [[ $nooptprogs != "1" ]];then *9*) packages="$packages poedit";;& *A*) packages="$packages arduino";;& esac - inchroot pacman -S $packages --noconfirm --needed + execl chroot pacman -S $packages --noconfirm --needed if [[ $inswine = 1 ]];then echo "$(T "Configuring wine for better experience") (32 bit winearch)" - inchroot su $nameuser -c "WINEARCH=win32 wineboot -u" + execl chroot su $nameuser -c "WINEARCH=win32 wineboot -u" fi packages="" fi @@ -574,19 +597,19 @@ fi function baseconX { tput setaf 2 ;echo "$(T "Installing desktop and basic programs, please wait")" ; tput setaf 9 sleep 2 -inchroot pacman -S xorg-server xorg-xinit xorg-server-common xf86-input-libinput xterm lightdm lightdm-gtk-greeter gvfs gvfs-mtp gvfs-smb udisks networkmanager network-manager-applet gnome-keyring xdialog --noconfirm -inchroot pacman -S lxterminal ttf-inconsolata octopi octopi-notifier gksu --noconfirm # Basic JKArch programs +execl chroot pacman -S xorg-server xorg-xinit xorg-server-common xf86-input-libinput xterm lightdm lightdm-gtk-greeter gvfs gvfs-mtp gvfs-smb udisks networkmanager network-manager-applet gnome-keyring xdialog --noconfirm +execl chroot pacman -S lxterminal ttf-inconsolata octopi octopi-notifier gksu --noconfirm # Basic JKArch programs #Instalar pulseaudio si tiene entorno grafico, sino es tonteria -inchroot pacman -S pulseaudio pavucontrol --noconfirm -inchroot pacman -S xdg-user-dirs --noconfirm -inchroot xdg-user-dirs-update +execl chroot pacman -S pulseaudio pavucontrol --noconfirm +execl chroot pacman -S xdg-user-dirs --noconfirm +execl chroot xdg-user-dirs-update #Gestor de energia -inchroot pacman -S xfce4-power-manager --noconfirm +execl chroot pacman -S xfce4-power-manager --noconfirm #Habilitamos ciertos servicios -inchroot systemctl enable lightdm -inchroot systemctl enable NetworkManager +execl chroot systemctl enable lightdm +execl chroot systemctl enable NetworkManager #Parte visual -inchroot pacman -S jkarch-appearance --noconfirm +execl chroot pacman -S jkarch-appearance --noconfirm clear } @@ -610,8 +633,8 @@ optentorno=`dialog --stdout --nocancel --menu "$(T "Select your desktop envirome case $optentorno in 1) baseconX - inchroot pacman -S lxappearance lxappearance-obconf lxde-common lxinput lxpanel lxrandr lxsession lxtask lxterminal openbox pcmanfm xfce4-notifyd --noconfirm - inchroot pacman -S gtk-engine-aurora faenza-icon-theme --noconfirm + execl chroot pacman -S lxappearance lxappearance-obconf lxde-common lxinput lxpanel lxrandr lxsession lxtask lxterminal openbox pcmanfm xfce4-notifyd --noconfirm + execl chroot pacman -S gtk-engine-aurora faenza-icon-theme --noconfirm if [[ $isoffline = 1 ]];then # Is an offline installation? tar xJf mods/LXDE.tar.xz -C /mnt/ else #online @@ -620,8 +643,8 @@ case $optentorno in ;; 2) baseconX - inchroot pacman -S xfce4 --noconfirm - inchroot pacman -S faenza-icon-theme --noconfirm + execl chroot pacman -S xfce4 --noconfirm + execl chroot pacman -S faenza-icon-theme --noconfirm if [[ $isoffline = 1 ]];then # Is an offline installation? tar xJf mods/XFCE4.tar.xz -C /mnt/ else #online @@ -630,29 +653,29 @@ case $optentorno in ;; 3) baseconX - inchroot pacman -S cinnamon --noconfirm + execl chroot pacman -S cinnamon --noconfirm ;; 4) optgnome=`dialog --stdout --nocancel --menu "¿Gnome base o gnome con sus extras?" 0 0 5 1 "Gnome base" 2 "Gnome+extras"` baseconX case $optgnome in - 1) inchroot pacman -S gnome --noconfirm;; - 2) inchroot pacman -S gnome gnome-extra --noconfirm;; + 1) execl chroot pacman -S gnome --noconfirm;; + 2) execl chroot pacman -S gnome gnome-extra --noconfirm;; esac - inchroot pacman -R gdm --noconfirm + execl chroot pacman -R gdm --noconfirm ;; 5) optmate=`dialog --stdout --nocancel --menu "¿MATE base o MATE con sus extras?" 0 0 5 1 "MATE base" 2 "MATE+extras"` baseconX case $optmate in - 1) inchroot pacman -S mate --noconfirm;; - 2) inchroot pacman -S mate mate-extra --noconfirm;; + 1) execl chroot pacman -S mate --noconfirm;; + 2) execl chroot pacman -S mate mate-extra --noconfirm;; esac ;; 6) baseconX - inchroot pacman -S plasma --noconfirm - inchroot pacman -R plasma-mediacenter ksshaskpass --noconfirm + execl chroot pacman -S plasma --noconfirm + execl chroot pacman -R plasma-mediacenter ksshaskpass --noconfirm ;; esac @@ -694,7 +717,7 @@ do #Cambiar el layout del teclado por el nuevo keyboardlayout ;; - 3) inchroot pacman -S yaourt base-devel --noconfirm --needed;; + 3) execl chroot pacman -S yaourt base-devel --noconfirm --needed;; esac fi done @@ -707,13 +730,13 @@ if [[ -z $partefi ]];then optboot=`dialog --stdout --nocancel --menu "¿Instalar bootloader/gestor de arranque?" 0 0 4 1 "Si (GRUB)" 2 "No, no instalar gestor de arranque"` case $optboot in 1) - inchroot pacman -S grub os-prober --noconfirm + execl chroot pacman -S grub os-prober --noconfirm #Arranque silencioso sed -i 's/\GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3 vga=current"/g' /mnt/etc/default/grub echo "Instalando GRUB para BIOS/MBR" #Se usa la variable ${hd} que se escogió al principio - inchroot grub-install --target=i386-pc /dev/${hd} - inchroot grub-mkconfig -o /boot/grub/grub.cfg + execl chroot grub-install --target=i386-pc /dev/${hd} + execl chroot grub-mkconfig -o /boot/grub/grub.cfg ;; 2) #No hará nada @@ -726,8 +749,8 @@ else case $optboot in 1) echo "Instalando rEFInd para UEFI" - inchroot pacman -S efibootmgr dosfstools refind-efi --noconfirm - inchroot refind-install + execl chroot pacman -S efibootmgr dosfstools refind-efi --noconfirm + execl chroot refind-install rootuuid=$(blkid -o value -s UUID /dev/$(echo $particionraiz)) echo '"Boot with standard options" "root=UUID='$(echo $rootuuid)' rw add_efi_memmap quiet loglevel=3 vga=current"' > /mnt/boot/refind_linux.conf echo "Boot in nomodeset mode" "root=UUID='$(echo $rootuuid)' rw add_efi_memmap quiet loglevel=3 vga=current nomodeset" >> /mnt/boot/refind_linux.conf @@ -736,10 +759,10 @@ else ;; 2) echo "Instalando GRUB en modo UEFI, puede fallar" - inchroot pacman -S grub os-prober efibootmgr dosfstools --noconfirm + execl chroot pacman -S grub os-prober efibootmgr dosfstools --noconfirm sed -i 's/\GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3 vga=current"/g' /mnt/etc/default/grub - inchroot grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub_uefi --recheck - inchroot grub-mkconfig -o /boot/grub/grub.cfg + execl chroot grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub_uefi --recheck + execl chroot grub-mkconfig -o /boot/grub/grub.cfg mostrardialog "GRUB" "GRUB fue instalado. Si no funciona, verificar en la bios que este seleccionado grub_uefi o grub como arranque, y no Windows u otro" ;; 3) @@ -827,14 +850,14 @@ echo "JKArch" > /mnt/etc/hostname #Configuraciones varias, en entorno se instala el entorno y programas del usuario entorno -inchroot mkinitcpio -p linux #Hacemos el mkinitcpio después de tener instalados los gráficos +execl chroot mkinitcpio -p linux #Hacemos el mkinitcpio después de tener instalados los gráficos #Ahora, se crea el usuario y se añaden los ficheros de configuracion de skel userpass bootinstall otrasconfig echo "$(T "Last tweaks and cleaning")" -inchroot systemctl enable dhcpcd -inchroot pacman -Sc --noconfirm +execl chroot systemctl enable dhcpcd +execl chroot pacman -Sc --noconfirm echo "Sincronizando datos al disco duro, puede tardar unos segundos" sync @@ -845,4 +868,5 @@ fi clear mostrardialog "$(T "End")" "$(T "Setup finished, press enter to reboot.")" +mv /tmp/install.log /mnt/home/$nameuser/install.log reboot