ventoy-hook.sh 2.43 KB
Newer Older
longpanda's avatar
longpanda committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
# 
#************************************************************************************

. $VTOY_PATH/hook/ventoy-os-lib.sh

longpanda's avatar
longpanda committed
22
23
#ventoy_systemd_udevd_work_around
#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
longpanda's avatar
longpanda committed
24

longpanda's avatar
longpanda committed
25
26
27
28
29
30
31
32
33
if [ -f $VTOY_PATH/autoinstall ]; then
    VTKS="inst.ks=file:$VTOY_PATH/autoinstall"
else
    for vtParam in $($CAT /proc/cmdline); do
        if echo $vtParam | $GREP -q 'inst.ks=hd:LABEL='; then
            vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}')
            VTKS="inst.ks=hd:/dev/dm-0:$vtRawKs"
            break
        fi
longpanda's avatar
longpanda committed
34
35
36
37
38
39
40
        
        if echo $vtParam | $GREP -q '^ks=.*:/'; then
            vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}')
            VTKS="ks=hd:/dev/dm-0:$vtRawKs"
            break
        fi
    done
longpanda's avatar
longpanda committed
41
42
43
44
fi

echo "VTKS=$VTKS" >> $VTLOG

longpanda's avatar
longpanda committed
45
if $GREP -q 'root=live' /proc/cmdline; then
longpanda's avatar
longpanda committed
46
    $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS#" -i /lib/dracut-lib.sh
longpanda's avatar
longpanda committed
47
else
longpanda's avatar
longpanda committed
48
    $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS#" -i /lib/dracut-lib.sh
longpanda's avatar
longpanda committed
49
50
fi

longpanda's avatar
longpanda committed
51
52
ventoy_set_inotify_script  rhel7/ventoy-inotifyd-hook.sh

longpanda's avatar
longpanda committed
53
54
55
56
57
58
59
60
61
#Fedora
if $BUSYBOX_PATH/which dmsquash-live-root > /dev/null; then
    vtPriority=99
else
    vtPriority=01
fi

$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
longpanda's avatar
longpanda committed
62

longpanda's avatar
longpanda committed
63
64
65
66
# suppress write protected mount warning
if [ -e /usr/sbin/anaconda-diskroot ]; then
    $SED  's/^mount $dev $repodir/mount -oro $dev $repodir/' -i /usr/sbin/anaconda-diskroot
fi
longpanda's avatar
longpanda committed
67