]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/pclos/ventoy-hook.sh
2 #************************************************************************************
3 # Copyright (c) 2020, longpanda <admin@ventoy.net>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #************************************************************************************
20 .
$VTOY_PATH/hook
/ventoy
-os-lib.sh
22 # Step 1: dd initrd file to ramdisk
23 vtRamdiskFile
=$($BUSYBOX_PATH/ls /initrd* | $HEAD -n1)
24 $BUSYBOX_PATH/mknod
-m 0666 /ram0 b
1 0
25 $BUSYBOX_PATH/dd if=$vtRamdiskFile of
=/ram0 status
=none
26 $BUSYBOX_PATH/rm -f $vtRamdiskFile
28 # Step 2: mount ramdisk
29 $BUSYBOX_PATH/mkdir -p /ventoy_rdroot
31 $BUSYBOX_PATH/mount
/ram0
/ventoy_rdroot
34 # Step 3: Copy ventoy tool to new root directory.
35 # Here we make a tmpfs mount to avoid ramdisk out of space (additional space is for log).
36 vtSize
=$($BUSYBOX_PATH/du -m -s $VTOY_PATH | $BUSYBOX_PATH/awk '{print $1}')
39 $BUSYBOX_PATH/mkdir -p /ventoy_rdroot
/ventoy
40 $BUSYBOX_PATH/mount
-t tmpfs
-o size
=${vtSize}m tmpfs
/ventoy_rdroot
/ventoy
41 $BUSYBOX_PATH/cp -a /ventoy
/* /ventoy_rdroot
/ventoy
/
44 # Step 4: add hook in linuxrc&rc.sysinit script file
45 vtLine
=$($GREP -n "^find_cdrom" /ventoy_rdroot/linuxrc | $GREP -v '(' | $AWK -F: '{print $1}')
46 $SED "$vtLine aif test -d /ventoy; then $BUSYBOX_PATH/sh $VTOY_PATH/hook/pclos/disk_hook.sh; fi" -i /ventoy_rdroot
/linuxrc
47 $SED "$vtLine aif test -d /initrd/ventoy; then ln -s /initrd/ventoy /ventoy; fi" -i /ventoy_rdroot
/linuxrc
50 vtRcInit
=$($BUSYBOX_PATH/tail /ventoy_rdroot/linuxrc | $GREP 'exec ' | $AWK '{print $2}')
51 if [ -e /ventoy_rdroot
$vtRcInit ]; then
52 vtRcInit
=/ventoy_rdroot
$vtRcInit
54 vtRcInit
=/ventoy_rdroot
/etc
/rc.d
/rc.sysinit
57 echo 'exec /sbin/init' >> $vtRcInit