launching sshd at boot time - Bushmills/Anycubic-Kobra-3-rooted GitHub Wiki

System init, when reaching the end of starting the system, checks for presence of a script outside the squashfs file, and executes it when found. This is a convenient place to hook up own actions.

Name and location of the script is /userdata/app/gk/start.sh

I have added code to the script which checks for presence of a specific thumbdrive, then mounts it, if found, and additional startup scripts executed from this thumbdrive, if existing. In addition does the thumbdrive serve to extend internal flash capacity for storing gcode files.

No lsblk executable exists, but a blkid does. Regrettably does this only appear to produce UUIDs of FAT formatted thumb drives. As the currently inserted thumbdrive is ext4 formatted, is it not visible to blkid, and properly identifying the drive using blkid is not an option. Therefore, for now I only check for presence of a device file corresponding to the partition of the thumbdrive, and a more reliable method is needed.

This currently looks like this, as addition to the end of /userdata/app/gk/start.sh:

# 2024jul1 ls custom
mp="/mnt/udisk"

# part="$(blkid | awk '/6d0bd8cd-05da-4596-b1ba-ae4a2b067871/ { print $1 }')" # my thumbdrive present?
[ -b /dev/sda1 ] && part="/dev/sda1:" # current workaround for blkid ignoring ext4 volumes

if [ -n "$part" ]; then
mount "${part%:}" "$mp"
if [ -x "$mp/userinit.sh" ]; then
cd "$mp"
./userinit.sh
fi
fi

The file userinit.sh stored on my thumb drive in turn launches the ssh server on Kobra 3. This was chosen so I can prevent launch of ssh start by simply removing the thumb drive. Additionally can I customize printer boot action right there in that file on thumb drive, rather than having to change printer resident launch scripts again.

Contents of userinit.sh are:
#! ??? # sorry, incomplete now.
# I forgot what path to use for the hashbang, will have to supply later
# it ought to be identical to the first line of /userdata/app/gk/start.sh
/ac_lib/lib/openssh/sshd_start

Set execute permission of userinit.sh (You'll probably want to do that already when creating and writing userinit.sh to thumb drive):
chmod +x userinit.sh