diff options
Diffstat (limited to 'utils/mkiso.d')
| -rw-r--r-- | utils/mkiso.d/include/etc/issue | 21 | ||||
| -rw-r--r-- | utils/mkiso.d/include/etc/skel/.profile | 9 | ||||
| -rw-r--r-- | utils/mkiso.d/init | 96 | ||||
| -rw-r--r-- | utils/mkiso.d/live_script.sh | 26 |
4 files changed, 152 insertions, 0 deletions
diff --git a/utils/mkiso.d/include/etc/issue b/utils/mkiso.d/include/etc/issue new file mode 100644 index 00000000..e8f879f5 --- /dev/null +++ b/utils/mkiso.d/include/etc/issue @@ -0,0 +1,21 @@ +Alice Linux \r (\l) + +Project page : https://codeberg.org/emmett1/alicelinux + +user login : live +user password: live + +root login : root +root password: root + +run 'sway' after login to start gui + +Some default sway keybindsym reminder: + + Super + Enter : foot terminal + Super + d : menu launcher + Super + Shift + q : quit program + Super + Shift + e : exit sway + +run 'doas poweroff' to poweroff live system + diff --git a/utils/mkiso.d/include/etc/skel/.profile b/utils/mkiso.d/include/etc/skel/.profile new file mode 100644 index 00000000..e425b03b --- /dev/null +++ b/utils/mkiso.d/include/etc/skel/.profile @@ -0,0 +1,9 @@ +# ~/.profile + +export ENV=~/.ashrc + +if [ -z "$XDG_RUNTIME_DIR" ]; then + XDG_RUNTIME_DIR="/tmp/$(id -u)-runtime-dir" + mkdir -pm 0700 "$XDG_RUNTIME_DIR" + export XDG_RUNTIME_DIR +fi diff --git a/utils/mkiso.d/init b/utils/mkiso.d/init new file mode 100644 index 00000000..05356e39 --- /dev/null +++ b/utils/mkiso.d/init @@ -0,0 +1,96 @@ +#!/bin/busybox sh + +NEWROOT=/.newroot +INITRAMFS=/run/initramfs +MEDIA=$INITRAMFS/media +LOWER=$INITRAMFS/lower +UPPER=$INITRAMFS/upper +WORK=$INITRAMFS/work +SFSIMAGE=$MEDIA/boot/rootfs.sfs + +/bin/busybox --install -s /bin + +clear + +mkdir -p /proc /sys /run /dev +mount -t proc proc /proc +mount -t sysfs sysfs /sys +mount -t tmpfs run /run +mount -t devtmpfs dev /dev + +mkdir -p $LOWER $MEDIA $UPPER $WORK $NEWROOT + +exec >/dev/console </dev/console 2>&1 + +PRINTK="`cat /proc/sys/kernel/printk`" +echo "0" > /proc/sys/kernel/printk + +# mdev +mkdir -p /etc +echo '$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' > /etc/mdev.conf +mdev -df & pid_mdev=$! + +# load kernel modules, twice +find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a >/dev/null 2>&1 +find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a >/dev/null 2>&1 + +# load kernel modules required for live iso +for m in loop cdrom isofs overlay squashfs usb-storage loop fuse exfat; do + modprobe $m >/dev/null 2>&1 +done + +echo "Please wait..." + +# figure out media +if [ -f /proc/sys/dev/cdrom/info ]; then + CDROM=$(grep name /proc/sys/dev/cdrom/info | awk -F : '{print $2}' | awk '{print $1}') +fi + +while [ "$wait" != 10 ]; do + BLOCK=$(grep -E '[vsh]d' /proc/partitions | awk '{print $4}') + for i in $CDROM $BLOCK; do + mount -v -r /dev/$i $MEDIA >/dev/null 2>&1 || continue + [ -f $MEDIA/boot/livemedia ] || { umount $MEDIA; continue; } + MEDIAFOUND=1 + break 2 + done + wait=$(( wait + 1 )) + sleep 1 +done + +if [ ! "$MEDIAFOUND" ]; then + echo "Media not found even after 10 seconds" + sh + echo "Cannot go further" + sleep 99999 + exit 1 +fi + +# mount stuffs +loopdevice=$(losetup -f) +losetup -f $SFSIMAGE +mount -r $loopdevice $LOWER +mount -t overlay overlay -o lowerdir=$LOWER,upperdir=$UPPER,workdir=$WORK $NEWROOT +if [ -f $MEDIA/boot/rootfs.gz ]; then + tar -xzaf $MEDIA/boot/rootfs.gz -C $NEWROOT +fi + +kill $pid_mdev + +mount --move /sys $NEWROOT/sys +mount --move /proc $NEWROOT/proc +mount --move /dev $NEWROOT/dev +mount --move /run $NEWROOT/run + +# execute live script if exist +if [ -f $NEWROOT/$MEDIA/boot/live_script.sh ]; then + chroot $NEWROOT sh $MEDIA/boot/live_script.sh +fi + +# switch to newroot +clear +exec /bin/switch_root $NEWROOT /sbin/init + +echo "This is the end of initramfs" +echo "Nothing further, here's the shell" +/bin/busybox sh diff --git a/utils/mkiso.d/live_script.sh b/utils/mkiso.d/live_script.sh new file mode 100644 index 00000000..bb470dc1 --- /dev/null +++ b/utils/mkiso.d/live_script.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +LIVEUSER=live +PASSWORD=live +LIVEHOSTNAME=alicelive + +adduser -D $LIVEUSER +for g in users wheel audio video input; do + addgroup $LIVEUSER $g +done + +passwd -d $LIVEUSER >/dev/null 2>&1 +passwd -d root >/dev/null 2>&1 + +echo "root:root" | chpasswd -c SHA512 +echo "$LIVEUSER:$PASSWORD" | chpasswd -c SHA512 + +for sv in tty1 tty2 tty3 seatd; do + [ -d /etc/sv/$sv ] && ln -s /etc/sv/$sv /var/service +done + +echo $LIVEHOSTNAME > /etc/hostname + +if [ -f /etc/doas.conf ]; then + echo "permit nopass $LIVEUSER" >> /etc/doas.conf +fi |