Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dabfe4025c | |||
| 4976ae08c4 | |||
| 9434b59c51 | |||
| 74a103c807 |
153
plct.sh
153
plct.sh
@@ -1,13 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "welcome to portable linux creation tool v1.0"
|
||||
printf "welcome to portable linux creation tool v1.0p2\n"
|
||||
printf "available distros: debian\n\n"
|
||||
|
||||
while true; do
|
||||
read -rp "disk (e.g. /dev/sdX): " disk
|
||||
if [ -b "$disk" ]; then
|
||||
read -rp "distro: " distro
|
||||
distro=${distro,,}
|
||||
if [ "$distro" = "debian" ] || \
|
||||
[ "$distro" = "alpine" ]; then
|
||||
break
|
||||
fi
|
||||
echo "$disk is incorrect or is not a disk"
|
||||
echo "pls choose distro from list"
|
||||
done
|
||||
|
||||
read -rp "choose mountpoint (/mnt/install): " mount
|
||||
@@ -15,6 +18,8 @@ if [ ! -n "$mount" ]; then
|
||||
mount="/mnt/install"
|
||||
fi
|
||||
|
||||
read -rp "disk (e.g. /dev/sdX) or skip to install to $mount: " disk
|
||||
|
||||
while true; do
|
||||
read -rp "gpt/mbr: " table
|
||||
table=${table,,}
|
||||
@@ -87,60 +92,78 @@ prepare_debian() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
if [ "$proceeding" = "no" ]; then
|
||||
echo "ok aborting"
|
||||
exit
|
||||
fi
|
||||
if [ "$proceeding" = "yes" ]; then
|
||||
echo "ok starting the installation"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -n "$disk" ]; then
|
||||
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
|
||||
if [ "$proceeding" = "no" ]; then
|
||||
echo "ok aborting"
|
||||
exit
|
||||
fi
|
||||
if [ "$proceeding" = "yes" ]; then
|
||||
echo "ok starting the installation"
|
||||
break
|
||||
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() {
|
||||
echo "unmounting $disk"
|
||||
umount $disk*
|
||||
if [ -n "$disk" ]; then
|
||||
echo "unmounting $disk"
|
||||
umount $disk*
|
||||
|
||||
umount -R $mount
|
||||
rm -rf $mount
|
||||
mkdir $mount
|
||||
umount -R $mount
|
||||
rm -rf $mount
|
||||
mkdir $mount
|
||||
|
||||
echo "making $table table"
|
||||
if [ $table = "mbr" ]; then
|
||||
parted $disk --script mklabel msdos
|
||||
echo "making $table table"
|
||||
if [ $table = "mbr" ]; then
|
||||
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
|
||||
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
|
||||
|
||||
@@ -171,23 +194,39 @@ install_debian() {
|
||||
mkdir $mount/boot/efi
|
||||
$RUN grub-install --target=x86_64-efi --efi-directory=/boot --removable
|
||||
$RUN update-grub
|
||||
efi_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
|
||||
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
|
||||
|
||||
if [ -n "$disk" ]; then
|
||||
efi_uuid=$(blkid -s UUID -o value ${disk}${prefix}1)
|
||||
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
|
||||
if [ $efi = "no" ]; then
|
||||
$RUN apt-get install -y grub-pc
|
||||
$RUN grub-install $disk
|
||||
$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 "$disk" ]; 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
|
||||
|
||||
echo 'done! chrooted you into installed system. type "exit" to finish the installation'
|
||||
if [ ! -n "$disk" ]; then
|
||||
echo "pls generate fstab manually"
|
||||
fi
|
||||
$RUN /bin/bash
|
||||
|
||||
umount -R $mount
|
||||
}
|
||||
|
||||
prepare_debian
|
||||
|
||||
|
||||
if [ $distro = "debian" ]; then
|
||||
prepare_debian
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "bye!"
|
||||
Reference in New Issue
Block a user