Compare commits

..
1 Commits
Author SHA1 Message Date
wyj f7ccffccf0 new feat: add partition script 2024-04-18 15:54:44 -04:00
5 changed files with 13 additions and 95 deletions
-5
View File
@@ -1,5 +0,0 @@
#!/bin/env bash
TARGETDISK=$(lsblk -nrpo NAME,TYPE | grep ' disk' | awk '{print $1}' | gum choose)
echo "You have selected: $TARGETDISK"
+6 -9
View File
@@ -1,14 +1,12 @@
#! /bin/env bash #! /bin/env bash
# assume that /mnt and /mnt/boot is mounted
TARGET=/mnt TARGET=/mnt
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" DEVICE=$(findmnt -n -o SOURCE $TARGET | sed 's/\[.*//')
UUID=$(blkid -s UUID -o value ${DEVICE})
umount -R $TARGET DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source $DIR/choosedisk.sh echo $DIR
source ./make-partition.sh
source ./mount-subvol.sh
UUID=$(blkid -s UUID -o value "${TARGETDISK}2")
debootstrap stable $TARGET http://deb.debian.org/debian/ debootstrap stable $TARGET http://deb.debian.org/debian/
@@ -26,7 +24,6 @@ echo "export PATH=$PATH:/sbin/" >>$TARGET/root/.bashrc
cp $DIR/chroot-commands.sh $TARGET/root/ cp $DIR/chroot-commands.sh $TARGET/root/
chmod +x $TARGET/root/chroot-commands.sh chmod +x $TARGET/root/chroot-commands.sh
chroot $TARGET /bin/bash -l -c '/root/chroot-commands.sh' chroot $TARGET /bin/bash -l -c '/root/chroot-commands.sh'
rm $TARGET/root/chroot-commands.sh
# fix systemd-boot # fix systemd-boot
for ENTRY in $TARGET/boot/loader/entries/*.conf; do for ENTRY in $TARGET/boot/loader/entries/*.conf; do
Executable → Regular
+3 -2
View File
@@ -7,7 +7,7 @@ if [ -z "$TARGETDISK" ]; then
fi fi
# 使用 gum confirm 警告:这将删除目标硬盘上的所有数据 # 使用 gum confirm 警告:这将删除目标硬盘上的所有数据
if ! gum confirm "Warning: This will erase all data on $TARGETDISK. Proceed?"; then if ! gum confirm --prompt "Warning: This will erase all data on $TARGETDISK. Proceed?"; then
echo "Aborting." echo "Aborting."
exit 1 exit 1
fi fi
@@ -26,6 +26,7 @@ parted -s "$TARGETDISK" mkpart primary btrfs 513MiB 100%
mkfs.fat -F32 "${TARGETDISK}1" mkfs.fat -F32 "${TARGETDISK}1"
# 格式化系统分区为 Btrfs # 格式化系统分区为 Btrfs
mkfs.btrfs -f "${TARGETDISK}2" mkfs.btrfs "${TARGETDISK}2"
echo "Partitioning and formatting complete." echo "Partitioning and formatting complete."
-15
View File
@@ -1,15 +0,0 @@
mount "${TARGETDISK}2" $TARGET
btrfs subvolume create $TARGET/@
btrfs subvolume create $TARGET/@home
btrfs subvolume create $TARGET/@var_log
umount $TARGET
mount -o defaults,ssd,noatime,compress=zstd,subvol=@ "${TARGETDISK}2" $TARGET
mkdir -p $TARGET/{home,var/log,boot}
mount -o defaults,ssd,noatime,compress=zstd,subvol=@home "${TARGETDISK}2" $TARGET/home
mount -o defaults,ssd,noatime,compress=zstd,subvol=@var_log "${TARGETDISK}2" $TARGET/var/log
mount "${TARGETDISK}1" $TARGET/boot
-60
View File
@@ -1,60 +0,0 @@
#!/bin/bash
# 确保安装 gum
# pacman -Sy gum
main_menu() {
while true; do
clear
# 使用 gum 或其他工具显示主菜单
option=$(gum choose "分区硬盘" "设置网络" "安装基本系统" "开始安装" "退出安装")
case $option in
"分区硬盘")
partition_disk
;;
"设置网络")
setup_network
;;
"安装基本系统")
install_base_system
;;
"开始安装")
start_installation
break
;;
"退出安装")
exit 0
;;
esac
done
}
partition_disk() {
echo "分区硬盘..."
# 这里添加分区逻辑
gum confirm "返回主菜单?" && return
}
setup_network() {
echo "设置网络..."
# 这里添加网络设置逻辑
gum confirm "返回主菜单?" && return
}
install_base_system() {
echo "安装基本系统..."
# 这里添加安装基本系统的逻辑
gum confirm "返回主菜单?" && return
}
start_installation() {
echo "开始安装..."
# 这里添加实际开始安装的逻辑
echo "安装完成。"
exit 0
}
# 主菜单
main_menu