-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchroot.sh
192 lines (169 loc) · 3.32 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# Chroot Install format
function start01 {
OPTIONS="Start Menu"
select opt in $OPTIONS; do
if [ "$opt" = "Start" ]; then
execfunc01
elif [ "$opt" = "Menu" ]; then
menu01
else
echo invalid option
fi
done
}
function menu01 {
OPTIONS="UpdateShell ConfigurePortage SelectSystemProfile ConfigureLocale Kernel Grub SetPasswd Quit"
select opt in $OPTIONS; do
case $opt in
"UpdateShell")
env00
;;
"ConfigurePortage")
sys00
;;
"SelectSystemProfile")
env01
;;
"ConfigureLocale")
env02
;;
"Kernel")
sys01
;;
"Grub")
sys02
;;
"SetPasswd")
env03
;;
"Quit")
exit00
;;
*) echo invalid option;;
esac
done
}
function qcontinue01 {
echo
read -p "Continue y/n?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo
else
start00
fi
echo
}
function execfunc01 {
env00
sys00
qcontinue01
# env01
qcontinue01
env02
qcontinue01
sys01
qcontinue01
sys02
qcontinue01
env03
exit00
}
function env00 {
env-update
source /etc/profile
}
# distcc
function sys00 {
echo
echo Configure Portage
mkdir /usr/portage
mkdir /usr/local/portage
cp /etc/portage/make.conf /var/lib/layman/make.conf
emerge-webrsync
}
# it doesnt look like this is necessary
function env01 {
eselect profile list
read -p "Enter Number for \"hardened/linux/amd64\" " profile
read -p "Is $profile correct?" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
eselect profile set $profile
else
env01
fi
}
function env02 {
locale-gen
}
# clean
# consider gcc emerge after reboot due to flags,parameters of host
function sys01 {
echo KERNEL
echo NOTE: This kernel requires GCC 4.9 and lz4. updating gcc requires gcc-config.
echo disable \'mknod\' and \'Deny mounts\' kernel configs from compiler system with grsec kernel prior to build.
emerge hardened-sources genkernel grub os-prober dhcpcd gcc app-arch/lz4 vim
gcc-config -l
read -p "Enter Number for \"x86_64-pc-linux-gnu-4.9.2 or later\" " gcc
read -p "Is $gcc correct?" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
gcc-config $gcc
else
# modify
gcc-config -l
fi
env-update && source /etc/profile
emerge --oneshot libtool
# su; eselect kernel
cp /001-master/config/usr/src/linux/.superkoala-* /usr/src/linux/
cd /usr/src/linux; ls -al; cd
# continue
genkernel --menuconfig all --makeopts=-j6
}
function sys02 {
# ensure fstab root dir is correct for fsid
#
# TODO: fix
# efi
#
# do this before chroot
# mount /boot/efi according to fstab
echo The EFI partition identifier needs to be listed correctly in fstab.
echo When vim loads the fstab file, ensure that the line:
echo \/dev\/EFI-identifier \/boot\/efi vfat noauto,noatime 1 2
echo is entered with key command \'i\' and saved with key command: :qw
qcontinue01
vim /etc/fstab
read -p "Is the modification correct?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo
else
sys02
fi
mkdir /boot/grub
#mkdir /boot/efi;mount /boot/efi^
grep -v rootfs /proc/mounts > /etc/mtab
grub2-install --target=x86_64-efi #/dev/sda1
grub2-mkconfig -o /boot/grub/grub.cfg
grub2-mkconfig -o /boot/grub/grub.cfg
}
function env03 {
echo
echo Set Root Password - ensure correct keymap
passwd
echo
}
function exit00 {
read -p "Exit Chroot Session?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
exit
else
start01
fi
}
start01
# check
# debug