Du kan fixa till och ordna, men det ska kunna funka:
- Kod: Markera allt
#! /bin/bash
#
if [[ -z $1 ]]; then
echo
echo "-No argument given - exiting..."
echo
exit
fi
PWD=$(basename $(pwd))
ISOEXT="$(echo $PWD | cut -c 3-).iso"
ISODIR=Enargo
LABEL="Enargo"
BOOTDIR="syslinux"
#
if [[ $1 == "ls" ]]; then
echo
BASE=$(pwd)
DIR=$(basename $(pwd))
# echo "DIR: $DIR"
if [[ $DIR != "gp32" ]]; then
echo "70:"
cd /home/ISO/gp70
else
echo "32:"
cd /home/ISO/gp32
fi
PWD=$(basename $(pwd))
ISOEXT="$(echo $PWD | cut -c 3-).iso"
ls -l Enargo$ISOEXT
# echo "ISOEXT: $ISOEXT"
ls -l /home/base/USB-kit/Kits/Ventoy/ISO/Enargo$ISOEXT
echo
cd $BASE
exit
fi
date > filesystem/root/dat
if [[ -z $1 || $1 == "squash" || $1 == "sq" || $1 == "s" ]]; then
BEFORE=$(ls -l $ISODIR/live/filesystem.squashfs)
if [[ -z $(which mksquashfs) ]]; then
apt-get install squashfs-tools
fi
if [[ -e $ISODIR/live/filesystem.squashfs ]]; then
rm -rif $ISODIR/live/filesystem.squashfs
fi
echo "-Making squashfs..."
#mksquashfs filesystem $ISODIR/live/filesystem.squashfs -b 1M # Don't know if we need "-b 1M"...
mksquashfs filesystem $ISODIR/live/filesystem.squashfs
echo
echo "-BEFORE: $BEFORE"
echo -n "-AFTER: "
ls -l $ISODIR/live/filesystem.squashfs
echo "-Syncing..."
sync
echo "-Created $ISODIR/live/filesystem.squashfs"
echo
fi
if [[ -z $1 || $1 == "iso" || $1 == "is" || $1 == "i" || $2 == "iso" || $2 == "is" || $2 == "i" ]]; then
#if [[ -z $1 ]]; then
# echo -n "_Directory: "
# read ISODIR
#fi
BEFORE=$(ls -l $ISODIR$ISOEXT)
echo
echo "-Generating ISO..."
genisoimage -r -V $LABEL -cache-inodes -J -l -b $BOOTDIR/isolinux.bin -c $BOOTDIR/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o $ISODIR$ISOEXT $ISODIR/
#ls -l $ISODIR$ISOEXT
#
# -The line above, shall be replaced with the line below if the size of the squashfs is bigger than 4G. The filesystem may be somewhat instable...
#genisoimage -r -V $LABEL -cache-inodes -J -l -b $BOOTDIR/isolinux.bin -c $BOOTDIR/boot.cat -no-emul-boot -allow-limited-size -boot-load-size 8 -boot-info-table -o $ISODIR$ISOEXT $ISODIR/
#
echo "-Making Hybrid..."
#ls -l $ISODIR$ISOEXT
isohybrid $ISODIR$ISOEXT
echo
echo "-BEFORE: $BEFORE"
echo -n "-AFTER: "
ls -l $ISODIR$ISOEXT
echo "-Syncing..."
sync
echo "-Created "$ISODIR$ISOEXT
echo
chmod 777 Enargo$ISOEXT
fi
if [[ -z $1 || $1 == "usb" || $1 == "us" || $1 == "u" ]]; then
#grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short)
echo
USBP="<none>"
USBD=$(alldisks -d -b usb)
for USB in $USBD; do
BSIZE=$(blockdev --getsize64 $USB)
#8 022 654 976
let MAXSIZE=8*1024*1024*1024
if [[ $BSIZE -le $MAXSIZE ]]; then
USBP=$USB
FSIZE=$(fdisk -l $USB 2> /dev/null | grep Disk\ | grep /dev/ | awk '{ print $3" "$4 }' | sed 's/://g' | sed 's/,$//g')
HWINFO=$(hwinfo --disk --short --only $USB | tail -1 | awk '{ $1="";print $0 }' | sed 's/^ //g')
printf "%-8s - %-25s - %s\n" "$USB" "$HWINFO" "$FSIZE"
fi
done
if [[ $USBP != "<none>" ]]; then
echo
fi
USBDEV=""
read -p "_USB Device - $USBP [y/N]: " IN
if [[ -z $IN || $IN == "n" || $IN == "N" ]]; then
echo
exit
elif [[ $IN == "y" || $IN == "Y" ]]; then
if [[ $USBP != "<none>" ]]; then
USBDEV=$USBP
else
echo
exit
fi
else
USBDEV=$IN
fi
if [[ ! -z $USBDEV ]]; then
MNT=$(mount | grep $USBDEV | wc -l)
if [[ $MNT == "0" ]]; then
read -p "_Is it correct to write to $USBDEV? [y/N]: " IN
if [[ -z $IN || $IN == "n" || $IN == "N" ]]; then
echo
exit
fi
echo "-Writing to USB ($USBDEV)"
pv -tpreb $ISODIR$ISOEXT | dd of=$USBDEV iflag=fullblock oflag=direct bs=4M conv=fsync
echo "-Syncing..."
sync
echo "-Written $ISODIR$ISOEXT to $USBDEV"
else
echo "-$USBDEV is mounted, can not write to it"
fi
fi
echo
fi
if [[ $1 == "cp" || $1 == "co" ]]; then
echo
echo "Old version:"
ls -lhs /home/base/USB-kit/Kits/Ventoy/ISO/Enargo$ISOEXT | awk '{ $1=""; print $0 }' | xargs
echo
echo "New version, here and at Ventoy"
#cp -av Enargo$ISOEXT /home/base/USB-kit/Kits/Ventoy/ISO/
cp -v Enargo$ISOEXT /home/base/USB-kit/Kits/Ventoy/ISO/
#echo
ls -lhs Enargo$ISOEXT | awk '{ $1=""; print $0 }' | xargs
ls -lhs /home/base/USB-kit/Kits/Ventoy/ISO/Enargo$ISOEXT | awk '{ $1=""; print $0 }' | xargs
echo
fi
sync