5
0
Fork 0
mirror of https://codeberg.org/Computertruhe/Setup-Skripte.git synced 2025-06-28 11:26:18 +02:00

rework the script to work as non-root and original ISO is used as argument instead

This commit is contained in:
stefan230 2020-03-08 10:40:12 +01:00
parent 7c5ad3ffbc
commit cac50cd166

View file

@ -1,38 +1,39 @@
#!/bin/bash #!/bin/bash
#you need to download the latest Linux Mint ISO from the website first before running the script.
#the script needs superuser rights to work correctly for now. #adds a variable for correct naming of the created ISO.
#TO DO: maybe there is a way for the script to work as non-root? UNATTENDED="unattended-$1" # => unattended-linuxmint-19.3-cinnamon-64bit.iso
[[ $UID -ne 0 ]] && exec sudo ./"$0"
#creates some folders that are used during the process. These can be changed, but needed be to changed across the script. #catch if argument 1 is empty. Without the ISO as an argument this script won't work
mkdir /mnt/iso /opt/mintiso if [ -z "$1" ]
#Downloads latest* mint-iso from the fh-aachen mirror. then echo "Usage: $0 [linuxmint-original.iso]"
#TO DO: Maybe there is a way to use a more generic url here? As it stands now the url has to be changed when a new Linux Mint version is released down the line. Maybe variables are a possibility? exit
wget http://mirror.bauhuette.fh-aachen.de/linuxmint-cd/stable/19.3/linuxmint-19.3-cinnamon-64bit.iso
#mounts the downloaded iso into a folder. * is added as a wildcard for the version number. #catch if the file cannot be found or is misspelled.
mount -o loop linuxmint-*-cinnamon-64bit.iso /mnt/iso elif [[ ! -f $1 ]]; then
echo "File not found: $1" >&2
exit 1
#the contents of the iso have to be copied over to another folder, since the ISO is mounted read-only. all the steps below require root. else
cp -rT /mnt/iso/ /opt/mintiso/
cd /opt/mintiso/ #creates a folders that is used during the process.
mkdir iso
#copies the iso to the created folder and makes the installed files writable.
bsdtar -xf $1 -C ./iso
chmod -R u+w ./iso
#copies the computertruhe.seed from codeberg-repo so always the latest preseed-file is used. #copies the computertruhe.seed from codeberg-repo so always the latest preseed-file is used.
curl https://codeberg.org/stefan230/Setup-Skripte/raw/branch/master/mint/computertruhe.seed > /opt/mintiso/preseed/computertruhe.seed curl https://codeberg.org/Computertruhe/Setup-Skripte/raw/branch/master/mint/computertruhe.seed > ./iso/preseed/linuxmint.seed
#configures the bootloader to use the "custom" computertruhe-preseed.
sed -i 's/linuxmint.seed/computertruhe.seed/g' isolinux/isolinux.cfg
#creates the custom-iso with the given parameters. #creates the custom-iso with the given parameters.
#TO DO: the outputpath right now is not generic enough. Maybe find a better name for the iso. mkisofs -D -r -V "UNATTENDED_MINT" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o $UNATTENDED ./iso
mkisofs -D -r -V "UNATTENDED_MINT" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /home/stefan/linuxmint-unattended.iso /opt/mintiso
#umounts the iso and clears up the space we used to create the iso. #umounts the iso and clears up the space we used to create the iso.
umount /mnt/iso rm -rf ./iso
cd
rm -r /mnt/iso/
rm -r /opt/mintiso/
#from here we are basically done and the iso can be "burned" on an USB ready for install. #from here we are basically done and the iso can be "burned" on an USB ready for install.
echo "Die Custom ISO wurde fertiggestellt und kann nun verwendet werden. Die ISO ist unter /home/stefan/linuxmint-unattended.iso zu finden." echo "Die Custom ISO wurde fertiggestellt und kann nun verwendet werden. Die ISO ist unter $UNATTENDED zu finden."
fi