minor changes

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

157
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,60 +92,78 @@ prepare_debian() {
exit 1 exit 1
fi fi
while true; do if [ ! -n $mount ]; then
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 while true; do
if [ "$proceeding" = "no" ]; then 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
echo "ok aborting" if [ "$proceeding" = "no" ]; then
exit echo "ok aborting"
fi exit
if [ "$proceeding" = "yes" ]; then fi
echo "ok starting the installation" if [ "$proceeding" = "yes" ]; then
break echo "ok starting the installation"
fi break
done fi
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() {
echo "unmounting $disk" if [ ! -n "$mount" ]; then
umount $disk* echo "unmounting $disk"
umount $disk*
umount -R $mount umount -R $mount
rm -rf $mount rm -rf $mount
mkdir $mount mkdir $mount
echo "making $table table" echo "making $table table"
if [ $table = "mbr" ]; then if [ $table = "mbr" ]; then
parted $disk --script mklabel msdos parted $disk --script mklabel msdos
fi
if [ $table = "gpt" ]; then
parted $disk --script mklabel gpt
fi
echo "making partitions"
if [ $efi = "yes" ]; then
parted $disk --script \
mkpart primary fat32 1MiB 513MiB \
set 1 esp on \
mkpart primary ext4 513MiB 100%
mkfs.fat -F 32 ${disk}${prefix}1
mkfs.ext4 ${disk}${prefix}2
echo "mounting"
mount ${disk}${prefix}2 $mount
mkdir $mount/boot
mount ${disk}${prefix}1 $mount/boot
fi
if [ $efi = "no" ]; then
parted $disk --script \
mkpart primary ext4 1MiB 100%
mkfs.ext4 ${disk}${prefix}1
mount ${disk}${prefix}1 $mount
fi
fi fi
if [ $table = "gpt" ]; then
parted $disk --script mklabel gpt
fi
echo "making partitions"
if [ $efi = "yes" ]; then
parted $disk --script \
mkpart primary fat32 1MiB 513MiB \
set 1 esp on \
mkpart primary ext4 513MiB 100%
mkfs.fat -F 32 ${disk}${prefix}1
mkfs.ext4 ${disk}${prefix}2
echo "mounting"
mount ${disk}${prefix}2 $mount
mkdir $mount/boot
mount ${disk}${prefix}1 $mount/boot
fi
if [ $efi = "no" ]; then
parted $disk --script \
mkpart primary ext4 1MiB 100%
mkfs.ext4 ${disk}${prefix}1
mount ${disk}${prefix}1 $mount
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
efi_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
root_uuid=$(blkid -s UUID -o value ${disk}${prefix}2) if [ ! -n "$mount" ]; then
echo "UUID=$efi_uuid /boot/ vfat umask=0077 0 1" >> $mount/etc/fstab efi_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
echo "UUID=$root_uuid / ext4 defaults,noatime 0 1" >> $mount/etc/fstab 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=$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
root_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
echo "UUID=$root_uuid / ext4 defaults,noatime 0 1" >> $mount/etc/fstab if [ ! -n "$mount" ]; then
root_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
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!"