1
0
mirror of https://gitlab.com/JKANetwork/JKArch.git synced 2026-02-17 10:41:32 +01:00

New installer

This commit is contained in:
2017-01-16 16:55:47 +01:00
parent 6390f533dc
commit 3ba9b67dda

View File

@@ -29,25 +29,33 @@ msgd=$2
dialog --title "$titled" --msgbox "$msgd" 15 60
}
function yesnobox {
local title=$1
#Return Y or N
echo `dialog --stdout --nocancel --menu "$title" 0 0 4 Y "$(T "Yes")" N "No"`
}
function fatalerror {
razon=$1
mostrardialog "Error" "$(T "An error has ocurred, setup will be stopped") $razon"
mostrardialog "Log" "$(T "You have a install log in") /tmp/install.log"
exit
}
function isanetworkerror {
if [[ $? != 0 ]];then
fatalerror "$(T "Network connection error, please check it")"
fi
}
function pacmanerror {
if [[ $? != 0 ]];then
fatalerror "$(T "Pacman error, problems in repositories, apologizes. You have to try later...")"
fi
}
function execl { ##This function logs and execute commands
##This function logs and execute commands
function execl {
local command
echo "------" >> "/tmp/install.log"
if [[ $1 != "chroot" && $1 != "chuser" ]];then #If it runs normally
@@ -81,7 +89,7 @@ echo "Error: Code $?" >> "/tmp/install.log"
fi
}
##Function for show to the user if an option is on or off
function optstate {
if [[ $1 =~ "$2" ]];then
echo "on"
@@ -90,7 +98,9 @@ else
fi
}
# End of functions that are user interactive for configuring system
##Function to select by the user the partitions for the system install
function particiones {
clear
mostrardialog "$(T "Questions about partitions where system will be installed")" "$(T "Questions about partitions dialog. Text")"
@@ -238,14 +248,10 @@ if [[ ! $optpa -eq 3 ]];then
if [[ $particionhome ]];then
optfh=`dialog --stdout --nocancel --menu "Formato para la particion home (/home)" 0 0 4 1 "EXT4 (Recomendado)" 2 "BTRFS" 3 "XFS" 4 "No formatear (Si ya esta formateada)"`
case $optfh in
1)
formatohome="mkfs.ext4 -F";;
2)
formatohome="mkfs.btrfs -f";;
3)
formatohome="mkfs.xfs -f";;
4)
formatohome="echo No formatear ";;
1) formatohome="mkfs.ext4 -F";;
2) formatohome="mkfs.btrfs -f";;
3) formatohome="mkfs.xfs -f";;
4) formatohome="echo No formatear ";;
esac
fi
;;
@@ -258,6 +264,7 @@ if [[ ! $optpa -eq 3 ]];then
optswap=`dialog --stdout --nocancel --menu "¿Quieres crear un archivo swap (Memoria virtual)?" 0 0 4 1 "Si (Con valores por defecto, recomendado)" 2 "Si (Valores a mano)" 3 "Si, pero con una particion que ya cree" 4 "No"`
case $optswap in
1)
# This count the ammount of swap to create dependent of computer RAM
if [[ $ram -le 7500 ]];then
swaptype=1
swapamount=$(expr $ram / 3)
@@ -284,97 +291,28 @@ if [[ ! $optpa -eq 3 ]];then
if [[ $tabletype = "gpt" ]];then
lsblk --output NAME,KNAME,FSTYPE,SIZE,LABEL
tput setaf 6 ; echo "$(T "Select EFI partition")" ; tput setaf 9
options=($(lsblk --output KNAME | sed '1d' | grep 'sd\|hd' | grep '[1-9]$'))
select opt in "${options[@]}"
# Seleccion de particion EFI
variable=$(lsblk --output KNAME /dev/${hd} | cut -c1-4 | tail -n +3)
i=3
varx=""
for addr in $(echo $variable | tr " " "\n")
do
case $opt in
*)
if [[ -z $opt ]];then
echo "$(T "Not valid")"
else
partefi=$opt
break
fi;;
esac
varx+=" $addr '$(lsblk --output KNAME,FSTYPE,SIZE,LABEL /dev/${hd} | tail -n +$i | head -1)'"
i=$((i+1))
done
varf="dialog --stdout --nocancel --menu \"$(T 'Select EFI partition')\" 0 0 5 $varx"
partefi=`bash -c "$varf"`
fi
fi
#fin del if de pedir los datos si no esta en automatico
}
### Base install of the system ###
function baseinstall {
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
execl $formatoraiz /dev/$particionraiz
e2label /dev/$particionraiz "JKArch"
execl mount /dev/$particionraiz /mnt/
if [[ $particionhome ]];then
execl $formatohome /dev/$particionhome
mkdir -p /mnt/home/
execl mount /dev/$particionhome /mnt/home/
fi
if [[ $partefi ]];then
mkdir -p /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
execl reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist
tput setaf 2 ; echo "$(T "Downloading")" ; tput setaf 9
execl pacman -Sy archlinux-keyring --noconfirm #Keyring update before download
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
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
#Create fstab
genfstab -U /mnt > /mnt/etc/fstab
#Create or activate swap if neccesary
if [[ $swaptype ]];then
case $swaptype in
1)
echo "$(T "Creating swap file")"
dd if=/dev/zero of=/mnt/swapfile bs=1M count=$swapamount
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
echo "/swapfile none swap defaults 0 0" >> /mnt/etc/fstab
;;
esac
fi
if [[ $isoffline = 0 ]];then
cp -r /etc/netctl/* /mnt/etc/netctl/
cp -f /etc/resolv.conf /mnt/etc/resolv.conf
fi
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /run /mnt/run
if [[ $isoffline = 1 ]];then
mount --bind /run/archiso/bootmnt/ /mnt/run/archiso/bootmnt/ # CD bind
fi
execl chroot pacman -Syu jka-toolkit git wget netctl iw wpa_supplicant reflector dialog sudo alsa-utils dosfstools ntfs-3g bash-completion --noconfirm --needed #Install base packages , reflector is for updating mirrorlist
}
### Date and language ###
## Date and language
function horaidioma {
while [[ $opclang == "" ]];do
while [[ $confirm != "Y" ]];do
varx="" #Empty var
langs=$(cat /mnt/etc/locale.gen | grep '^#[a-zA-Z]' | cut -f1 -d" " | cut -c2-30 | sort | uniq)
langs=$(cat /etc/locale.gen | grep '^#[a-zA-Z]' | cut -f1 -d" " | cut -c2-30 | sort | uniq)
for addr in $(echo $langs | tr " " "\n")
do
varx+=" $addr $addr"
@@ -384,55 +322,27 @@ opclang=`bash -c "$varf"`
varx="" #Empty varx
langabr=$(echo $opclang | cut -f1 -d"_")
langinst=$(cat /mnt/etc/locale.gen | grep -m1 '^#'$opclang | cut -c2-40)
opt=`dialog --stdout --nocancel --menu "$(T "Your language:") $opclang" 0 0 4 1 "$(T "It's right")" 2 "$(T "No,edit")"`
case $opt in
2) opclang="";;
esac
langinst=$(cat /etc/locale.gen | grep -m1 '^#'$opclang | cut -c2-40)
#Confirm
confirm=`yesnobox "$(T "Your language:") $opclang. Correcto?"`
done #End of selecting lang
confirm="" #Erase var
sed -i "s/\#$langinst/$langinst/g" /mnt/etc/locale.gen
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
execl chroot locale-gen
clear
echo "$(T "Now select your timezone for adjusting the clock")"
while [[ $NEW_TIMEZONE == "" ]];do
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="";;
esac
while [[ $confirm != "Y" ]];do
NEW_TIMEZONE=$(execl tzselect)
confirm=`yesnobox "$(T "Your timezone is") $NEW_TIMEZONE ?"`
done
test -n "$NEW_TIMEZONE" && cp -fp /mnt/usr/share/zoneinfo/"$NEW_TIMEZONE" /mnt/etc/localtime
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")";
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
confirm="" #Erase var
}
##Function for make user select their user
function userpass {
if [[ $isoffline = 1 ]];then # Is an offline installation?
tar xJf mods/skel.tar.xz -C /mnt/
else #online
wget -nv https://gitlab.com/JKANetwork/JKArch/raw/master/mods/skel.tar.xz -O- | tar xJf - -C /mnt/
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`
execl chroot useradd -m -G wheel -s /bin/bash $nameuser
nameuser=`dialog --stdout --inputbox "Nombre para tu usuario principal:" 10 50`
until [[ $pass1 = $pass2 && $pass1 != "" ]]
do
pass1=`dialog --stdout --insecure --passwordbox "$(T "Password for ") $nameuser" 9 50`
@@ -441,19 +351,14 @@ do
mostrardialog "$(T "Password")" "$(T "Passwords do not match")"
fi
done
echo "${nameuser}:${pass1}" | execl chroot chpasswd
passuser=${pass1}
pass1="" #Reiniciar pass1, por si hace falta de nuevo que el until funcione
#For some strange login bugs
echo "Cambio de permisos por si se quedaron mal en algún momento"
execl chroot chmod 755 /
execl chroot chmod 755 /bin
#
#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}" | execl chroot chpasswd;;
1) passroot=${pass2};;
2) until [[ $pass1 = $pass2 && $pass1 != "" ]]
do
pass1=`dialog --stdout --insecure --passwordbox "$(T "Password for ") . root" 9 50`
@@ -462,35 +367,34 @@ case $opt in
mostrardialog "$(T "Password")" "$(T "Passwords do not match")"
fi
done
echo "root:${pass1}" | execl chroot chpasswd
passroot=${pass2}
pass1="" #Reiniciar pass1, por si hace falta de nuevo que el until funcione
;;
esac
#Añadir soporte sudo para este nuevo usuario
sed -i "s/\# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" /mnt/etc/sudoers
}
##User graphics select
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) execl chroot pacman -S xf86-video-nouveau 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;;
1) allpackages=$allpackages" xf86-video-nouveau libva-vdpau-driver mesa-vdpau";;
2) allpackages=$allpackages" xf86-video-ati xf86-video-amdgpu libva-mesa-driver libva-vdpau-driver mesa-vdpau";;
3) allpackages=$allpackages" xf86-video-intel libva-intel-driver libvdpau-va-gl";;
4) allpackages=$allpackages" xf86-video-openchrome";;
5) allpackages=$allpackages" virtualbox-guest-utils virtualbox-guest-modules-arch";;
6) allpackages=$allpackages" xf86-video-vmware xf86-input-vmmouse open-vm-tools";;
7) allpackages=$allpackages" "$(execl chroot pacman -Ssq xf86-video-*);;
esac
#Instalar siempre la estandar, por se acaso
execl chroot pacman -S xf86-video-vesa mesa-libgl --noconfirm
allpackages=$allpackages" xf86-video-vesa mesa-libgl"
}
##Interactive function for make user select programs
function programasguiuser {
clear
#Seleccion de programas predeterminados
# Default selected apps
opt1="1 6"
opt2="1 5"
opt3="1"
@@ -523,7 +427,7 @@ case $tipoinstall in
esac
done
;;
2) mostrardialog "Programas predeterminados" "Ahora se van a instalar los programas predeterminados, espere";;
2) mostrardialog "Programas predeterminados" "Se instalaran los programas predeterminados";;
3) mostrardialog "Ningun programa" "No se instalara ningun programa opcional."
nooptprogs="1" # Not install anything
;;
@@ -564,9 +468,6 @@ if [[ $nooptprogs != "1" ]];then
*1*) packages="$packages noto-fonts noto-fonts-cjk noto-fonts-emoji ttf-dejavu ttf-liberation";;&
*2*) packages="$packages ttf-ms-fonts";;&
*3*) packages="$packages ttf-google-fonts-git"
#Delete (Package per line) possible packages that conficts with ttf-google-fonts-git
execl chroot pacman -Rdd noto-fonts --noconfirm
execl chroot pacman -Rdd ttf-inconsolata --noconfirm #This is because ttf-google-fonts provides noto-fonts (But not noto-fonts-cjk neither noto-fonts-emoji
;;&
esac
case $opt6 in
@@ -609,100 +510,276 @@ if [[ $nooptprogs != "1" ]];then
*1*) packages="$packages base-devel";;&
*2*) packages="$packages jdk8-openjdk";;&
esac
execl chroot pacman -S $packages --noconfirm --needed
if [[ $inswine = 1 ]];then
echo "$(T "Configuring wine for better experience") (32 bit winearch)"
execl chuser WINEARCH=win32 wineboot -u
fi
allpackages=$allpackages" "$packages
packages=""
fi
}
### Install base graphic programs ###
function baseconX {
tput setaf 2 ;echo "$(T "Installing desktop and basic programs, please wait")" ; tput setaf 9
sleep 2
execl chroot pacman -S xorg-server xorg-xinit xorg-server-common xf86-input-libinput xterm lightdm lightdm-gtk-greeter gvfs gvfs-mtp gvfs-smb gvfs-afc udisks networkmanager network-manager-applet gnome-keyring xdialog --noconfirm
execl chroot pacman -S lxterminal ttf-inconsolata octopi octopi-notifier gksu pulseaudio pavucontrol xdg-user-dirs --noconfirm # Basic programs and audio support
#Instalar pulseaudio si tiene entorno grafico, sino es tonteria
execl chroot xdg-user-dirs-update
#Gestor de energia
execl chroot pacman -S xfce4-power-manager --noconfirm
#Habilitamos ciertos servicios
execl chroot systemctl enable lightdm
execl chroot systemctl enable NetworkManager
#Parte visual
execl chroot pacman -S jkarch-appearance --noconfirm
clear
}
### Simply put keyboard layout configs ###
function keyboardlayout {
echo "KEYMAP=$langabr" > /mnt/etc/vconsole.conf
echo "# Read and parsed by systemd-localed. It's probably wise not to edit this file" > /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo "# manually too freely." >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'Section "InputClass"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo ' Identifier "system-keyboard"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo ' MatchIsKeyboard "on"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo ' Option "XkbLayout" "'$langabr'"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'EndSection' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
}
### Install desktop enviroment and their style in some cases ###
##Function to select environment
function entorno {
clear
optentorno=`dialog --stdout --nocancel --menu "$(T "Select your desktop enviroment")" 0 0 5 1 "LXDE (Muy ligero)" 2 "XFCE (Ligero)" 3 "Cinnamon (Facil para antiguos usuarios de Windows)" 4 "Gnome (Complejo, pero practico)" 5 "MATE (Tradicional)" 6 "Plasma/KDE (Pesado aunque bonito) " 7 "No instalar entorno de escritorio"`
case $optentorno in
1)
baseconX
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
allpackages=$allpackages" lxappearance lxappearance-obconf lxde-common lxinput lxpanel lxrandr lxsession lxtask lxterminal openbox pcmanfm xfce4-notifyd gtk-engine-aurora faenza-icon-theme"
#Themes: gtk-engine-aurora faenza-icon-theme
;;
2) allpackages=$allpackages" xfce4 faenza-icon-theme";;
3) allpackages=$allpackages" cinnamon";;
4)
optgnome=`dialog --stdout --nocancel --menu "¿Gnome base o gnome con sus extras?" 0 0 5 1 "Gnome base" 2 "Gnome+extras"`
case $optgnome in
1) allpackages=$allpackages" gnome";;
2) allpackages=$allpackages" gnome gnome-extra";;
esac
#In installconf, it has to remove gdm
;;
5)
optmate=`dialog --stdout --nocancel --menu "¿MATE base o MATE con sus extras?" 0 0 5 1 "MATE base" 2 "MATE+extras"`
case $optmate in
1) allpackages=$allpackages" mate gtk-engine-murrine";;
2) allpackages=$allpackages" mate mate-extra gtk-engine-murrine";;
esac
;;
6)
allpackages=$allpackages" plasma"
#Remove plasma-mediacenter ksshaskpass after, in installconf
;;
esac
# Basic programs (Xorg) and audio support if there is selected any
if [[ $optentorno != 7 ]];then
#Gestor de energia xfce4-power-manager
allpackages=$allpackages" xorg-server xorg-xinit xorg-server-common xf86-input-libinput xterm lightdm lightdm-gtk-greeter gvfs gvfs-mtp gvfs-smb gvfs-afc udisks networkmanager network-manager-applet gnome-keyring xdialog lxterminal ttf-inconsolata octopi octopi-notifier gksu pulseaudio pavucontrol xdg-user-dirs jkarch-appearance xfce4-power-manager"
fi
}
# End of functions that are user interactive for configuring system
##Install and configure all of the system, this function is NOT interactive, it works alone
function installconf {
clear
tput setaf 2 ; echo "$(T "Installing system, this can take about 20 minutes, wait")" ; tput setaf 9
sleep 2
tput setaf 2 ; echo "$(T "Formatting and mounting partitions")" ; tput setaf 9
# Format and mount partitions
execl $formatoraiz /dev/$particionraiz
e2label /dev/$particionraiz "JKArch"
execl mount /dev/$particionraiz /mnt/
if [[ $particionhome ]];then
execl $formatohome /dev/$particionhome
mkdir -p /mnt/home/
execl mount /dev/$particionhome /mnt/home/
fi
if [[ $partefi ]];then
mkdir -p /mnt/boot/efi
execl mount /dev/$partefi /mnt/boot/efi/
fi
# Download or install base system.
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
execl reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist
tput setaf 2 ; echo "$(T "Downloading")" ; tput setaf 9
# Reflector and rsync is for updating mirrorlist #
execl pacman -Sy archlinux-keyring --noconfirm #Keyring for avoid fail sig of some packages
execl pacstrap -C pacman.conf /mnt/ base jkarch-mirrorlist reflector rsync dosfstools ntfs-3g btrfs-progs exfat-utils #Install base and disk format drivers
pacmanerror
mv pacman.conf /mnt/etc/pacman.conf
fi
if [[ $isoffline = "1" ]];then
tput setaf 2 ; echo "$(T "Installing packages")..." ; tput setaf 9
execl pacstrap -C pacman-offline.conf /mnt/ base btrfs-progs jkarch-mirrorlist rsync dosfstools ntfs-3g btrfs-progs exfat-utils #Install base and disk format drivers
mv pacman-offline.conf /mnt/etc/pacman.conf #Move pacman.conf (offline) to pacman chroot location
fi
# Create fstab
execl genfstab -U /mnt > /mnt/etc/fstab
# Create or activate swap if neccesary
if [[ $swaptype ]];then
case $swaptype in
1)
echo "$(T "Creating swap file")"
dd if=/dev/zero of=/mnt/swapfile bs=1M count=$swapamount
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
echo "/swapfile none swap defaults 0 0" >> /mnt/etc/fstab
;;
esac
fi
# Create bind mountpoints for the rest of the install (Chroot)
if [[ $isoffline = 0 ]];then
cp -r /etc/netctl/* /mnt/etc/netctl/
cp -f /etc/resolv.conf /mnt/etc/resolv.conf
fi
# CD bind if is offline
if [[ $isoffline = 1 ]];then
mount --bind /run/archiso/bootmnt/ /mnt/run/archiso/bootmnt/
fi
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /run /mnt/run
#
# Var allpackages have in this moment all the packages selected by user, and will be the install packages list for pacman #
# Do allpackages var contain base packages and NTP daemon (Hour sync)
allpackages=$allpackages" jka-toolkit git wget netctl iw wpa_supplicant dialog sudo alsa-utils bash-completion ntp"
# GUI and apps selected in "entorno{}"
# Before install, configure mirrorlist if its online
if [[ $isoffline = 0 ]];then
execl chroot reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist
fi
# Here, allpackages have the user selected packages because selected before. Then, install it
execl chroot pacman -Syu $allpackages --noconfirm --needed
# Language
sed -i "s/\#$langinst/$langinst/g" /mnt/etc/locale.gen
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
execl chroot locale-gen
clear
# Timezone
test -n "$NEW_TIMEZONE" && cp -fp /mnt/usr/share/zoneinfo/"$NEW_TIMEZONE" /mnt/etc/localtime
execl chroot hwclock --systohc --utc
execl chroot systemctl enable ntpd
if [[ $isoffline = 0 ]];then #Only sync if its online
echo "$(T "Syncing hour to internet")";
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
# User skel move
if [[ $isoffline = 1 ]];then # Is an offline installation?
tar xJf mods/skel.tar.xz -C /mnt/
else # Online
wget -nv https://gitlab.com/JKANetwork/JKArch/raw/master/mods/skel.tar.xz -O- | tar xJf - -C /mnt/
fi
# Themes skel before creating user and remove some progs
if [[ $optentorno = 1 ]];then #LXDE
if [[ $isoffline = 1 ]];then # Is an offline installation?
tar xJf mods/LXDE.tar.xz -C /mnt/
else #online
wget -nv https://gitlab.com/JKANetwork/JKArch/raw/master/mods/LXDE.tar.xz -O- | tar xJf - -C /mnt/
fi
;;
2)
baseconX
execl chroot pacman -S xfce4 --noconfirm
execl chroot pacman -S faenza-icon-theme --noconfirm
fi
if [[ $optentorno = 2 ]];then #XFCE4
if [[ $isoffline = 1 ]];then # Is an offline installation?
tar xJf mods/XFCE4.tar.xz -C /mnt/
else #online
wget -nv https://gitlab.com/JKANetwork/JKArch/raw/master/mods/XFCE4.tar.xz -O- | tar xJf - -C /mnt/
fi
;;
3)
baseconX
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) execl chroot pacman -S gnome --noconfirm;;
2) execl chroot pacman -S gnome gnome-extra --noconfirm;;
esac
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) execl chroot pacman -S mate gtk-engine-murrine --noconfirm;;
2) execl chroot pacman -S mate mate-extra gtk-engine-murrine --noconfirm;;
esac
;;
6)
baseconX
execl chroot pacman -S plasma --noconfirm
execl chroot pacman -R plasma-mediacenter ksshaskpass --noconfirm
;;
esac
fi
if [[ $optentorno = 4 ]];then #GDM remove in gnome
execl chroot pacman -R gdm --noconfirm
fi
if [[ $optentorno = 6 ]];then #Plasma, remove 2 apps
execl chroot pacman -R plasma-mediacenter ksshaskpass --noconfirm
fi
# Create user
execl chroot useradd -m -G wheel -s /bin/bash $nameuser
echo "${nameuser}:${passuser}" | execl chroot chpasswd
# Root password
echo "root:${passroot}" | execl chroot chpasswd
# Fix for some strange login bugs
execl chroot chmod 755 /
execl chroot chmod 755 /bin
# Add sudo support for wheel users like user added
sed -i "s/\# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" /mnt/etc/sudoers
# User directory (Photos, Desktop..) create
execl chroot xdg-user-dirs-update
# Turn on some services
execl chroot systemctl enable lightdm
execl chroot systemctl enable NetworkManager
execl chroot systemctl enable dhcpcd
# Configure wine if neccesary
if [[ $inswine = 1 ]];then
echo "$(T "Configuring wine for better experience") (32 bit winearch)"
execl chuser WINEARCH=win32 wineboot -u
fi
# Set X11 keyboard, and user GKSU, if there is any enviroment installed
if [[ $optentorno != 7 ]];then
keyboardlayout
# Modify gksu for ask user password and not root one
execl chuser gconftool-2 --set /apps/gksu/sudo-mode --type=bool true --owner=$(echo $nameuser)
fi
# Install and configure bootloader GRUB/rEFInd
if [[ -z $partefi ]];then #If it dont have EFI
case $optboot in
1)
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
execl chroot grub-install --target=i386-pc /dev/${hd}
execl chroot grub-mkconfig -o /boot/grub/grub.cfg
;;
esac
else #With EFI
case $optboot in
1)
echo "Instalando rEFInd para UEFI"
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
echo '"Boot to single-user mode" "root=UUID='$(echo $rootuuid)' rw add_efi_memmap quiet single"' >> /mnt/boot/refind_linux.conf
echo '"Boot with minimal options" "root=UUID='$(echo $rootuuid)' rw add_efi_memmap"' >> /mnt/boot/refind_linux.conf
;;
2)
echo "Instalando GRUB en modo UEFI, puede fallar"
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
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"
;;
esac
fi
# Hostname
echo "JKArch" > /mnt/etc/hostname
# Linux kernel
execl chroot mkinitcpio -p linux #Hacemos el mkinitcpio después de tener instalados los gráficos
# Clean pacman
echo "$(T "Cleaning")"
execl chroot pacman -Sc --noconfirm
} # Fin installconf
}
### More optional configs ###
function otrasconfig {
@@ -738,51 +815,35 @@ do
done
}
function bootinstall {
## Set X11 keyboard
function keyboardlayout {
echo "KEYMAP=$langabr" > /mnt/etc/vconsole.conf
echo "# Read and parsed by systemd-localed. It's probably wise not to edit this file" > /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo "# manually too freely." >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'Section "InputClass"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo ' Identifier "system-keyboard"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo ' MatchIsKeyboard "on"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo ' Option "XkbLayout" "'$langabr'"' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'EndSection' >> /mnt/etc/X11/xorg.conf.d/00-keyboard.conf
}
function bootselect {
if [[ -z $partefi ]];then
#Si no usa EFI, preguntar por instalar GRUB
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)
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
execl chroot grub-install --target=i386-pc /dev/${hd}
execl chroot grub-mkconfig -o /boot/grub/grub.cfg
;;
2)
#No hará nada
echo "$(T "No new bootloader installed")"
mostrardialog "Bootloader" "$(T "No new bootloader will be installed")"
;;
esac
else
#Si usa EFI, preguntar por instalar rEFInd
optboot=`dialog --stdout --nocancel --menu "¿Instalar bootloader/gestor de arranque?" 0 0 4 1 "Si (rEFInd) (Recomendado)" 2 "Si (GRUB) (Suele fallar)" 3 "No, no instalar gestor de arranque"`
case $optboot in
1)
echo "Instalando rEFInd para UEFI"
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
echo '"Boot to single-user mode" "root=UUID='$(echo $rootuuid)' rw add_efi_memmap quiet single"' >> /mnt/boot/refind_linux.conf
echo '"Boot with minimal options" "root=UUID='$(echo $rootuuid)' rw add_efi_memmap"' >> /mnt/boot/refind_linux.conf
;;
2)
echo "Instalando GRUB en modo UEFI, puede fallar"
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
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)
#No hará nada
echo "$(T "No new bootloader installed")"
mostrardialog "Bootloader" "$(T "No new bootloader will be installed")"
;;
esac
fi
@@ -801,7 +862,29 @@ echo "Desmontando posibles particiones"
umount /mnt/boot/efi/
umount /mnt/*
umount /mnt/
# Start questions, functions for timezone, enviroment, programs...
particiones
horaidioma
entorno
#Programas de usuario si hay entorno escogido
if [[ $optentorno != "7" ]];then
graficos
#Variable para poner el teclado bien en x11
hastosetxkb=1
#Aqui va la personalizacion de programas, ya que son graficos.
programasguiuser
fi
# Ask for user and password for the new system
userpass
#GRUB/rEFInd select
bootselect
clear
# Resumen de los cambios
@@ -840,6 +923,7 @@ fi
if [[ $partefi ]];then
echo "$(T "EFI partition in") $partefi"
fi
# Log options
echo "------" >> "/tmp/install.log"
echo "Install partition options" >> "/tmp/install.log"
@@ -855,9 +939,9 @@ if [[ $particionhome ]];then
echo "Home partition $particionhome not formatted" >> "/tmp/install.log"
fi
fi
#
#Pregunta si instalar o no
tput setaf 1
echo "¿Estas de acuerdo con los cambios y quieres comenzar la instalacion?"
@@ -878,40 +962,15 @@ do
done
tput setaf 9
#Instalación
# Real install
pause
baseinstall
horaidioma #Configure hour/timezone
echo "JKArch" > /mnt/etc/hostname
installconf
#Configuraciones varias, en entorno se instala el entorno
entorno
#Se crea el usuario despues del entorno pero antes de instalar más (para una correcta configuración) y se añaden los ficheros de configuracion de skel
userpass
#Programas de usuario si hay entorno escogido
if [[ $optentorno != "7" ]];then
graficos
#Poner el teclado bien en x11
keyboardlayout
#Aqui va la personalizacion de programas, ya que son graficos.
programasguiuser
#Modificar gksu para preguntar por contraseña del usuario
execl chuser gconftool-2 --set /apps/gksu/sudo-mode --type=bool true --owner=$(echo $nameuser)
fi
execl chroot mkinitcpio -p linux #Hacemos el mkinitcpio después de tener instalados los gráficos
bootinstall
#End install, other user configs (If it wants it)
otrasconfig
echo "$(T "Last tweaks and cleaning")"
execl chroot systemctl enable dhcpcd
execl chroot rm -rf /var/cache/pacman/pkg/* #Remove downloads (Freeing space)
# Unmount and tweak pacman if necessary (If offline)
if [[ $isoffline = 1 ]];then # Is an offline installation?
echo "Configurando pacman para usar servidores web en los siguientes arranques..."
mv pacman.conf /mnt/etc/pacman.conf #Put online pacman.conf
@@ -928,4 +987,5 @@ umount /mnt
clear
mostrardialog "$(T "End")" "$(T "Setup finished, press enter to reboot.")"
mv /tmp/install.log /mnt/home/$nameuser/install.log
# Reboot, finished
reboot