Files
kali-arm/banana-pro.sh

88 lines
2.7 KiB
Bash
Raw Permalink Normal View History

2021-09-16 06:42:05 +01:00
#!/usr/bin/env bash
#
# Kali Linux ARM build-script for Banana Pro (32-bit)
2021-10-12 22:10:32 +01:00
# Source: https://gitlab.com/kalilinux/build-scripts/kali-arm
2021-09-16 06:42:05 +01:00
#
2021-10-12 22:10:32 +01:00
# This is a supported device - which you can find pre-generated images on: https://www.kali.org/get-kali/
2021-09-16 06:42:05 +01:00
# More information: https://www.kali.org/docs/arm/banana-pro/
#
2021-08-30 15:08:40 -05:00
# Hardware model
hw_model=${hw_model:-"banana-pro"}
2022-08-22 20:23:41 +03:00
2020-07-21 13:55:32 -05:00
# Architecture
architecture=${architecture:-"armhf"}
2022-08-22 20:23:41 +03:00
2021-08-30 15:08:40 -05:00
# Desktop manager (xfce, gnome, i3, kde, lxde, mate, e17 or none)
desktop=${desktop:-"xfce"}
# Load default base_image configs
source ./common.d/base_image.sh
2021-08-30 15:08:40 -05:00
# Network configs
2021-11-06 15:45:57 +01:00
basic_network
2021-08-30 15:08:40 -05:00
add_interface eth0
2020-07-21 13:55:32 -05:00
# Third stage
2022-08-22 20:23:41 +03:00
cat <<EOF >>"${work_dir}"/third-stage
status_stage3 'Copy rpi services'
2021-08-30 15:08:40 -05:00
cp -p /bsp/services/rpi/*.service /etc/systemd/system/
2021-09-19 10:56:45 +01:00
status_stage3 'Install the kernel packages'
2021-08-30 15:08:40 -05:00
eatmydata apt-get install -y linux-image-armmp u-boot-menu u-boot-sunxi
2018-07-06 18:03:37 -05:00
status_stage3 'Enable login over serial (No password)'
2021-08-30 15:08:40 -05:00
echo "T0:23:respawn:/sbin/agetty -L ttyAMA0 115200 vt100" >> /etc/inittab
2016-03-18 00:22:30 -05:00
EOF
2020-07-21 13:55:32 -05:00
# Run third stage
include third_stage
2016-03-18 00:22:30 -05:00
2020-07-21 13:55:32 -05:00
# Clean system
2021-08-30 15:08:40 -05:00
include clean_system
2021-09-16 06:58:38 +01:00
# Calculate the space to create the image and create
2021-08-30 15:08:40 -05:00
make_image
2016-03-18 00:22:30 -05:00
# Create the disk partitions
2021-09-19 10:56:45 +01:00
status "Create the disk partitions"
2021-09-19 13:45:29 +01:00
parted -s "${image_dir}/${image_name}.img" mklabel msdos
parted -s -a minimal "${image_dir}/${image_name}.img" mkpart primary "$fstype" 4MiB 100%
2018-07-06 18:03:37 -05:00
# Set the partition variables
2021-11-07 10:55:31 +01:00
make_loop
2022-08-22 20:23:41 +03:00
2021-11-04 15:13:16 +01:00
# Create file systems
2021-11-06 14:00:40 +01:00
mkfs_partitions
2022-08-22 20:23:41 +03:00
2021-11-04 15:13:16 +01:00
# Make fstab.
make_fstab
2018-07-06 18:03:37 -05:00
# Create the dirs for the partitions and mount them
2021-09-19 10:56:45 +01:00
status "Create the dirs for the partitions and mount them"
mkdir -p "${base_dir}"/root
mount ${rootp} "${base_dir}"/root
2018-07-06 18:03:37 -05:00
2021-09-24 15:26:15 -05:00
status "Edit the extlinux.conf file to set root uuid and proper name"
2022-08-22 20:23:41 +03:00
# Ensure we don't have root=/dev/sda3 in the extlinux.conf which comes from running u-boot-menu in a cross chroot
# We do this down here because we don't know the UUID until after the image is created
2021-11-04 15:13:16 +01:00
sed -i -e "0,/root=.*/s//root=UUID=$root_uuid rootfstype=$fstype console=tty1 consoleblank=0 ro rootwait/g" ${work_dir}/boot/extlinux/extlinux.conf
2022-08-22 20:23:41 +03:00
2021-09-24 15:26:15 -05:00
# And we remove the "GNU/Linux because we don't use it
sed -i -e "s|.*GNU/Linux Rolling|menu label Kali Linux|g" ${work_dir}/boot/extlinux/extlinux.conf
status "Set the default options in /etc/default/u-boot"
2022-08-22 20:23:41 +03:00
echo 'U_BOOT_MENU_LABEL="Kali Linux"' >>${work_dir}/etc/default/u-boot
echo 'U_BOOT_PARAMETERS="console=tty1 consoleblank=0 ro rootwait"' >>${work_dir}/etc/default/u-boot
2021-09-19 10:56:45 +01:00
status "Rsyncing rootfs into image file"
rsync -HPavz -q ${work_dir}/ ${base_dir}/root/
2018-07-06 18:03:37 -05:00
sync
status "dd to ${loopdevice} (u-boot bootloader)"
2020-07-21 13:55:32 -05:00
dd if=${work_dir}/usr/lib/u-boot/Bananapro/u-boot-sunxi-with-spl.bin of=${loopdevice} bs=1024 seek=8
2016-03-18 00:22:30 -05:00
# Load default finish_image configs
include finish_image