This repository has been archived by the owner on Mar 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchroot.sh
172 lines (147 loc) · 4.42 KB
/
chroot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env bash
# -*- ENCODING: UTF-8 -*-
##
## @author Raúl Caro Pastorino
## @copyright Copyright © 2018 Raúl Caro Pastorino
## @license https://wwww.gnu.org/licenses/gpl.txt
## @email dev@fryntiz.es
## @web https://fryntiz.es
## @gitlab https://gitlab.com/fryntiz
## @github https://github.com/fryntiz
## @twitter https://twitter.com/fryntiz
##
## Guía de estilos aplicada:
## @style https://gitlab.com/fryntiz/bash-guide-style
############################
## INSTRUCCIONES ##
############################
## Completa y Personaliza la instalación de Gentoo y usuarios una vez
## dentro del entorno enjaulado chroot.
############################
## IMPORTACIONES ##
############################
## Importo variables de configuración
source 'conf'
## Importo funciones auxiliares
source 'functions.sh'
############################
## FUNCIONES ##
############################
startChroot() {
echo -e "Preparando entorno chroot"
source /etc/profile
export PS1="(chroot) $PS1"
if [[ ! -d '/usr/portage' ]]; then
mkdir '/usr/portage'
fi
}
confRepos() {
echo -e "Configurando Repositorios"
emerge-webrsync
}
portageProfile() {
echo -e "Seleccionando Perfil del Sistema"
eselect profile list
read -p "Introduce el profile elegido" inputprofile
eselect profile set $inputprofile
cp "/usr/share/zoneinfo/$ZONE" /etc/localtime
echo "$ZONE" > /etc/timezone
}
installKernel() {
echo -e "Instalando Kernel con Genkernel"
emerge gentoo-sources
emerge genkernel
genkernel all
}
createFstab() {
echo -e "Generando fstab"
cp aux/fstab /etc/fstab
## TODO → Modificar con kernel actual
}
configRed() {
echo -e "Configurando Red"
echo "$HOSTNAME" > /etc/conf.d/hostname
# nano -w /etc/conf.d/net
#dns_domain_lo="$DOMAIN" ## insertar con sed
## Interfaz de red levantandose sola
# nano -w /etc/conf.d/net
#config_enp0s3=( “dhcp” )
# cd /etc/init.d/
# ln -s net.lo net.enp0s3
# rc-update add net.enp0s3 default
}
configLocales() {
echo -e "Configuración de idioma, hora y localización"
# nano -w /etc/conf.d/keymaps
#Agregamos las siguientes líneas si nuestro teclado es en español: > KEYMAP="$KEYMAP" > SET_WINDOWKEYS="yes"
## Reloj
# nano -w /etc/conf.d/hwclock
# clock="UTC"
# clock_systohc="YES"
## Localizaciones
echo "$LOCALIZATION UTF-8" > /etc/locale.gen
echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
locale-gen
## Locale Variables globales
echo "LANG=$LOCALIZATION" > /etc/env.d/02locale
echo "LANGUAGE=$LOCALIZATION" >> /etc/env.d/02locale
echo 'LC_COLLATE="C"' >> /etc/env.d/02locale
env-update && source /etc/profile
}
configRoot() {
echo -e "Configurando a Root"
## Passwd de root
echo 'Introduce la contraseña para root'
passwd
}
configUser() {
echo -e "Creando y configurando Usuario"
emerge app-admin/sudo
useradd -m -G users,wheel,audio,cdrom,usb,video -s /bin/bash $USUARIO
passwd $USUARIO
}
installGrub() {
echo -e "Instalando y configurando GRUB"
emerge grub
kernel=$(ls /boot/kernel* | head -1)
initramfs=$(/boot/initramfs* | head -1)
echo 'default 0' > '/boot/grub/grub.conf'
echo 'timeout 30' >> '/boot/grub/grub.conf'
echo 'title Gentoo' >> '/boot/grub/grub.conf'
echo "root $HDROOT" >> '/boot/grub/grub.conf'
echo "kernel $kernel real_root=$RAIZ" >> '/boot/grub/grub.conf'
echo "initrd $initramfs" >> '/boot/grub/grub.conf'
## Instalar GRUB en el disco duro
read -p '¿Instalar GRUB en MBR de /dev/sda? s/N → ' installGRUB
if [[ "$installGRUB" = 's' ]] || [[ "$installGRUB" = 'S' ]]; then
grep -v rootfs /proc/mounts > /etc/mtab
grub-install --no-floppy /dev/sda
fi
}
installSoftware() {
echo -e "Instalando Software Adicional"
emerge syslog-ng
rc-update add syslog-ng default
emerge vixie-cron
rc-update add vixie-cron default
emerge mlocate
emerge net-misc/dhcpcd
}
installRepoConf() {
echo -e "Clonando repositorio con herramientas adicionales"
echo -e "El repositorio estará en /home/$USUARIO/"
git clone https://gitlab.com/fryntiz/debian-developer-conf
}
installChroot() {
startChroot
confRepos
portageProfile
installKernel
createFstab
configRed
configLocales
configRoot
configUser
installGrub
installRepoConf
}