-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinside_chroot.sh
115 lines (87 loc) · 3.52 KB
/
inside_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
#!/bin/sh
# This script will run inside the chrooted environment
# Make sure we are running as root:
[ "$(id -u)" -ne 0 ] && echo "Must run as root" && exit
confirm_eselect_automation(){
eselect "$1" list
echo "Is the above ${1} correct?[y for 'yes']"
read -r answer
if [ ! "$answer" = 'y' ] && [ ! "$answer" = 'Y' ] && [ ! "$answer" = 'yes' ]; then
echo "Exiting..." & sleep 1
exit 1
fi
}
SCRIPT_DIR=/root/install_scripts
. /etc/profile
export PS1="(chroot) ${PS1}"
# should mount /boot here, in theory
emerge-webrsync
eselect profile list | grep 'default/linux/amd64.*/desktop (stable)' | sed 's/\([0-9]\).*/\1/' | tr -d [ | tr -d ' ' | xargs eselect profile set
eselect profile list | grep -F '*' | grep -q 'default/linux/amd64/.*/desktop (stable)' || echo "Couldn't set profile correctly" && exit 1
confirm_eselect_automation "profile"
# this doesn't work if something fails (circular dependencies)
emerge --verbose --update --deep --newuse @world || exit 1
# we use this command in the next script
emerge --verbose app-portage/cpuid2cpuflags || exit 1
"${SCRIPT_DIR}"/setup_local_use_flags.sh && echo "Local use flags set up." || exit 1
echo "Brazil/East" > /etc/timezone && emerge --config sys-libs/timezone-data && echo "Timezone set" || exit 1
echo \
"en_US ISO-8859-1
en_US.UTF-8 UTF-8
pt_BR ISO-8859-1
pt_BR.UTF-8 UTF-8
" > /etc/locale.gen && echo "Edited locale.gen"
locale-gen && echo "Generated locales"
eselect locale list | grep "en_US.UTF-8 UTF-8" | sed 's/\([0-9]\).*/\1/' | tr -d [ | tr -d ' ' | xargs eselect locale set
confirm_eselect_automation "locale"
env-update && . /etc/profile && export PS1="(chroot) ${PS1}"
emerge --verbose sys-kernel/gentoo-sources app-arch/lz4
eselect kernel set 1
confirm_eselect_automation "kernel"
cd /usr/src/linux || exit 1
make menuconfig
while true; do
echo "Are you ready to compile the kernel[y/n]?"
read -r answer
case $answer in
[yY]*)
break
;;
[nN]*)
make menuconfig
;;
*)
echo "Don't be a bitch; type either 'y' or 'n'."
;;
esac
done
make -j12 && make -j12 modules_install
make install
emerge --verbose sys-kernel/genkernel sys-kernel/linux-firmware
echo "Generating initramfs..."
genkernel --install --kernel-config=./.config initramfs || exit 1
echo "...done."
lsblk
blkid
"${SCRIPT_DIR}"/utils/warn_and_edit.sh '/etc/fstab' 'You will now edit fstab. Take note of the above'
"${SCRIPT_DIR}"/utils/warn_and_edit.sh '/etc/conf.d/hostname' 'You will now set the hostname.'
emerge --verbose --noreplace net-misc/netifrc
"${SCRIPT_DIR}"/utils/warn_and_edit.sh '/etc/conf.d/net' 'Now set config_eth0="dhcp".'
cd /etc/init.d || exit 1
ln -s net.lo net.eth0
rc-update add net.eth0 default
"${SCRIPT_DIR}"/utils/warn_and_edit.sh '/etc/hosts' "Now you will edit the hosts file
A good idea is to set it to <hostname>.homenetwork <hostname> localhost"
"${SCRIPT_DIR}"/utils/warn_and_edit.sh '/etc/conf.d/keymaps' "You will now select the keymap."
echo "Type the root password:" #This could go wrong if the doesn't have an us keyboard
passwd
"${SCRIPT_DIR}"/utils/warn_and_edit.sh "/etc/rc.conf" "Editing rc.conf."
"${SCRIPT_DIR}"/utils/warn_and_edit.sh "/etc/conf.d/hwclock" "Editing hwclock."
emerge --verbose app-admin/sysklogd && rc-update add sysklogd default
emerge --verbose net-misc/dhcpcd
emerge --verbose sys-process/cronie && rc-update add cronie default
echo "Would you like to install grub?[y for yes]"
read -r answer
if [ ! "$answer" = 'y' ] && [ ! "$answer" = 'Y' ] && [ ! "$answer" = 'yes' ]; then
emerge --verbose sys-boot/grub:2 && grub-mkconfig -o /boot/grub/grub.cfg
fi