mirror of
https://gitlab.com/JKANetwork/JKArch.git
synced 2026-02-15 09:41:31 +01:00
212 lines
7.1 KiB
Bash
Executable File
212 lines
7.1 KiB
Bash
Executable File
#!/bin/bash
|
|
sclang=$1
|
|
source translations.sh
|
|
#Try to disable ctrl+C
|
|
trap '' INT
|
|
|
|
function pause {
|
|
echo "Pulse enter para continuar..."
|
|
read
|
|
}
|
|
|
|
function mostrardialog {
|
|
local titled
|
|
local msgd
|
|
titled=$1
|
|
msgd=$2
|
|
dialog --title "$titled" --msgbox "$msgd" 15 60
|
|
}
|
|
|
|
function fatalerror {
|
|
razon=$1
|
|
mostrardialog "Error fatal" "Ha occurrido un error fatal, la instalacion se va a detener \n Razon: $razon"
|
|
exit
|
|
}
|
|
|
|
function particiones {
|
|
clear
|
|
mostrardialog "Preguntas acerca de las unidades donde instalar el sistema" "Esta parte es la mas importante, antes de seguir se mostrarán los discos duros. Si esta vacío o es nuevo, recomendamos formatear en DOS/MBR. Si sabe lo que hace, o ya usaba GPT/UEFI, tendrá que seleccionar la partición EFI, recuerdelo \n (Si lo instala junto a windows 8.1/10 de 64 bits con UEFI activado, entonces usa EFI y tendrás que seleccionar la unidad EFI que utiliza luego)"
|
|
clear
|
|
if [[ ! $(lsblk --output KNAME | cut -c1-3 | sort | uniq | sed '1d' | grep 'sd\|hd') ]];then
|
|
mostrardialog "ERROR" "ERROR: No tienes discos duros, no se puede continuar. Por favor enchufe/inserte un disco duro y reinicie. \n Al pulsar aceptar se reiniciara el sistema"
|
|
reboot
|
|
fi
|
|
optpa=`dialog --stdout --nocancel --menu "¿Quieres editar las particiones?¿De modo gráfico, o por la terminal?" 0 0 5 1 "Grafico con Gparted (Recomendado)" 2 "Terminal (Pequeño asistente o por tu cuenta)" 3 "Borrar todo un disco duro e instalar JKArch en el" 4 "No editar nada"`
|
|
case $optpa in
|
|
1)
|
|
#Abrir gparted grafico
|
|
mostrardialog "Gparted" "Se abrira Gparted. Con el puedes editar, borrar,añadir y poner a tu gusto graficamente las particiones. \n Recuerda que al menos debe haber una particion ext4 primaria para el sistema. \n (Nota: No monte ninguna particion)"
|
|
startx;;
|
|
2)
|
|
#Terminal
|
|
echo "Seleccione el disco duro para editar"
|
|
echo "AVISO, GPT/UEFI ES EXPERMIENTAL, FALTA PROBARLO MAS, PUEDES QUEDARTE SIN ARRANQUE"
|
|
lsblk --output NAME,KNAME,FSTYPE,SIZE,LABEL
|
|
options=($(lsblk --output KNAME | cut -c1-3 | sort | uniq | sed '1d' | grep 'sd\|hd') "No editar" "Terminal")
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
"Terminal")
|
|
echo "Haga los cambios pertinentes, asegurese, y escriba exit continuar la instalación"
|
|
bash;;
|
|
"No edit") break;;
|
|
*) cfdisk /dev/$opt;break;;
|
|
esac
|
|
done
|
|
;;
|
|
3)
|
|
mostrardialog "Espera majo" "Esta opcion aun esta en construccion";;
|
|
esac
|
|
clear
|
|
tput setaf 6 ; echo "Este es tu esquema de particiones actual: " ; tput setaf 9
|
|
lsblk --output NAME,KNAME,FSTYPE,SIZE,LABEL
|
|
tput setaf 6 ; echo "Elige la particion a usar como sistema raíz ('/')" ; tput setaf 9
|
|
options=($(lsblk --output KNAME | sed '1d' | grep 'sd\|hd' | grep '[1-9]$'))
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
*) particionraiz=$opt;break;;
|
|
esac
|
|
done
|
|
optfr=`dialog --stdout --nocancel --menu "Formato para la particion raiz(/)" 0 0 4 1 "EXT4 (Recomendado)" 2 "BTRFS" 3 "No formatear (Si ya esta formateada)"`
|
|
case $optfr in
|
|
1)
|
|
formatoraiz="mkfs.ext4 -F";;
|
|
2)
|
|
formatoraiz="mkfs.btrfs -f";;
|
|
3)
|
|
formatohome="echo No formatear ";;
|
|
esac
|
|
|
|
clear
|
|
|
|
opthpart=`dialog --stdout --nocancel --menu "¿Quieres separar la particion /home de /?" 0 0 4 1 "No (Por defecto)" 2 "Si (Tendras que elegir la particion)"`
|
|
case $opthpart in
|
|
2)
|
|
#Selección de home
|
|
lsblk --output NAME,KNAME,FSTYPE,SIZE,LABEL
|
|
tput setaf 6 ; echo "Elige la particion a usar como home ('/home')" ; tput setaf 9
|
|
options=($(lsblk --output KNAME | sed '1d' | grep 'sd\|hd' | grep '[1-9]$'))
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
*) particionhome=$opt;break;;
|
|
esac
|
|
done
|
|
|
|
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 ";;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
clear
|
|
|
|
opt=`dialog --stdout --nocancel --menu "¿Usaste EFI/UEFI/GPT o es MBR/BIOS?" 0 0 5 1 "MBR/BIOS" 2 "EFI/UEFI/GPT"`
|
|
case $opt in
|
|
2)
|
|
clear
|
|
lsblk --output NAME,KNAME,FSTYPE,SIZE,LABEL
|
|
tput setaf 6 ; echo "Elige la particion EFI del sistema (Si usa windows, suele ser una particion de 300-400Mb en FAT32 llamada EFI, y suele estar en /dev/sda2)" ; tput setaf 9
|
|
options=($(lsblk --output KNAME | sed '1d'| grep 'sd\|hd'))
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
*) partefi=$opt;break;;
|
|
esac
|
|
done
|
|
;;
|
|
esac
|
|
|
|
}
|
|
|
|
function install {
|
|
clear
|
|
tput setaf 2 ; echo "Instalando el sistema, esto puede tardar unos 10 minutos, espere hasta el siguiente aviso" ; tput setaf 9
|
|
sleep 2
|
|
$formatoraiz /dev/$particionraiz
|
|
mount /dev/$particionraiz /mnt/
|
|
if [[ $particionhome ]];then
|
|
$formatohome /dev/$particionhome
|
|
mkdir -p /mnt/home/
|
|
mount /dev/$particionhome /mnt/home/
|
|
fi
|
|
if [[ $partefi ]];then
|
|
mkdir -p /mnt/boot/efi
|
|
mount /dev/$partefi /mnt/boot/efi/
|
|
fi
|
|
|
|
wget https://gitlab.com/JKANetwork/JKArch/raw/master/archinstall/pacman.conf -O /tmp/pacman.conf
|
|
if [[ $? != 0 ]];then
|
|
fatalerror "Error de conexion con internet, compruebe la red"
|
|
fi
|
|
pacstrap -C /tmp/pacman.conf /mnt/ base btrfs-progs
|
|
mkdir -p /mnt/root/inst/
|
|
wget https://gitlab.com/JKANetwork/JKArch/raw/master/archinstall/chrootinstall.sh -O /mnt/root/inst/chrootinstall.sh
|
|
if [[ $? != 0 ]];then
|
|
fatalerror "Error de conexion con internet, compruebe la red"
|
|
fi
|
|
chmod +x /mnt/root/inst/chrootinstall.sh
|
|
genfstab -U /mnt >> /mnt/etc/fstab
|
|
cp /etc/netctl/* /mnt/etc/netctl/
|
|
mv /tmp/pacman.conf /mnt/etc/pacman.conf
|
|
argpart=$(echo $particionraiz | cut -c1-3)
|
|
arch-chroot /mnt /bin/bash -c "./root/inst/chrootinstall.sh $argpart $partefi"
|
|
}
|
|
clear
|
|
mostrardialog "$(T "Arch install script (BETA)")" "$(T "Intro arch install script")"
|
|
mostrardialog "JKArch" "El script esta en estado beta y se esta actualizando casi constantemente. Puede haber fallos importantes. En caso de fallo, vuelva a probar en unas horas"
|
|
echo "Desmontando posibles particiones"
|
|
umount /mnt/*
|
|
umount /mnt/
|
|
particiones
|
|
|
|
clear
|
|
tput setaf 6
|
|
echo "Ok, vamos a comenzar la instalacion, pero antes, un resumen de donde lo va a instalar."
|
|
echo "Tu esquema de particiones antes de los cambios que has decidido"
|
|
tput setaf 9
|
|
lsblk --output NAME,KNAME,FSTYPE,SIZE,LABEL
|
|
tput setaf 6
|
|
echo "Cambios que has realizado"
|
|
tput setaf 9
|
|
case $formatoraiz in
|
|
"mkfs.ext4 -F")
|
|
mosfraiz="formateado en ext4";;
|
|
"mkfs.btrfs -f")
|
|
mosfraiz="formateado en btrfs";;
|
|
"echo No formatear ")
|
|
mosfraiz="sin formatear";;
|
|
esac
|
|
echo "Partición raiz (/): $particionraiz , $mosfraiz"
|
|
if [[ $particionhome ]];then
|
|
case $formatohome in
|
|
"mkfs.ext4 -F")
|
|
mosfhome="formateado en ext4";;
|
|
"mkfs.btrfs -f")
|
|
mosfhome="formateado en btrfs";;
|
|
"mkfs.xfs -f")
|
|
mosfhome="formateado en XFS";;
|
|
"echo No formatear ")
|
|
mosfhome="sin formatear";;
|
|
esac
|
|
echo "Partición home (/home): $particionhome , $mosfhome"
|
|
fi
|
|
if [[ $partefi ]];then
|
|
echo "Tienes una partición EFI en: $partefi"
|
|
fi
|
|
tput setaf 1 ; echo "Si estas de acuerdo, presione enter, en caso contrario, apague el ordenador a la fuerza y no comenzará la instalación" ; tput setaf 9
|
|
pause
|
|
install
|
|
clear
|
|
mostrardialog "Fin" "Instalación finalizada, al pulsar aceptar, se reiniciará el sistema"
|
|
reboot
|