minor changes

This commit is contained in:
2026-01-24 21:40:53 +03:00
parent 6fd0c59095
commit 74a103c807

53
plct.sh
View File

@@ -1,13 +1,16 @@
#!/bin/bash #!/bin/bash
echo "welcome to portable linux creation tool v1.0" printf "welcome to portable linux creation tool v1.0p1\n"
printf "available distros: debian\n\n"
while true; do while true; do
read -rp "disk (e.g. /dev/sdX): " disk read -rp "distro: " distro
if [ -b "$disk" ]; then distro=${distro,,}
if [ "$distro" = "debian" ] || \
[ "$distro" = "alpine" ]; then
break break
fi fi
echo "$disk is incorrect or is not a disk" echo "pls choose distro from list"
done done
read -rp "choose mountpoint (/mnt/install): " mount read -rp "choose mountpoint (/mnt/install): " mount
@@ -15,6 +18,8 @@ if [ ! -n "$mount" ]; then
mount="/mnt/install" mount="/mnt/install"
fi fi
read -rp "disk (e.g. /dev/sdX) or skip to install to $mount: " disk
while true; do while true; do
read -rp "gpt/mbr: " table read -rp "gpt/mbr: " table
table=${table,,} table=${table,,}
@@ -87,6 +92,7 @@ prepare_debian() {
exit 1 exit 1
fi fi
if [ ! -n $mount ]; then
while true; do while true; do
read -rp "everything is ok, type 'no' to cancel or 'yes' to preceed installation of debian $choice to $disk with $table table (DATA ON $disk WILL BE LOST): " proceeding read -rp "everything is ok, type 'no' to cancel or 'yes' to preceed installation of debian $choice to $disk with $table table (DATA ON $disk WILL BE LOST): " proceeding
if [ "$proceeding" = "no" ]; then if [ "$proceeding" = "no" ]; then
@@ -98,11 +104,25 @@ prepare_debian() {
break break
fi fi
done done
else
while true; do
read -rp "everything is ok, type 'no' to cancel or 'yes' to preceed installation of debian $choice to $mount with $table table: " proceeding
if [ "$proceeding" = "no" ]; then
echo "ok aborting"
exit
fi
if [ "$proceeding" = "yes" ]; then
echo "ok starting the installation"
break
fi
done
fi
install_debian install_debian
} }
install_debian() { install_debian() {
if [ ! -n "$mount" ]; then
echo "unmounting $disk" echo "unmounting $disk"
umount $disk* umount $disk*
@@ -114,6 +134,7 @@ install_debian() {
if [ $table = "mbr" ]; then if [ $table = "mbr" ]; then
parted $disk --script mklabel msdos parted $disk --script mklabel msdos
fi fi
if [ $table = "gpt" ]; then if [ $table = "gpt" ]; then
parted $disk --script mklabel gpt parted $disk --script mklabel gpt
fi fi
@@ -134,6 +155,7 @@ install_debian() {
mkdir $mount/boot mkdir $mount/boot
mount ${disk}${prefix}1 $mount/boot mount ${disk}${prefix}1 $mount/boot
fi fi
if [ $efi = "no" ]; then if [ $efi = "no" ]; then
parted $disk --script \ parted $disk --script \
mkpart primary ext4 1MiB 100% mkpart primary ext4 1MiB 100%
@@ -141,6 +163,7 @@ install_debian() {
mount ${disk}${prefix}1 $mount mount ${disk}${prefix}1 $mount
fi fi
fi
debootstrap $choice $mount $mirror debootstrap $choice $mount $mirror
@@ -171,23 +194,43 @@ install_debian() {
mkdir $mount/boot/efi mkdir $mount/boot/efi
$RUN grub-install --target=x86_64-efi --efi-directory=/boot --removable $RUN grub-install --target=x86_64-efi --efi-directory=/boot --removable
$RUN update-grub $RUN update-grub
if [ ! -n "$mount" ]; then
efi_uuid=$(blkid -s UUID -o value ${disk}${prefix}1) efi_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
root_uuid=$(blkid -s UUID -o value ${disk}${prefix}2) root_uuid=$(blkid -s UUID -o value ${disk}${prefix}2)
echo "UUID=$efi_uuid /boot/ vfat umask=0077 0 1" >> $mount/etc/fstab echo "UUID=$efi_uuid /boot/ vfat umask=0077 0 1" >> $mount/etc/fstab
echo "UUID=$root_uuid / ext4 defaults,noatime 0 1" >> $mount/etc/fstab echo "UUID=$root_uuid / ext4 defaults,noatime 0 1" >> $mount/etc/fstab
fi fi
fi
if [ $efi = "no" ]; then if [ $efi = "no" ]; then
$RUN apt-get install -y grub-pc $RUN apt-get install -y grub-pc
$RUN grub-install $disk $RUN grub-install $disk
$RUN update-grub $RUN update-grub
if [ ! -n "$mount" ]; then
root_uuid=$(blkid -s UUID -o value ${disk}${prefix}1) root_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
echo "UUID=$root_uuid / ext4 defaults,noatime 0 1" >> $mount/etc/fstab echo "UUID=$root_uuid / ext4 defaults,noatime 0 1" >> $mount/etc/fstab
fi fi
fi
echo 'done! chrooted you into installed system. type "exit" to finish the installation' echo 'done! chrooted you into installed system. type "exit" to finish the installation'
if [ -n "$mount" ]; then
echo "pls generate fstab manually"
fi
$RUN /bin/bash $RUN /bin/bash
umount -R $mount umount -R $mount
} }
prepare_debian
if [ $distro = "debian" ]; then
prepare_debian
exit
fi
if [ $distro = "alpine" ]; then
prepare_alpine
exit
fi
echo "bye!"