]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/sbin/init
update
[Ventoy.git] / IMG / cpio / sbin / init
1 #!/ventoy/busybox/ash
2 #************************************************************************************
3 # Copyright (c) 2020, longpanda <admin@ventoy.net>
4 #
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.
9 #
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.
14 #
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/>.
17 #
18 #************************************************************************************
19
20 ####################################################################
21 # #
22 # Step 1 : extract busybox & set busybox enviroment #
23 # #
24 ####################################################################
25
26 export VTOY_ORG_PATH=$PATH
27 export VTOY_PATH=/ventoy
28 export BUSYBOX_PATH=$VTOY_PATH/busybox
29 export VTLOG=$VTOY_PATH/log
30 export FIND=$BUSYBOX_PATH/find
31 export GREP=$BUSYBOX_PATH/grep
32 export EGREP=$BUSYBOX_PATH/egrep
33 export CAT=$BUSYBOX_PATH/cat
34 export AWK=$BUSYBOX_PATH/awk
35 export SED=$BUSYBOX_PATH/sed
36 export SLEEP=$BUSYBOX_PATH/sleep
37 export HEAD=$BUSYBOX_PATH/head
38
39 if [ -e $BUSYBOX_PATH/64h ]; then
40 $BUSYBOX_PATH/xzminidec32 < $BUSYBOX_PATH/busybox32.xz > $BUSYBOX_PATH/busybox
41 $BUSYBOX_PATH/vtchmod32 $BUSYBOX_PATH/busybox
42 else
43 $BUSYBOX_PATH/xzminidec64 < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
44 $BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
45 fi
46
47 $BUSYBOX_PATH/busybox --install $BUSYBOX_PATH
48
49 export PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool
50
51 export VTOY_BREAK_LEVEL=$(hexdump -n 1 -s 449 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
52 export VTOY_DEBUG_LEVEL=$(hexdump -n 1 -s 450 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
53
54 #Fixme: busybox shell output redirect seems to have some bug in rhel5
55 if uname -a | grep -q el5; then
56 VTOY_REDT_BUG=YES
57 fi
58
59 if [ -z "$VTOY_REDT_BUG" ]; then
60 echo "============== VENTOY =================" >>$VTLOG
61 fi
62
63 cd $VTOY_PATH
64 xz -d ventoy_chain.sh.xz
65 xz -d ventoy_loop.sh.xz
66
67 if [ -n "$VTOY_REDT_BUG" ]; then
68 xz -d -c hook.cpio.xz | cpio -idm
69 xz -d -c tool.cpio.xz | cpio -idm
70 xz -d -c loop.cpio.xz | cpio -idm
71 else
72 xz -d -c hook.cpio.xz | cpio -idm 2>>$VTLOG
73 xz -d -c tool.cpio.xz | cpio -idm 2>>$VTLOG
74 xz -d -c loop.cpio.xz | cpio -idm 2>>$VTLOG
75 fi
76
77 if [ -e $BUSYBOX_PATH/64h ]; then
78 echo "Use busybox32 toolkit ..." >>$VTLOG
79 ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec
80 ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
81 else
82 echo "Use busybox64 toolkit ..." >>$VTLOG
83 ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec
84 ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup
85 fi
86
87 rm -f *.xz
88 cd /
89
90 ####################################################################
91 # #
92 # Step 2 : Hand over to ventoy init #
93 # #
94 ####################################################################
95 exec $BUSYBOX_PATH/sh $VTOY_PATH/init