-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·130 lines (108 loc) · 5.36 KB
/
deploy.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
#!/bin/bash
# We assume that you have booted the live iso at a new gentoo machine
# and grabbed this script from https://raw.githubusercontent.com/smurfd/gentoo-deploy/main/deploy.sh
# THIS WILL WIPE YOUR DRIVE
source ./setup.cfg
# Add some config files or parts of configfiles to $SITE/ for easily be able to wget
CRASHANDBURN=isolomlyswearimuptono.good
if test -f "$CRASHANDBURN"; then
echo 'Its Your fault from now on...'
else
echo 'DO YOU REALIZE THIS WILL WIPE YOUR DRIVE???'
echo 'if you do, and you understand that anything that goes wrong after this, is YOUR FAULT!'
echo 'Read through the script and change the variables at the top to your liking'
echo 'Then run the following command and re-run the script:'
echo 'touch isolomlyswearimuptono.good'
exit
fi
# Configure network for the install
ip a add $IP dev $NC
ip link set $NC up
route add default gw 192.168.0.1
echo 'nameserver 192.168.0.1' >> /etc/resolv.conf
# Set keyboard
echo 'keymap="sv-latin1"' >> /etc/conf.d/keymaps
/etc/init.d/keymaps restart
# Wipe filesystem
wipefs $HD
# Create partitions
parted -a optimal $HD --script mklabel gpt
parted $HD --script unit MB #Sets the unit to MegaBytes
parted $HD --script mkpart primary 1 20 #Makes a primary partition starting from 1 MegaByte to #20th for bios
parted $HD --script mkpart primary 21 500 #Partition /boot filesystem
parted $HD --script mkpart primary 501 7500 #Partition of size 2000MB made for swap
parted $HD --script -- mkpart primary 7501 -1 #Partition for the /(root) filesystem.
parted $HD --script print
parted $HD --script name 1 grub
parted $HD --script set 1 bios_grub on #The partition number 1 has its bios_grub flag set to one
parted $HD --script name 2 boot
parted $HD --script name 3 swap
parted $HD --script name 4 root
# Create the filesystems
mkfs.ext4 "${HDD}4"
mkfs.fat -F 32 "${HDD}2"
mkswap "${HDD}3"
swapon "${HDD}3"
# Mounting the root partition
mount "${HDD}4" /mnt/gentoo
# Create and make the boot partition
mkdir /mnt/gentoo/boot
mkdir /mnt/gentoo/boot/efi
mkdir /mnt/gentoo/home
mount "${HDD}2" /mnt/gentoo/boot/efi
cp setup.cfg deploy-chroot.sh kern* /mnt/gentoo
chmod +x /mnt/gentoo/deploy-chroot.sh
# Get the latest stage3 file
cd /mnt/gentoo
wget $URL/latest-stage3-amd64-hardened-openrc.txt
URL2=`cat latest-stage3-amd64-hardened-openrc.txt|grep -v "^#" | cut -d" " -f1`
wget $URL/$URL2
# unpack the tarball
tar xpf stage3-amd64* --xattrs-include='*.*' --numeric-owner
# Create a make.conf
echo '# These settings were set by the catalyst build script that automatically' > /mnt/gentoo/etc/portage/make.conf
echo '# built this stage.' >> /mnt/gentoo/etc/portage/make.conf
echo '# Please consult /usr/share/portage/config/make.conf.example for a more' >> /mnt/gentoo/etc/portage/make.conf
echo '# detailed example.' >> /mnt/gentoo/etc/portage/make.conf
echo 'COMMON_FLAGS="-march=native -O2 -pipe"' >> /mnt/gentoo/etc/portage/make.conf
echo 'CFLAGS="${COMMON_FLAGS}"' >> /mnt/gentoo/etc/portage/make.conf
echo 'CXXFLAGS="${COMMON_FLAGS}"' >> /mnt/gentoo/etc/portage/make.conf
echo 'FCFLAGS="${COMMON_FLAGS}"' >> /mnt/gentoo/etc/portage/make.conf
echo 'FFLAGS="${COMMON_FLAGS}"' >> /mnt/gentoo/etc/portage/make.conf
echo 'MAKEOPTS="-j4"' >> /mnt/gentoo/etc/portage/make.conf
echo '' >> /mnt/gentoo/etc/portage/make.conf
echo '# NOTE: This stage was built with the bindist Use flag enabled' >> /mnt/gentoo/etc/portage/make.conf
echo 'PORTDIR="/var/db/repos/gentoo"' >> /mnt/gentoo/etc/portage/make.conf
echo 'DISTDIR="/var/cache/distfiles"' >> /mnt/gentoo/etc/portage/make.conf
echo 'PKGDIR="/var/cache/binpkgs"' >> /mnt/gentoo/etc/portage/make.conf
echo '' >> /mnt/gentoo/etc/portage/make.conf
echo '# This sets the language of build output to English.' >> /mnt/gentoo/etc/portage/make.conf
echo '# Please keep this setting intact when reporting bugs.' >> /mnt/gentoo/etc/portage/make.conf
echo 'LC_MESSAGES=C' >> /mnt/gentoo/etc/portage/make.conf
if [ $LOCAL = true ]; then
echo 'GENTOO_MIRRORS="rsync://192.168.0.39/gentoo"' >> /mnt/gentoo/etc/portage/make.conf
else
echo 'GENTOO_MIRRORS="http://gentoo.osuosl.org/"' >> /mnt/gentoo/etc/portage/make.conf
fi
echo 'ACCEPT_LICENSE="-* @FREE @BINARY-REDISTRIBUTABLE"' >> /mnt/gentoo/etc/portage/make.conf
# Create a portage folder
mkdir --parents /mnt/gentoo/etc/portage/repos.conf && cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf && cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
mkdir --parents /mnt/gentoo/var/db/repos/gentoo
# Set local rsync mirror
if [ $LOCAL = true ]; then
sed -i 's/sync-uri = rsync:\/\/rsync.gentoo.org\/gentoo-portage/sync-uri = rsync:\/\/192.168.0.39\/gentoo-portage/g' /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
fi
# Mount the system partitions
mount --types proc /proc /mnt/gentoo/proc && mount --rbind /sys /mnt/gentoo/sys && mount --make-rslave /mnt/gentoo/sys && mount --rbind /dev /mnt/gentoo/dev && mount --make-rslave /mnt/gentoo/dev && mount --bind /run /mnt/gentoo/run && mount --make-slave /mnt/gentoo/run
# Enter chroot
chroot /mnt/gentoo ./deploy-chroot.sh
# Clearing out some downloaded things from the chroot
rm /mnt/gentoo/deploy.sh
rm /mnt/gentoo/deploy-chroot.sh
rm /mnt/gentoo/*.cfg
rm /mnt/gentoo/latest*.txt
rm /mnt/gentoo/stage*
# Unmount After install in chroot is done
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -l /mnt/gentoo{/boot/efi,/proc,}
echo "Now you should be able to reboot"