2023-05-01 03:54:15 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
### this script makes everything to build a ready to boot .iso file of nanodesk
|
|
|
|
###
|
|
|
|
### By: DeltaLima
|
|
|
|
### 2023
|
2023-05-01 03:58:47 +02:00
|
|
|
|
2023-05-03 17:40:43 +02:00
|
|
|
### include config
|
2023-05-03 19:19:25 +02:00
|
|
|
. makeanything.conf
|
2023-05-03 17:40:43 +02:00
|
|
|
|
2023-05-01 05:32:10 +02:00
|
|
|
CHROOTCMD="sudo chroot build/chroot/"
|
2023-05-02 23:02:13 +02:00
|
|
|
test -n "$VERSION" || VERSION="$(git describe --tags)" #-$(git rev-parse --short HEAD)"
|
2023-05-01 07:49:56 +02:00
|
|
|
|
2023-05-01 10:46:32 +02:00
|
|
|
MIRROR=$1
|
2023-05-01 07:49:56 +02:00
|
|
|
if [ -z "$MIRROR" ]
|
|
|
|
then
|
|
|
|
MIRROR="http://ftp.gwdg.de/debian/"
|
|
|
|
fi
|
2023-05-01 05:32:10 +02:00
|
|
|
|
2023-05-01 11:58:19 +02:00
|
|
|
# colors for colored output 8)
|
|
|
|
RED="\e[31m"
|
|
|
|
GREEN="\e[32m"
|
|
|
|
YELLOW="\e[33m"
|
|
|
|
ENDCOLOR="\e[0m"
|
|
|
|
|
|
|
|
function message() {
|
|
|
|
case $1 in
|
|
|
|
warn)
|
|
|
|
MESSAGE_TYPE="${YELLOW}WARN${ENDCOLOR}"
|
|
|
|
;;
|
|
|
|
error)
|
|
|
|
MESSAGE_TYPE="${RED}ERROR${ENDCOLOR}"
|
|
|
|
;;
|
|
|
|
info|*)
|
|
|
|
MESSAGE_TYPE="${GREEN}INFO${ENDCOLOR}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-05-03 17:34:20 +02:00
|
|
|
if [ "$1" == "info" ] || [ "$1" == "warn" ] || [ "$1" == "error" ]
|
2023-05-01 11:58:19 +02:00
|
|
|
then
|
|
|
|
MESSAGE=$2
|
|
|
|
else
|
|
|
|
MESSAGE=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "[${MESSAGE_TYPE}] $MESSAGE"
|
2023-05-01 03:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
error ()
|
|
|
|
{
|
2023-05-01 11:58:19 +02:00
|
|
|
message error "ERROR!!"
|
2023-05-01 03:58:47 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-05-01 06:14:58 +02:00
|
|
|
message "installing requirements"
|
|
|
|
### https://www.willhaley.com/blog/custom-debian-live-environment/
|
|
|
|
sudo apt install \
|
|
|
|
debootstrap \
|
|
|
|
squashfs-tools \
|
|
|
|
xorriso \
|
|
|
|
isolinux \
|
|
|
|
syslinux-efi \
|
|
|
|
grub-pc-bin \
|
|
|
|
grub-efi-amd64-bin \
|
|
|
|
grub-efi-ia32-bin \
|
|
|
|
mtools \
|
2023-05-01 06:16:53 +02:00
|
|
|
dosfstools \
|
2023-05-01 09:24:15 +02:00
|
|
|
coreutils \
|
2023-05-03 15:46:57 +02:00
|
|
|
pandoc || error
|
2023-05-01 03:58:47 +02:00
|
|
|
|
2023-05-03 16:30:55 +02:00
|
|
|
|
|
|
|
|
2023-05-01 17:02:56 +02:00
|
|
|
message "start building nanodesk ${YELLOW}${VERSION}${ENDCOLOR}"
|
2023-05-01 16:55:30 +02:00
|
|
|
|
2023-05-01 17:48:56 +02:00
|
|
|
read -p "press [enter] to continue"
|
|
|
|
|
2023-05-01 03:58:47 +02:00
|
|
|
### stuff begins here
|
2023-05-01 22:26:18 +02:00
|
|
|
|
|
|
|
message "creating build directories"
|
2023-05-03 16:30:55 +02:00
|
|
|
for dir in $(echo build/{staging/{EFI/BOOT,boot/grub/x86_64-efi,isolinux,live},tmp,chroot,nanodesk-files})
|
2023-05-01 22:26:18 +02:00
|
|
|
do
|
|
|
|
message "$dir"
|
|
|
|
test -d $dir || mkdir -p $dir
|
|
|
|
done
|
2023-05-01 03:58:47 +02:00
|
|
|
|
2023-05-03 16:30:55 +02:00
|
|
|
message "running debootstrap $DEBOOTSTRAP_OPTS $DEBOOTSTRAP_SUITE $MIRROR"
|
2023-05-03 17:34:20 +02:00
|
|
|
sudo debootstrap ${DEBOOTSTRAP_OPTS} ${DEBOOTSTRAP_SUITE} build/chroot/ $MIRROR || message warn "debootstrap exited with code $?"
|
2023-05-01 07:39:57 +02:00
|
|
|
|
2023-05-01 06:20:39 +02:00
|
|
|
message "copy xdgmenumaker deb file into chroot"
|
2023-05-01 11:58:19 +02:00
|
|
|
sudo cp deb/xdgmenumaker* build/chroot/tmp || error
|
2023-05-01 06:44:45 +02:00
|
|
|
|
2023-05-03 18:53:52 +02:00
|
|
|
message "copy install_base scripts to build/chroot/tmp/"
|
|
|
|
sudo cp install_base/* build/chroot/tmp/ || error
|
2023-05-01 23:39:04 +02:00
|
|
|
|
|
|
|
|
2023-05-03 18:53:52 +02:00
|
|
|
#### install_base
|
2023-05-01 20:26:40 +02:00
|
|
|
message "run install_base.sh"
|
2023-05-01 05:32:10 +02:00
|
|
|
$CHROOTCMD /bin/bash /tmp/install_base.sh || error
|
2023-05-03 18:53:52 +02:00
|
|
|
####
|
2023-05-01 10:46:32 +02:00
|
|
|
|
2023-05-03 15:46:57 +02:00
|
|
|
### copy nanodesk files in nanodesk-files/ to build/nanodesk-files/ so we can make changes there,
|
|
|
|
### like generate version file and convert .md to .html in usr/share/docs/nanodesk
|
|
|
|
message "copy nanodesk-files/ to build/nanodesk-files/"
|
2023-05-03 16:30:55 +02:00
|
|
|
cp -r nanodesk-files/* build/nanodesk-files/
|
2023-05-03 15:46:57 +02:00
|
|
|
|
|
|
|
message "write nanodesk version $VERSION into build/nanodesk-files/usr/share/nanodesk/version"
|
2023-05-03 16:30:55 +02:00
|
|
|
echo $VERSION > build/nanodesk-files/usr/share/nanodesk/version
|
2023-05-03 15:46:57 +02:00
|
|
|
|
|
|
|
message "convert .md files in build/nanodesk-files/usr/doc/nanodesk/ to .html"
|
|
|
|
for md in $(find build/nanodesk-files/usr/share/doc/nanodesk/ -name "*.md")
|
|
|
|
do pandoc --self-contained --css=pandoc/pandoc.css -M pagetitle:$(basename $md|sed 's/\.md//') -s $md -o $(echo $md | sed 's/\.md/\.html/')
|
|
|
|
done
|
|
|
|
|
|
|
|
message "copy build/nanodesk-files/ to build/chroot/"
|
|
|
|
sudo cp -r build/nanodesk-files/* build/chroot/
|
2023-05-01 06:07:51 +02:00
|
|
|
|
2023-05-03 19:19:25 +02:00
|
|
|
message "generate icon path list for jwm config"
|
2023-05-03 19:32:08 +02:00
|
|
|
find build/chroot/usr/share/icons/ -type d | sed 's/build\/chroot//g' > build/tmp/jwm.iconlist
|
2023-05-03 19:19:25 +02:00
|
|
|
sed -i -e 's/^/\ \ \ \ <IconPath>/g' -e 's/$/<\/IconPath>/g' build/tmp/jwm.iconlist
|
|
|
|
sudo cp build/tmp/jwm.iconlist build/chroot/tmp/ || error
|
|
|
|
|
2023-05-03 18:53:52 +02:00
|
|
|
message "putting generated icon path list to /etc/jwm/system.jwmrc"
|
2023-05-03 19:19:25 +02:00
|
|
|
$CHROOTCMD sed -i '/<\!-- GENERATED ICONLIST -->/r /tmp/jwm.iconlist' /etc/jwm/system.jwmrc || error
|
2023-05-03 18:53:52 +02:00
|
|
|
|
2023-05-01 06:40:03 +02:00
|
|
|
message "correct file permissions"
|
2023-05-03 00:39:55 +02:00
|
|
|
$CHROOTCMD /usr/bin/chmod 440 /etc/sudoers || error
|
|
|
|
$CHROOTCMD /usr/bin/chmod 755 /root/nanodesk-installer.sh || error
|
2023-05-01 06:40:03 +02:00
|
|
|
|
2023-10-21 20:07:56 +02:00
|
|
|
|
|
|
|
### set root password
|
|
|
|
message "set root password to 'debian'"
|
2023-10-21 20:32:15 +02:00
|
|
|
$CHROOTCMD echo -e "debian\ndebian" | $CHROOTCMD passwd root
|
2023-10-21 20:07:56 +02:00
|
|
|
|
|
|
|
### add debian user
|
2023-10-21 20:32:15 +02:00
|
|
|
message "create user debian, password 'debian'"
|
|
|
|
$CHROOTCMD echo -e "debian\ndebian\nDebian\n\n\n\n\y\n" | $CHROOTCMD adduser debian
|
2023-10-21 20:07:56 +02:00
|
|
|
|
2023-05-03 18:53:52 +02:00
|
|
|
message "clear /tmp"
|
|
|
|
$CHROOTCMD /usr/bin/rm -Rf /tmp/* || error
|
|
|
|
|
2023-05-01 06:04:01 +02:00
|
|
|
### liveboot part, https://www.willhaley.com/blog/custom-debian-live-environment/
|
2023-05-01 06:44:45 +02:00
|
|
|
message "make squashfs"
|
2023-05-01 06:04:01 +02:00
|
|
|
test -f build/staging/live/filesystem.squashfs && sudo rm build/staging/live/filesystem.squashfs
|
2023-05-01 05:47:12 +02:00
|
|
|
sudo mksquashfs \
|
|
|
|
build/chroot \
|
|
|
|
build/staging/live/filesystem.squashfs \
|
2023-05-02 23:02:13 +02:00
|
|
|
-comp xz \
|
2023-05-01 05:47:12 +02:00
|
|
|
-e boot || error
|
|
|
|
|
2023-05-03 00:32:27 +02:00
|
|
|
|
2023-05-01 20:41:06 +02:00
|
|
|
message "copy kernel and initrd images"
|
2023-05-03 00:32:27 +02:00
|
|
|
cp build/chroot/boot/vmlinuz-* build/staging/live/vmlinuz || error
|
|
|
|
cp build/chroot/boot/initrd.img-* build/staging/live/initrd || error
|
2023-05-01 05:47:12 +02:00
|
|
|
|
2023-05-01 20:26:40 +02:00
|
|
|
message "generate isolinux.cfg"
|
|
|
|
sed "s/%VERSION%/${VERSION}/g" templates/isolinux.tpl.cfg > build/staging/isolinux/isolinux.cfg
|
2023-05-01 05:47:12 +02:00
|
|
|
|
2023-05-01 20:26:40 +02:00
|
|
|
message "generate grub.cfg"
|
|
|
|
sed "s/%VERSION%/${VERSION}/g" templates/grub.tpl.cfg > build/staging/boot/grub/grub.cfg
|
|
|
|
sed "s/%VERSION%/${VERSION}/g" templates/grub.tpl.cfg > build/staging/EFI/BOOT/grub.cfg
|
2023-05-01 05:47:12 +02:00
|
|
|
|
2023-05-01 20:26:40 +02:00
|
|
|
message "copy grub-embed.cfg"
|
|
|
|
cp templates/grub-embed.tpl.cfg build/tmp/grub-embed.cfg
|
2023-05-01 05:47:12 +02:00
|
|
|
|
2023-05-01 06:44:45 +02:00
|
|
|
message "copy isolinux"
|
2023-05-01 05:47:12 +02:00
|
|
|
cp /usr/lib/ISOLINUX/isolinux.bin "build/staging/isolinux/" || error
|
|
|
|
cp /usr/lib/syslinux/modules/bios/* "build/staging/isolinux/" || error
|
|
|
|
|
2023-05-01 06:44:45 +02:00
|
|
|
message "copy grub-efi"
|
2023-05-01 16:53:31 +02:00
|
|
|
cp -r /usr/lib/grub/x86_64-efi/* "build/staging/boot/grub/x86_64-efi/" || error
|
2023-05-01 05:47:12 +02:00
|
|
|
|
2023-05-01 06:44:45 +02:00
|
|
|
message "make efi images"
|
2023-05-01 05:47:12 +02:00
|
|
|
grub-mkstandalone -O i386-efi \
|
|
|
|
--modules="part_gpt part_msdos fat iso9660" \
|
|
|
|
--locales="" \
|
|
|
|
--themes="" \
|
|
|
|
--fonts="" \
|
|
|
|
--output="build/staging/EFI/BOOT/BOOTIA32.EFI" \
|
2023-05-01 16:53:31 +02:00
|
|
|
"boot/grub/grub.cfg=build/tmp/grub-embed.cfg" || error
|
2023-05-01 05:47:12 +02:00
|
|
|
|
|
|
|
grub-mkstandalone -O x86_64-efi \
|
|
|
|
--modules="part_gpt part_msdos fat iso9660" \
|
|
|
|
--locales="" \
|
|
|
|
--themes="" \
|
|
|
|
--fonts="" \
|
|
|
|
--output="build/staging/EFI/BOOT/BOOTx64.EFI" \
|
2023-05-01 16:53:31 +02:00
|
|
|
"boot/grub/grub.cfg=build/tmp/grub-embed.cfg" || error
|
2023-05-01 05:47:12 +02:00
|
|
|
|
|
|
|
(cd build/staging && \
|
|
|
|
dd if=/dev/zero of=efiboot.img bs=1M count=20 && \
|
2023-06-14 12:34:06 +02:00
|
|
|
/usr/sbin/mkfs.vfat efiboot.img && \
|
2023-05-01 05:47:12 +02:00
|
|
|
mmd -i efiboot.img ::/EFI ::/EFI/BOOT && \
|
|
|
|
mcopy -vi efiboot.img \
|
2023-05-01 16:53:31 +02:00
|
|
|
../../build/staging/EFI/BOOT/BOOTIA32.EFI \
|
|
|
|
../../build/staging/EFI/BOOT/BOOTx64.EFI \
|
|
|
|
../../build/staging/boot/grub/grub.cfg \
|
2023-05-01 05:47:12 +02:00
|
|
|
::/EFI/BOOT/
|
2023-05-01 16:53:31 +02:00
|
|
|
) || error
|
2023-05-01 05:47:12 +02:00
|
|
|
|
2023-05-01 06:44:45 +02:00
|
|
|
message "generate .iso"
|
2023-05-01 05:47:12 +02:00
|
|
|
xorriso \
|
|
|
|
-as mkisofs \
|
|
|
|
-iso-level 3 \
|
2023-05-01 10:46:32 +02:00
|
|
|
-o "build/nanodesk_$VERSION.iso" \
|
2023-05-01 05:47:12 +02:00
|
|
|
-full-iso9660-filenames \
|
|
|
|
-volid "NANODESK" \
|
|
|
|
--mbr-force-bootable -partition_offset 16 \
|
|
|
|
-joliet -joliet-long -rational-rock \
|
|
|
|
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
|
|
|
|
-eltorito-boot \
|
|
|
|
isolinux/isolinux.bin \
|
|
|
|
-no-emul-boot \
|
|
|
|
-boot-load-size 4 \
|
|
|
|
-boot-info-table \
|
|
|
|
--eltorito-catalog isolinux/isolinux.cat \
|
|
|
|
-eltorito-alt-boot \
|
|
|
|
-e --interval:appended_partition_2:all:: \
|
|
|
|
-no-emul-boot \
|
|
|
|
-isohybrid-gpt-basdat \
|
|
|
|
-append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B build/staging/efiboot.img \
|
|
|
|
"build/staging"
|