-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall
executable file
·143 lines (124 loc) · 4.12 KB
/
install
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
#!/bin/bash
# SPDX-FileCopyrightText: 2017 - 2024 sudorook <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
set -euo pipefail
DIR="$(dirname "$0")"
#
# Source the functions
#
. "${DIR}"/functions/00-check
. "${DIR}"/functions/00-install
#
# Define main select wrapper
#
function main {
ask_release
ask_device
ask_partition_scheme
case "${SCHEME}" in
"LVM on LUKS")
ask_physical_volume_name
ask_volume_group_name
;;
"LVM")
SCHEME="LVM"
ask_volume_group_name
;;
*) ;;
esac
ask_bootmode
ask_partition_sizes
ask_timezone
ask_locale
ask_hostname
ask_username
ask_password
if [[ "${SCHEME}" = "LVM on LUKS" ]]; then
ask_lukspass
fi
export PATH="/usr/sbin:/usr/bin:/sbin:/bin${PATH:+":${PATH}"}"
set_partitions
format_partitions
mount_install
if [ "${RELEASE_VERSION}" -gt 11 ]; then
debootstrap \
--include=locales,keyboard-configuration,cryptsetup,cryptsetup-initramfs,lvm2,zstd,util-linux,util-linux-extra,tasksel \
--arch amd64 "${RELEASE_NAME}" /mnt https://deb.debian.org/debian
else
debootstrap \
--include=locales,keyboard-configuration,cryptsetup,cryptsetup-initramfs,lvm2,zstd,util-linux,tasksel \
--arch amd64 "${RELEASE_NAME}" /mnt https://deb.debian.org/debian
fi
mkdir -p /mnt/run/udev
for FS in proc sys dev dev/pts run/udev; do
mount --bind /${FS} /mnt/${FS}
done
"${DIR}"/utils/genfstab -U /mnt >> /mnt/etc/fstab
if [[ "${BOOTMODE}" = "systemd-boot" ]]; then
sed -i "/\(.*\)\s\+\/efi\s\+vfat/s/0022/0077/g" /mnt/etc/fstab
fi
TIMEZONE="${TIMEZONE}" chroot /mnt /bin/bash -c "set_timezone"
LOCALE="${LOCALE}" CHARSET="${CHARSET}" chroot /mnt /bin/bash -c "set_locale"
KBLAYOUT="us" chroot /mnt /bin/bash -c "set_keyboard"
cp "sources/${RELEASE_NAME}-sources.list" "/mnt/etc/apt/sources.list"
chroot /mnt /bin/bash -c "update_mirrorlist"
SCHEME="${SCHEME}" chroot /mnt /bin/bash -c "install_packages"
# chroot /mnt /bin/bash -c "install_ucode"
HOST_NAME="${HOST_NAME}" chroot /mnt /bin/bash -c "set_hostname"
USER_NAME="${USER_NAME}" USER_PASSWORD="${USER_PASSWORD}" \
chroot /mnt /bin/bash -c "add_user"
chroot /mnt /bin/bash -c "disable_root"
if [[ "${BOOTMODE}" = "GRUB" ]]; then
SCHEME="${SCHEME}" DEVICE="${DEVICE}" \
chroot /mnt /bin/bash -c "install_grub"
if [[ "${SCHEME}" = "LVM on LUKS" ]]; then
CRYPT_PASSWORD="${CRYPT_PASSWORD}" CRYPT_PARTITION="${CRYPT_PARTITION}" \
chroot /mnt /bin/bash -c "make_luks_key"
fi
elif [[ "${BOOTMODE}" = "systemd-boot" ]]; then
mkdir -p /mnt/etc/kernel/postinst.d/
mkdir -p /mnt/etc/kernel/postrm.d/
mkdir -p /mnt/etc/initramfs/post-update.d/
mkdir -p /mnt/etc/systemd/system/
cp -af "${DIR}/hooks/update-systemd-boot" /mnt/etc/kernel/postinst.d/
cp -af "${DIR}/hooks/update-systemd-boot" /mnt/etc/kernel/postrm.d/
cp -af "${DIR}/hooks/update-initrd" /mnt/etc/initramfs/post-update.d/
cp -af \
"${DIR}/hooks/systemd-update-efi.path" \
"${DIR}/hooks/systemd-update-efi.service" \
/mnt/etc/systemd/system/
SCHEME="${SCHEME}" DEVICE="${DEVICE}" \
chroot /mnt /bin/bash -c "install_gummiboot"
elif [[ "${BOOTMODE}" = "EFISTUB" ]]; then
show_warning "Not supported yet..."
fi
unmount_install
show_success "Done! Reboot now."
}
#
# Check if dependencies are installed and if network is working
#
check_root
check_network
if ! check_install_commands; then
check_sync_repos
install_dependencies
fi
#
# GO!!!
#
main