PK!Sdracut-init.shnuȯ#!/bin/bash # # functions used by dracut and other tools. # # Copyright 2005-2009 Red Hat, Inc. All rights reserved. # # 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 2 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 . # export LC_MESSAGES=C if [[ $DRACUT_KERNEL_LAZY ]] && ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then if ! [[ -d "$initdir/.kernelmodseen" ]]; then mkdir -p "$initdir/.kernelmodseen" fi DRACUT_KERNEL_LAZY_HASHDIR="$initdir/.kernelmodseen" fi if [[ $initdir ]] && ! [[ -d $initdir ]]; then mkdir -p "$initdir" fi [[ $dracutbasedir ]] || export dracutbasedir=${BASH_SOURCE%/*} . $dracutbasedir/dracut-functions.sh PK!2HHdracut-installnuȯELF>@@@8 @@@@@@00pp@p@@@22 `` ``@@DD``Ptdnn@n@QtdRtd``/lib64/ld-linux-x86-64.so.2GNU GNU H"w@ l= @ =>@/PvbA2Z[Kv*69/* kqELdLb#>R\z! -@_ `! `o@`H`libgcc_s.so.1__gmon_start___Unwind_Resume__gcc_personality_v0libc.so.6__xpg_basenamestrcpy__printf_chkoptind__strdup__open64_2putsforkfutimes__stack_chk_failunlinkmkdirabort_exitpopengetpidisattyfeofsymlinkexeclpcallocstrlendirnamewritevstrstr__errno_locationopen64readmemcmpstrndupfchownmemcpy__vsnprintf_chkstrtoulmallocumaskrealpath__lxstat64__xstat64__ctype_b_locgetenvoptargioctl__snprintf_chkgetopt_longpcloseusleep__getdelimwaitpidstrchrprogram_invocation_short_namesyscallstrcmpstrerror__asprintf_chk__libc_start_mainstpcpysysconffree__prognameGCC_3.0GCC_3.3.1GLIBC_2.7GLIBC_2.14GLIBC_2.8GLIBC_2.4GLIBC_2.3GLIBC_2.3.4GLIBC_2.2.5  0P&y ja_& rBii |ii ii ii ti ui `% `>@`@H`A` `(`0`8`@`H`P`X` `` h` p` x` `````````Ȑ`А`ؐ```````` `! `"(`#0`$8`%@`&H`'P`(X`)``=h`*p`+x`,`-`.`/`0`1`2`3`4`5ȑ`6Б`7ؑ`8`9`:`;`<HH| Ht[H5| %| @%| h%| h%| h%z| h%r| h%j| h%b| h%Z| hp%R| h`%J| h P%B| h @%:| h 0%2| h %*| h %"| h%| h%| h% | h%| h%{ h%{ h%{ h%{ h%{ hp%{ h`%{ hP%{ h@%{ h0%{ h %{ h%{ h%{ h%{ h %{ h!%{ h"%z{ h#%r{ h$%j{ h%%b{ h&%Z{ h'p%R{ h(`%J{ h)P%B{ h*@%:{ h+0%2{ h, %*{ h-%"{ h.%{ h/%{ h0% { h1%{ h2%z h3%z h4%z h5%z h6%z h7p%z h8`%z h9P%z h:@%z h;0%z h< P g@}$c@e@9fDAWAVAUATUSHHE1g@e@HމFh6@.RDNDHfz 뤐vElfomz xDatf@Bg@u$c@14L+/LHLkVHIIAJf@Bg@z$c@14 w w ALLA6MA^f@Bg@}$c@184 L Auf@Bg@$c@14I/J,J\HH0 xv uv AHHAE=Pv H,$IAb@*g@h$c@1z3=v EfH(H=u ,Hu DHH=u +HuH=u $H=u $H=u AAJH=qu D)1l$HN411HLyRMM,H=;u L#&HtLHSt$LH=u HHU$LH9\$M$A+f@g@$c@1M52H5t LvHdMcAf@@i@$c@11MAb@@i@$c@1f1=DHGHIIAf@*g@Z$c@1H,$s1 t  t AHLAt LH,$MAf@*g@]$c@11HLH3Axb@@i@A@b@@i@1I^HHPTIP[@HZ@Hp@f.`UH-`HHw]øHt]``UH-`HHHH?HHu]úHt]Hƿ`=r uUH~]r @H=Hn tHtU`H]{sH)r Sp[@1IH?HSHt9BHt.HPfDHHt|/HJHu</tH[1[f.AVAUIc@ATUSHdH%(H$1HD$HIaHTHIIALc@6g@-$c@1.LUHt:u fDt H:uAtE1H|$1MHTc@Ht$HT$ HktHLL$AZc@6g@B$c@1B.H|$EHD$F19fH\$Ht-H$MAhc@6g@M$c@1-H\$LH$dH3 %(Hu;H[]A\A]A^Ac@6g@"$c@1-KA=c@6g@;$c@1j-HL-HA=c@6g@)$c@14-fAVAUIATUSHHH0@dH%(H$(@1HD$7HHH31DHIHIHL]IVH9LDv$A8/t|/uHH9LDwH|$1LTc@LD$D$ A8@IP1HIHZHIHIH;LHI H1H¾L6H.HD|$1Yf\$H|$0HtH%H|$ HL$8dH3 %(HH[]A\A]A^A_fDIA*d@Pg@$c@1%KIA*d@Pg@$c@1%NIA*d@Pg@=$c@n%fMA*d@Pg@5$c@1<%E1E1E1fH|$1Ax_Ht$ BHD$ 8#ƀtUD)IA{c@g@v$c@1$\$hH|$0agx!uHXHhHHH]DY uHUtsHDHHtDQ tIAc@g@Z$c@1$E11HHA1ۅAD(d@ATUHSHH8dH%(H$(1H4$$c@HD$@N"H=d HHtHHEt'H=d HHtHHHT$pH޿D$ HHH=Td HHH Jd H|$@1Iqd@)Ht$@HT$pEt$ULL$@Ad@g@$c@1/!E1E1LH|$@H$(dH3 %(DcH8[]A\A]A^A_ED$ HH=Sc HH`fD8HD$(tYLL$@Avd@g@ $c@1 #IAxa@g@$c@^ E1A'H|$@HIH$ALD$4E|$ $%=@=&ItE=vb DL$4Ae@g@r$c@1HD$@IA,e@g@s$c@H$1x=a Hl$@D$H&H$H޿9 $%=H1A$H1AuD1 @D$Hr$$DvDH$Ht$PDHD$XHD$hHD$PH$HD$`%D\$H#D#Dl$4Ae@g@v$c@1AE4IAYd@g@$c@ILL$@Aa@g@f$c@1H+AE11HHItAAE1HHMAd@g@L$c@1mAL/1DHJDt_ ["sAuHD$(8Ht$H1DxDL$HAxe@`g@$c@1\$HpHD$(M8Avd@g@#$c@1HD$8H|$8AUWEmLL$@Ad@g@6$c@1QH|$@rAH,$IAa@`g@$c@1D$H E1AAd@g@'$c@1HHHHD$8H|$8A1ɺHD$4MAa@g@0$c@1jLL$@Ad@g@>$c@1?$H|$@@΀ZA1HHuEHhD$4'HT$pLAt;MAd@g@Q$c@1PH|$8Ht$@HT$pu,=1] 1HH D/H \ H|$H1Mqd@HD$H3HD$@H|$HHHD$ IHD$ Ad@Mg@$c@H$1Ht$ Lt-HD$ MAd@g@$c@H$1LyH|$HoUA=c@g@$c@1tj$DE1LHD$ H|$@ HD$ H\LHH|$HLHHA=c@g@Z$c@1i눐f.xf.hf.Xf.HHD$8H|$8HD$ SHD$ )H\f.f.ue@HD$Hl$HH$A9e@A=e@Xe@fe@1 HADEDHAHHHHfVfAWAVIAUIATUSHH8dH%(HD$(1LIMHHD$HD$ HHe@HIjMLJ\;C<WH|$DI1Le@vH|$ 1ILe@R{HD$ LL$Ae@cg@$c@H$1Ht$ H|$A11H|$ 16H|$,H$LHL$(dH3 %(H8[]A\A]A^A_e@LHpe@LH`e@LHPe@LH@LJ\;C<H|$DI1Le@=H|$ 1IHe@A=c@cg@$c@1`VfD1A=c@cg@$c@1A=c@cg@$c@1H|$ HH|$HLHA=c@cg@$c@1D@f.1H9CDf.HHHHF HN(HtEHH(HN(HtHHA HFHtHNHHHNHt2HAG t0G H@HHOuHGfHD(ɹ1j@Ei@Yi@.1j@Ei@m@1j@Ei@Wi@ff.HHHHD(HHFHVHHtHrH0HGHF HHF(t HtqHp G HwtHfDHujHw޹j@Ei@Yi@Zj@Ei@m@Aj@Ei@Wi@(j@Ei@li@j@Ei@ki@fDUSHHHHt P H9sJH։H HDH[]1ɍ, Ht$@Ht$HCHH|H1H!HGHH|HtHHt$h@ HH11ATHUHStd~wFIH\(Hu.fDH[HtLH;UuH[]A\f.[]1A\ùj@+Ei@i@j@*Ei@Wi@UHSHHHHtdH>UHHiH )))Hމ}$tHS HS HH[]@HH[]>j@Ei@m@)>j@Ei@Wi@t@Hu;f.ATIUHSHS H7HHR HA @@D1AHu~Au`AuRf.M0;@B IEHHBH @;@HBHE͈Z$HHJ[]A\1HfGAtfDHAtf HHe1띐HzA1HAfO DAHD `qHH1:@f.HSHt(1H?t[DHHMHH[ùPj@Ei@Wi@fDHSHuDHHsHu[f.HSHt{$tHP HP H[fH[AUATUHSHHIHIUÉHHiH )L))ȉƉHt!1L9hEH[]A\A]fD}$tBH5CP HtOHH4P L&LnHH[]A\A]f0HHu댾0`H%j@8Ei@Wi@zf.ATHUSHtfHHIHiH )H))H߉HtH(L`1[]A\HHL[]A\~j@XEi@Wi@ DUSHHHtRHHAHHiHH A)ADAAA)D)DHtH@H[]@1ff.USHHHtbHHAHHiHH A)ADAAA)D)HtHhHHPHH[]fD1ff.AWAVAUATIUSHHHHIIA$ÉHHiLH )))ȉƉFHIt~LA$ʼnLHiH )))LƉHu#LLpM/MwLL<1H[]A\A]A^A_ffAWAVAUATUSHHHIHIIʼnLHiHH )))ȉƉXHILAĉHMiI D)AADD))LAHtI9t HHLHnMuM}DLH81H[]A\A]A^A_fATHUSHtOIHHALHiHH A)ADAAA)D)cHt L`I9t[E1]LA\f.HH[]LA\f.HtnHtFHHt=Ht(Hx HHHEHHtHH H@HGHuHHtH1f.1Pi@Ei@e@ Ht^Ht6HHt.HtHH(HHtHH H@ÐHGHuHHtH1f.1Pi@Ei@e@c ATHUSHtTHHIAHHiHH A)ADAAA)D)HtI$H@[]A\Ð1ff.HtHGHt H@D1DHtHGHt HfD1DHtHGHt H@D1DHtHwHtSH^H[1f.SHf.HHHuH[rfHtHwHtSHYH[@1f.Ht G 1f.Ht G ff.UHSHHtKHt=H^Hu 2fH[ Ht'HSH3HytH[]H1[]ùi@xEi@Wi@N@f.AVHAUATIUSHIt^HnHuSfLH}Lu A$ÉLHiH )))HUƉHtMu[]A\A]A^DH}AULHiH )))HHL먹i@Ei@Wi@Zf.AVHIAUATUSHIIHA$ÉLHiH )))LƉHuZLAʼnLHiH )))LƉfHIt>HƉLLL1[]A\A]A^[]A\1A]A^׹i@Ei@Wi@PUSHHHtFHwH?fHHtHHcxHH[]D1@H@1๐i@Ei@Wi@AUATIUSHdH%(HD$1G xHHItr1HLH$'HtTL1DH1HLHHuHcHID-LHL$dH3 %(uH[]A\A]11fDf.ATUHSH`dH%(HD$X1=vM HDIIALу t tu  tH uHhD%uD ExW1 HHLLD$H$ij@HD$HDHD$HD$ zj@HD$("Hx=HD1Ht$XdH34%(u1H`[]A\f1if؅y뿐Kf.UIտ`1SHH(HL$T$H4$ `HL HK `i@SUC x t [f-C [Df.@f.=B fAUATUSH(dH%(H$1;=B ~(1H$dH3 %(uH([]A\A]HLL$L$:LL$L$H|$D(IHT$HƄ$KE,$DHLL$Ht7)D$P)L$`)T$p)$)$)$)$)$dH%(HD$1H$IHD$HD$ $(D$0HD$HT$dH3%(uH@f.A S1ۅx [t^A [þ|j@qEA x#A8k@l@Kj@1؉Ak@Il@Gj@1@ iff.HAhk@9u=@ Pl@^j@j@fDHAk@Hx$=I Hùl@j@j@l@j@j@ffDHx \1HDH f@ fwHcHm@1DUHSHdH%(HD$1HD$tz1H<m@Ht HtGHH uHt$Hx0T$FHL$dH3 %(uH[]fD߸`l@&j@|c@GH7x|1HDfSj@UHHt HxQj@7HHt Hwx [fIA l@l@[j@1CIAk@l@j@1f.dH%HtQH~ dH%Zù*n@*Hm@m@-f.ATHUSHt^HHt=GHI usr/lib64 `-- usr |-- bin | |-- bash | |-- sh -> bash | `-- tr `-- lib64 |-- ld-2.15.90.so |-- ld-linux-x86-64.so.2 -> ld-2.15.90.so |-- libc-2.15.90.so |-- libc.so |-- libc.so.6 -> libc-2.15.90.so |-- libdl-2.15.90.so |-- libdl.so -> libdl-2.15.90.so |-- libdl.so.2 -> libdl-2.15.90.so |-- libtinfo.so.5 -> libtinfo.so.5.9 `-- libtinfo.so.5.9 convert_abs_rel(): target '%s' directory has no realpath.you do not have execution permissionERROR: failed to install '%s' for '%s'hash hit items_failed for '%s''%s' already exists, but checking for any depsERROR: failed to create directory '%s'Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %sEnvironment DESTROOTDIR or argument -D is not set!Environment DESTROOTDIR or argument -D is set to '/'!Environment DESTROOTDIR or argument -D is set to '%s': %mERROR: installing '%s' to '%s'PATHPATH is not setinstall/dracut-install.cOut of memory!PATH=%s%s/%sstat(%s) != 0find_binary(%s) == %s.soldd %s 2>&1Script install: '%s'ERROR: failed to install '%s'ldd: '%s'not a dynamic executableloader cannot load itselfnot regular filecannot read header=>.so.Lib install: '%s'/dracut_install('%s', '%s')hash hit items for '%s'%s%sERROR: stat '%s': %m'%s' already existsdest dir '%s' does not existmkdir '%s''%s' install errorlstat '%s': %mln -s '%s' '%s'ERROR: ln -s '%s' '%s': %mdracut_install ret = %dcp '%s' '%s'-fL--preserve=mode,timestamps--sparse=auto--reflink=autocpcp ret = %d/lib/fipscheck/lib64/fipscheck/lib/hmaccalc/lib64/hmaccalc%s/%s.hmac%s/.%s.hmachmac cp '%s' '%s')iadhloD:HRNo SOURCE argument givenDESTROOTDIROut of memoryresolve_deps('%s')Handle '%s'dracut_install '%s'dracut_install '%s' OKERROR: installing '%s'dracut_install '%s' '%s'dracut_install '%s' '%s' OKhelpversiondebugverboselddresolvelazyoptionalallfipsdestrootdiritem_freeinstall_onefind_binaryinstall_alllibrary_installcphmac_installconvert_abs_relln_rdracut_installresolve_depsresolve_lazyparse_argvf@hf@g@df@f@vf@lf@Rf@of@af@Hf@Dmaininstall/hashmap.chh->n_entries >= 1!h->iterate_list_headhash < 127hashmap_copyhashmap_move_onehashmap_movehashmap_mergehashmap_iterate_backwardshashmap_iteratehashmap_replacelink_entryhash_scanhashmap_putunlink_entryremove_entryhashmap_ensure_allocateddracut-install: /dev/consoleinstall/log.c(level & 0x07) == leveltarget >= 0target < _LOG_TARGET_MAXDRACUT_LOG_TARGETDRACUT_LOG_LEVELsafenullFailed to open /dev/console for logging: %sSuccessfully opened /dev/console for logging.Assertion '%s' failed at %s:%u, function %s(). Aborting.Code should not be reached '%s' at %s:%u, function %s(). Aborting.Failed to parse log target %s. Ignoring.Failed to parse log level %s. Ignoring.log_target_from_stringlog_parse_environmentlog_set_targetlog_set_max_levellog_open_consolej@ae@j@j@install/util.cpostfixfd >= 0close_nointr(fd) == 0ret_uemergalertcriterrwarningnoticeinfo(r = sysconf(_SC_PAGESIZE)) > 0log_level_from_stringsafe_atouclose_nointr_nofailclose_nointrendswithpage_sizem@m@m@m@m@m@m@f@;QШyp ` Xh`@xp 0@@@0@ P8 h P  ( @ px ` ` 8 x 0  ( Ph P p0 H ` x p @  @phP Xp0``zRx *zRx $FJ w?;*3$"D`(H\xFD} A CzPLRx@ L$.|@BBJ A(A0G 0A(A BBBA Lth@BBE A(A0M 0A(A BBBA T@BBB B(A0A8G 8A0A(B BBBG T@ .@BMJ K(A0D8O 8A0A(B BBBD Lt@BBE E(A0A8GpW 8A0A(B BBBH <ȣALУ@BBB B(A0C8GP 8A0A(B BBBA @8@D_ E De G ,AAG0e AAA 4DPBDD x ABK A ADA 4|ADD ` AAE D DAE  (8,0BDD  ABH $JDN F X A <#D^\9Db J DL|BBA D(D0\ (C ABBG q (F ABDJ <BDA M ABI J ABE , dAAG P AAE ,<8tAAG ^ AAG LlBBB B(D0A8D@ 8C0A(B BBBJ L(BBB B(A0A8G@ 8A0A(B BBBH 4 BDA U DEK LAED0t\}d,tdBDA T ABB PX`h#OM x.Ah,#OLLd4|rADD | AAI D CAA <BEB D(A0m (A BBBF LBHB A(A0 (A BBDH A (A BDDD ,DPmAAG o AAF <tBBD A(D@ (A ABBA 45BAD D  AABJ \AMG@$ XAAU J P H 4 L x<d pBEA A(Gw (A ABBA  G A $ pGI H W A  D *Q D4 JDS A T 0DVl 8 0 (, 0ADD0~ AAG  'DV F $ A} J O Y , HCPY A ,L xBDA F ABA $| MCe H C A , =BAC Z ABA L BED A(I0@ (C ABBA V (C CBBB $ `0aN< xASm4\ BAA G0  AABB  `, hADD0~ AAG BBE E(A0D8DPr 8D0A(B BBBJ H 8G0A(B BBBH D 8K0A(B BBBH D8A0A(B BBB,l h4ADG T GAH 4 xtBDA DpK  AABA D eBEE E(H0H8M@l8A0A(B BBBw 0     8    7            ]l22    1   /  L 5<NCq&S@@B P@ T[@``o@8 @@  ` @8 @` o @oo @`@@@@@@@@@@&@6@F@V@f@v@@@@@@@@@@@&@6@F@V@f@v@@@@@@@@@@@&@6@F@V@f@v@@@@@@@@@@@&@6@F@dracut-install.debugi87zXZִF!t/]?Eh=ڊ̓N OvΚa~~kdO/y A›c'6Q=@_jvF.n!#9vCܖr,y00[qꦕ[O/}FhfkϵMR LQ璭: C E9',z}Cj, 2Pm*yٶӲv L5ͫb}\I%QE BG32(6Y0&^HȘl8?L0Do}ja=،7CmAT7hZj^"$QC6"N'] Ȼ 4?(v: Plh4v'#TTT1r^ZTAcqhOecï#(T˨z10R[^R@ ;<0登(Po+fnr)zDk۫gmr鶶 cuA'-y4nj,Q̅@5]EIz1XXK̺#L{T<ފR͘X@!dV:n8jzow-ݽE3rWZ(I]nYu8ԁ/oEV-_샆x4Adǹu3 Iet(L1L=B^=.UT13<ܱ&ӳLdZzȥ5\ʍ_9R4OK25YSgmJ.:^[҇#ncM,ŭL(-vA5FNJ3 Nknغ\v}ŊJ򧼓vW%"V&4ȕFsD(k%+f4iiR^:w"\#VDQƬi9y"Ww y_2""%Ԏoc8q$fg>S"∭I eM"-=@-SDlA]W!(CbHؠ&N;Ԋcu\X_ngXB e$9X d" {Ưc9j>7A`gYZ.shstrtab.interp.note.ABI-tag.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.text.fini.rodata.eh_frame_hdr.eh_frame.gcc_except_table.tbss.init_array.fini_array.jcr.dynamic.got.got.plt.data.bss.gnu_debuglink.gnu_debugdata p@p@ !@$4o@8> @0F8 @8 No @ [o @ j8 @8 `tB @ ~P@Pyp@pP@PDT[@T[ `[@`[  n@nq@qd|@|```````` ` 4(\%PK!ujM9modules.d/99microcode_ctl-fw_dir_override/module-setup.shnuȯ#!/bin/bash # Hack in additional firmware directories for supported caveats. # # SPDX-License-Identifier: CC0-1.0 check() { return 0 } install() { local FW_DIR=/lib/firmware local DATA_DIR=/usr/share/microcode_ctl/ucode_with_caveats local CFG_DIR="/etc/microcode_ctl/ucode_with_caveats" local check_caveats=/usr/libexec/microcode_ctl/check_caveats local fw_path_para=$(< /sys/module/firmware_class/parameters/path) local verbose_opt local cc_out local path local ignored local do_skip_host_only local p verbose_opt= [ 4 -gt "$stdloglvl" ] || verbose_opt="-v" # HACK: we override external fw_dir variable in order to get # an additional ucode based on the kernel version. dinfo " microcode_ctl module: mangling fw_dir" [ -z "$fw_dir_l" ] || { dinfo " microcode_ctl: avoid touching fw_dir as" \ "it has been changed (fw_dir_l is '$fw_dir_l')" return 0 } # Reset fw_dir to avoid inclusion of kernel-version-specific directories # populated with microcode for the late load, only in case it is set # to the default value to avoid meddling with user-enforced changes. # The second variant has been introduced in dracut-057~5. [ \( "x$fw_dir" != \ "x/lib/firmware/updates /lib/firmware /lib/firmware/$kernel" \) -a \ \( "x$fw_dir" != \ "x${fw_path_para:+$fw_path_para }/lib/firmware/updates/$kernel /lib/firmware/updates /lib/firmware/$kernel /lib/firmware" \) ] || { fw_dir="/lib/firmware/updates /lib/firmware" dinfo " microcode_ctl: reset fw_dir to \"${fw_dir}\"" } fw_dir_add="" while read -d $'\n' -r i; do dinfo " microcode_ctl: processing data directory " \ "\"$DATA_DIR/$i\"..." if [ "x" != "x$hostonly" ]; then do_skip_host_only=0 local sho_overrides=" $CFG_DIR/skip-host-only-check $CFG_DIR/skip-host-only-check-$i $FW_DIR/$kernel/skip-host-only-check $FW_DIR/$kernel/skip-host-only-check-$i" for p in $(echo "$sho_overrides"); do [ -e "$p" ] || continue do_skip_host_only=1 dinfo " microcode_ctl: $i; skipping" \ "Host-Only check, since \"$p\" exists." break done else do_skip_host_only=1 fi match_model_opt="" [ 1 = "$do_skip_host_only" ] || match_model_opt="-m" if ! cc_out=$($check_caveats -e -k "$kernel" -c "$i" \ $verbose_opt $match_model_opt) then dinfo " microcode_ctl: kernel version \"$kernel\"" \ "failed early load check for \"$i\", skipping" continue fi path=$(printf "%s" "$cc_out" | sed -n 's/^paths //p') [ -n "$path" ] || { ignored=$(printf "%s" "$cc_out" | \ sed -n 's/^skip_cfgs //p') if [ -n "$ignored" ]; then dinfo " microcode_ctl: configuration" \ "\"$i\" is ignored" else dinfo " microcode_ctl: no microcode paths" \ "are associated with \"$i\", skipping" fi continue } dinfo " microcode_ctl: $i: caveats check for kernel" \ "version \"$kernel\" passed, adding" \ "\"$DATA_DIR/$i\" to fw_dir variable" if [ 0 -eq "$do_skip_host_only" ]; then fw_dir_add="$DATA_DIR/$i " else fw_dir_add="$DATA_DIR/$i $fw_dir_add" fi # The list of directories is reverse-sorted in order to preserve the # "last wins" policy in case of presence of multiple microcode # revisions. # # In case of hostonly == 0, all microcode revisions will be included, # but since the microcode search is done with the "first wins" policy # by the (early) microcode loading code, the correct microcode revision # still has to be picked. # # Note that dracut without patch [1] puts only the last directory # in the early cpio; we try to address this by putting only the last # matching caveat in the search path, but that workaround works only # for host-only mode; non-host-only mode early cpio generation is still # broken without that patch. # # [1] https://github.com/dracutdevs/dracut/commit/c44d2252bb4b done <<-EOF $(find "$DATA_DIR" -maxdepth 1 -mindepth 1 -type d -printf "%f\n" \ | LC_ALL=C sort) EOF fw_dir="${fw_dir_add}${fw_dir}" dinfo " microcode_ctl: final fw_dir: \"${fw_dir}\"" } PK!R$modules.d/90qemu-net/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { if type -P systemd-detect-virt >/dev/null 2>&1; then vm=$(systemd-detect-virt --vm >/dev/null 2>&1) (($? != 0)) && return 255 [[ $vm = "qemu" ]] && return 0 [[ $vm = "kvm" ]] && return 0 [[ $vm = "bochs" ]] && return 0 fi for i in /sys/class/dmi/id/*_vendor; do [[ -f $i ]] || continue read vendor < $i [[ "$vendor" == "QEMU" ]] && return 0 [[ "$vendor" == "Bochs" ]] && return 0 done return 255 } installkernel() { # qemu specific modules hostonly='' instmods virtio_net e1000 8139cp pcnet32 e100 ne2k_pci } PK!O_"modules.d/90bcache/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { if ! blkid -k | { while read line; do [[ $line == bcache ]] && exit 0; done; exit 1; } \ && ! type -P probe-bcache >/dev/null; then return 1 fi [[ $hostonly ]] || [[ $mount_needs ]] && { for fs in "${host_fs_types[@]}"; do [[ $fs = "bcache" ]] && return 0 done return 255 } return 0 } depends() { return 0 } installkernel() { instmods bcache } install() { blkid -k | { while read line; do [[ $line == bcache ]] && exit 0; done; exit 1; } || inst_multiple -o probe-bcache inst_multiple -o ${udevdir}/bcache-register inst_rules 61-bcache.rules 69-bcache.rules } PK!XX(modules.d/03modsign/load-modsign-keys.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Licensed under the GPLv2 # # Copyright 2013 Red Hat, Inc. # Peter Jones for x in /lib/modules/keys/* ; do [ "${x}" = "/lib/modules/keys/*" ] && break keyctl padd asymmetric "" @s < ${x} done PK!ޮ#modules.d/03modsign/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Licensed under the GPLv2 # # Copyright 2013 Red Hat, Inc. # Peter Jones check() { require_binaries keyctl || return 1 # do not include module in hostonly mode, # if no keys are present if [[ $hostonly ]]; then x=$(echo /lib/modules/keys/*) [[ "${x}" = "/lib/modules/keys/*" ]] && return 255 fi return 0 } depends() { return 0 } install() { inst_dir /lib/modules/keys inst_binary /usr/bin/keyctl inst_hook pre-trigger 01 "$moddir/load-modsign-keys.sh" for x in /lib/modules/keys/* ; do [[ "${x}" = "/lib/modules/keys/*" ]] && break inst_simple "${x}" done } PK!@ʓ!modules.d/40network/dhclient.confnu[ option classless-static-routes code 121 = array of unsigned integer 8; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, root-path, interface-mtu, classless-static-routes; PK!_jj$modules.d/40network/kill-dhclient.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh for f in /tmp/dhclient.*.pid; do [ -e $f ] || continue read PID < $f; kill $PID >/dev/null 2>&1 done sleep 0.1 for f in /tmp/dhclient.*.pid; do [ -e $f ] || continue read PID < $f; kill -9 $PID >/dev/null 2>&1 done PK!'#modules.d/40network/parse-ifname.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Format: # ifname=: # # Note letters in the macaddress must be lowercase! # # Examples: # ifname=eth0:4a:3f:4c:04:f8:d7 # # Note when using ifname= to get persistent interface names, you must specify # an ifname= argument for each interface used in an ip= or fcoe= argument # check if there are any ifname parameters if ! getarg ifname= >/dev/null ; then return fi command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh # Check ifname= lines for p in $(getargs ifname=); do parse_ifname_opts $p done PK!|5I#modules.d/40network/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { local _program require_binaries ip arping dhclient || return 1 return 255 } depends() { return 0 } installkernel() { # Include wired net drivers, excluding wireless net_module_filter() { local _net_drivers='eth_type_trans|register_virtio_device|usbnet_open' local _unwanted_drivers='/(wireless|isdn|uwb|net/ethernet|net/phy|net/team)/' local _ret # subfunctions inherit following FDs local _merge=8 _side2=9 function nmf1() { local _fname _fcont while read _fname; do [[ $_fname =~ $_unwanted_drivers ]] && continue case "$_fname" in *.ko) _fcont="$(< $_fname)" ;; *.ko.gz) _fcont="$(gzip -dc $_fname)" ;; *.ko.xz) _fcont="$(xz -dc $_fname)" ;; esac [[ $_fcont =~ $_net_drivers && ! $_fcont =~ iw_handler_get_spy ]] \ && echo "$_fname" done return 0 } function rotor() { local _f1 _f2 while read _f1; do echo "$_f1" if read _f2; then echo "$_f2" 1>&${_side2} fi done | nmf1 1>&${_merge} return 0 } # Use two parallel streams to filter alternating modules. set +x eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1" [[ $debug ]] && set -x return 0 } { find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \ | net_module_filter | instmods #instmods() will take care of hostonly instmods \ =drivers/net/phy \ =drivers/net/team \ =drivers/net/ethernet \ ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net hostonly="" instmods iscsi_ibft crc32c iscsi_boot_sysfs } install() { local _arch _i _dir inst_multiple ip arping dhclient sed awk inst_multiple -o ping ping6 inst_multiple -o teamd teamdctl teamnl inst_simple /etc/libnl/classid inst_script "$moddir/ifup.sh" "/sbin/ifup" inst_script "$moddir/netroot.sh" "/sbin/netroot" inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script" inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh" inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf" inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" inst_hook pre-udev 60 "$moddir/net-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" inst_hook cmdline 92 "$moddir/parse-ibft.sh" inst_hook cmdline 95 "$moddir/parse-vlan.sh" inst_hook cmdline 96 "$moddir/parse-bond.sh" inst_hook cmdline 96 "$moddir/parse-team.sh" inst_hook cmdline 97 "$moddir/parse-bridge.sh" inst_hook cmdline 98 "$moddir/parse-ip-opts.sh" inst_hook cmdline 99 "$moddir/parse-ifname.sh" inst_hook cleanup 10 "$moddir/kill-dhclient.sh" # Special network nameing for idrac USB devs inst_rules 73-idrac.rules # install all config files for teaming unset TEAM_MASTER unset TEAM_CONFIG unset TEAM_PORT_CONFIG unset HWADDR unset SUBCHANNELS for i in /etc/sysconfig/network-scripts/ifcfg-*; do [ -e "$i" ] || continue case "$i" in *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave) continue ;; esac ( . "$i" if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \ && [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then mkdir -p $initdir/etc/teamd printf -- "%s" "$TEAM_CONFIG" > "$initdir/etc/teamd/${DEVICE}.conf" elif [ -n "$TEAM_PORT_CONFIG" ]; then inst_simple "$i" HWADDR="$(echo $HWADDR | sed 'y/ABCDEF/abcdef/')" if [ -n "$HWADDR" ]; then ln_r "$i" "/etc/sysconfig/network-scripts/mac-${HWADDR}.conf" fi SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')" if [ -n "$SUBCHANNELS" ]; then ln_r "$i" "/etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf" fi fi fi ) done _arch=$(uname -m) inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \ {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" dracut_need_initqueue } PK!)f!modules.d/40network/parse-team.shnuȯ#!/bin/sh # # Format: # team=: # # teamslaves is a comma-separated list of physical (ethernet) interfaces # parseteam() { local v=${1}: set -- while [ -n "$v" ]; do set -- "$@" "${v%%:*}" v=${v#*:} done case $# in 2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;; *) die "team= requires two parameters" ;; esac } for team in $(getargs team=); do unset teammaster teamslaves parseteam "$(getarg team=)" echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info if ! [ -e /etc/teamd/${teammaster}.conf ]; then warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using activebackup." mkdir -p /etc/teamd printf -- "%s" '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' > "/etc/teamd/${teammaster}.conf" fi done PK!j0``modules.d/40network/net-lib.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh is_ip() { echo "$1" | { IFS=. read a b c d test "$a" -ge 0 -a "$a" -le 255 \ -a "$b" -ge 0 -a "$b" -le 255 \ -a "$c" -ge 0 -a "$c" -le 255 \ -a "$d" -ge 0 -a "$d" -le 255 \ 2> /dev/null } && return 0 return 1 } get_ip() { local iface="$1" ip="" ip=$(ip -o -f inet addr show $iface) ip=${ip%%/*} ip=${ip##* } } iface_for_remote_addr() { set -- $(ip -o route get to $1) echo $5 } iface_for_ip() { set -- $(ip -o addr show to $1) echo $2 } iface_for_mac() { local interface="" mac="$(echo $1 | sed 'y/ABCDEF/abcdef/')" for interface in /sys/class/net/*; do if [ $(cat $interface/address) = "$mac" ]; then echo ${interface##*/} fi done } # get the iface name for the given identifier - either a MAC, IP, or iface name iface_name() { case $1 in ??:??:??:??:??:??|??-??-??-??-??-??) iface_for_mac $1 ;; *:*:*|*.*.*.*) iface_for_ip $1 ;; *) echo $1 ;; esac } # list the configured interfaces configured_ifaces() { local IFACES="" iface_id="" rv=1 [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces if { pidof udevd || pidof systemd-udevd; } > /dev/null; then for iface_id in $IFACES; do echo $(iface_name $iface_id) rv=0 done else warn "configured_ifaces called before udev is running" echo $IFACES [ -n "$IFACES" ] && rv=0 fi return $rv } all_ifaces_up() { local iface="" IFACES="" [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces for iface in $IFACES; do [ -e /tmp/net.$iface.up ] || return 1 done } all_ifaces_setup() { local iface="" IFACES="" [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces for iface in $IFACES; do [ -e /tmp/net.$iface.did-setup ] || return 1 done } get_netroot_ip() { local prefix="" server="" rest="" splitsep "$1" ":" prefix server rest case $server in [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) echo "$server"; return 0 ;; esac return 1 } ip_is_local() { strstr "$(ip route get $1 2>/dev/null)" " via " } ifdown() { local netif="$1" # ip down/flush ensures that routing info goes away as well ip link set $netif down ip addr flush dev $netif echo "#empty" > /etc/resolv.conf rm -f -- /tmp/net.$netif.did-setup [ -z "$DO_VLAN" ] && \ [ -e /sys/class/net/$netif/address ] && \ rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup # TODO: send "offline" uevent? } setup_net() { local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES="" local _p [ -e /tmp/net.$netif.did-setup ] && return [ -z "$DO_VLAN" ] && \ [ -e /sys/class/net/$netif/address ] && \ [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces [ -z "$IFACES" ] && IFACES="$netif" # run the scripts written by ifup [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts # set up resolv.conf [ -e /tmp/net.$netif.resolv.conf ] && \ awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw # add static route for _p in $(getargs rd.route); do route_to_var "$_p" || continue [ -n "$route_dev" ] && [ "$route_dev" != "$netif" ] && continue ip route add "$route_mask" ${route_gw:+via "$route_gw"} ${route_dev:+dev "$route_dev"} if strstr "$route_mask" ":"; then printf -- "%s\n" "$route_mask ${route_gw:+via $route_gw} ${route_dev:+dev $route_dev}" \ > /tmp/net.route6."$netif" else printf -- "%s\n" "$route_mask ${route_gw:+via $route_gw} ${route_dev:+dev $route_dev}" \ > /tmp/net.route."$netif" fi done # Handle STP Timeout: arping the default gateway. # (or the root server, if a) it's local or b) there's no gateway.) # Note: This assumes that if no router is present the # root server is on the same subnet. # Get DHCP-provided router IP, or the cmdline-provided "gw=" argument [ -n "$new_routers" ] && gw_ip=${new_routers%%,*} [ -n "$gw" ] && gw_ip=$gw # Get the "netroot" IP (if there's an IP address in there) netroot_ip=$(get_netroot_ip $netroot) # try netroot if it's local (or there's no gateway) if ip_is_local $netroot_ip || [ -z "$gw_ip" ]; then dest="$netroot_ip" else dest="$gw_ip" fi unset layer2 if [ -f /sys/class/net/$netif/device/layer2 ]; then read layer2 < /sys/class/net/$netif/device/layer2 fi if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! strstr "$dest" ":"; then arping -q -f -w 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed" fi unset layer2 > /tmp/net.$netif.did-setup [ -z "$DO_VLAN" ] && \ [ -e /sys/class/net/$netif/address ] && \ > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup } save_netinfo() { local netif="$1" IFACES="" f="" i="" [ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces # Add $netif to the front of IFACES (if it's not there already). set -- "$netif" for i in $IFACES; do [ "$i" != "$netif" ] && set -- "$@" "$i"; done IFACES="$*" for i in $IFACES; do for f in /tmp/dhclient.$i.*; do [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.} done done echo $IFACES > /tmp/.net.ifaces.new mv /tmp/.net.ifaces.new /tmp/net.ifaces } set_ifname() { local name="$1" mac="$2" num=-1 n="" # if it's already set, return the existing name for n in $(getargs ifname=); do strstr "$n" "$mac" && echo ${n%%:*} && return done # otherwise, pick a new name and use that while :; do num=$(($num+1)); [ -e /sys/class/net/$name$num ] && continue for n in $(getargs ifname=); do [ "$name$num" = "${n%%:*}" ] && continue 2 done break done echo "ifname=$name$num:$mac" >> /etc/cmdline.d/45-ifname.conf echo "$name$num" } # pxelinux provides macaddr '-' separated, but we need ':' fix_bootif() { local macaddr=${1} local IFS='-' macaddr=$(printf '%s:' ${macaddr}) macaddr=${macaddr%:} # strip hardware type field from pxelinux [ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:} # return macaddr with lowercase alpha characters expected by udev echo $macaddr | sed 'y/ABCDEF/abcdef/' } ibft_to_cmdline() { local iface="" modprobe -q iscsi_ibft ( for iface in /sys/firmware/ibft/ethernet*; do local mac="" dev="" local dhcp="" ip="" gw="" mask="" hostname="" local dns1 dns2 [ -e ${iface}/mac ] || continue mac=$(read a < ${iface}/mac; echo $a) [ -z "$mac" ] && continue dev=$(set_ifname ibft $mac) [ -e /tmp/net.${dev}.has_ibft_config ] && continue [ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a) # Skip invalid interfaces (( $flags & 1 )) || continue [ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a) [ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a) [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a) if [ -n "$ip" ] ; then case "$ip" in *.*.*.*) family=ipv4 ;; *:*) family=ipv6 ;; esac fi if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then if [ "$family" = "ipv6" ] ; then echo "ip=$dev:dhcp6" else echo "ip=$dev:dhcp" fi elif [ -e ${iface}/ip-addr ]; then # skip not assigned ip adresses [ "$ip" = "0.0.0.0" ] && continue [ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a) [ "$gateway" = "0.0.0.0" ] && unset $gateway [ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a) [ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a) [ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a) [ "$dns1" = "0.0.0.0" ] && unset $dns1 [ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a) [ "$dns2" = "0.0.0.0" ] && unset $dns2 [ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a) if [ "$family" = "ipv6" ] ; then if [ -n "$ip" ] ; then ip="[$ip]" [ -n "$prefix" ] || prefix=64 mask="$prefix" fi if [ -n "$gw" ] ; then gw="[${gw}]" fi fi if [ -n "$ip" ] && [ -n "$mask" ]; then echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}" else warn "${iface} does not contain a valid iBFT configuration" warn "ip-addr=$ip" warn "gateway=$gw" warn "subnet-mask=$mask" warn "hostname=$hostname" fi else info "${iface} does not contain a valid iBFT configuration" ls -l ${iface} | vinfo fi if [ -e ${iface}/vlan ]; then vlan=$(read a < ${iface}/vlan; echo $a) if [ "$vlan" -ne "0" ]; then case "$vlan" in [0-9]*) echo "vlan=$dev.$vlan:$dev" echo $mac > /tmp/net.${dev}.${vlan}.has_ibft_config ;; *) echo "vlan=$vlan:$dev" echo $mac > /tmp/net.${vlan}.has_ibft_config ;; esac else echo $mac > /tmp/net.${dev}.has_ibft_config fi else echo $mac > /tmp/net.${dev}.has_ibft_config fi done ) >> /etc/cmdline.d/40-ibft.conf } parse_iscsi_root() { local v v=${1#iscsi:} # extract authentication info case "$v" in *@*:*:*:*:*) authinfo=${v%%@*} v=${v#*@} # allow empty authinfo to allow having an @ in iscsi_target_name like this: # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk if [ -n "$authinfo" ]; then OLDIFS="$IFS" IFS=: set $authinfo IFS="$OLDIFS" if [ $# -gt 4 ]; then warn "Wrong authentication info in iscsi: parameter!" return 1 fi iscsi_username=$1 iscsi_password=$2 if [ $# -gt 2 ]; then iscsi_in_username=$3 iscsi_in_password=$4 fi fi ;; esac # extract target ip case "$v" in [[]*[]]:*) iscsi_target_ip=${v#[[]} iscsi_target_ip=${iscsi_target_ip%%[]]*} v=${v#[[]$iscsi_target_ip[]]:} ;; *) iscsi_target_ip=${v%%[:]*} v=${v#$iscsi_target_ip:} ;; esac unset iscsi_target_name # extract target name case "$v" in *:iqn.*) iscsi_target_name=iqn.${v##*:iqn.} v=${v%:iqn.*}: ;; *:eui.*) iscsi_target_name=eui.${v##*:eui.} v=${v%:eui.*}: ;; *:naa.*) iscsi_target_name=naa.${v##*:naa.} v=${v%:naa.*}: ;; esac # parse the rest OLDIFS="$IFS" IFS=: set $v IFS="$OLDIFS" iscsi_protocol=$1; shift # ignored iscsi_target_port=$1; shift if [ -n "$iscsi_target_name" ]; then if [ $# -eq 3 ]; then iscsi_iface_name=$1; shift fi if [ $# -eq 2 ]; then iscsi_netdev_name=$1; shift fi iscsi_lun=$1; shift if [ $# -ne 0 ]; then warn "Invalid parameter in iscsi: parameter!" return 1 fi return 0 fi if [ $# -gt 3 ] && [ -n "$1$2" ]; then if [ -z "$3" ] || [ "$3" -ge 0 ] 2>/dev/null ; then iscsi_iface_name=$1; shift iscsi_netdev_name=$1; shift fi fi iscsi_lun=$1; shift iscsi_target_name=$(printf "%s:" "$@") iscsi_target_name=${iscsi_target_name%:} } ip_to_var() { local v=${1}: local i set -- while [ -n "$v" ]; do if [ "${v#\[*:*:*\]:}" != "$v" ]; then # handle IPv6 address i="${v%%\]:*}" i="${i##\[}" set -- "$@" "$i" v=${v#\[$i\]:} else set -- "$@" "${v%%:*}" v=${v#*:} fi done unset ip srv gw mask hostname dev autoconf macaddr mtu dns1 dns2 if [ $# -eq 0 ]; then autoconf="error" return 0 fi if [ $# -eq 1 ]; then # format: ip={dhcp|on|any|dhcp6|auto6|either6} # or # ip= means anaconda-style static config argument cluster autoconf="$1" if strstr "$autoconf" "*.*.*.*"; then # ip= means anaconda-style static config argument cluster: # ip= gateway= netmask= hostname= mtu= # ksdevice={link|bootif|ibft||} ip="$autoconf" gw=$(getarg gateway=) mask=$(getarg netmask=) hostname=$(getarg hostname=) dev=$(getarg ksdevice=) autoconf="none" mtu=$(getarg mtu=) # handle special values for ksdevice case "$dev" in bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;; link) dev="" ;; # FIXME: do something useful with this ibft) dev="" ;; # ignore - ibft is handled elsewhere esac fi return 0 fi if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" -o "$2" = "either6" ]; then # format: ip=:{dhcp|on|any|dhcp6|auto6}[:[][:]] [ -n "$1" ] && dev="$1" [ -n "$2" ] && autoconf="$2" [ -n "$3" ] && mtu=$3 if [ -z "$5" ]; then macaddr="$4" else macaddr="${4}:${5}:${6}:${7}:${8}:${9}" fi return 0 fi # format: ip=:[]:::::{none|off|dhcp|on|any|dhcp6|auto6|ibft}:[:[][:]] [ -n "$1" ] && ip=$1 [ -n "$2" ] && srv=$2 [ -n "$3" ] && gw=$3 [ -n "$4" ] && mask=$4 [ -n "$5" ] && hostname=$5 [ -n "$6" ] && dev=$6 [ -n "$7" ] && autoconf=$7 case "$8" in [0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*) dns1="$8" [ -n "$9" ] && dns2="$9" ;; [0-9]*) mtu="$8" if [ -n "${9}" -a -z "${10}" ]; then macaddr="${9}" elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then macaddr="${9}:${10}:${11}:${12}:${13}:${14}" fi ;; *) if [ -n "${9}" -a -z "${10}" ]; then macaddr="${9}" elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then macaddr="${9}:${10}:${11}:${12}:${13}:${14}" fi ;; esac return 0 } route_to_var() { local v=${1}: local i set -- while [ -n "$v" ]; do if [ "${v#\[*:*:*\]:}" != "$v" ]; then # handle IPv6 address i="${v%%\]:*}" i="${i##\[}" set -- "$@" "$i" v=${v#\[$i\]:} else set -- "$@" "${v%%:*}" v=${v#*:} fi done unset route_mask route_gw route_dev case $# in 2) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2" return 0;; 3) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"; [ -n "$3" ] && route_dev="$3" return 0;; *) return 1;; esac } parse_ifname_opts() { local IFS=: set $1 case $# in 7) ifname_if=$1 # udev requires MAC addresses to be lower case ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/') ;; 21) # infiniband MAC addrs are 20 bytes long not 6 ifname_if=$1 ifname_mac=$(echo $2:$3:$4:$5:$6:$7:$8:$9:$10:$11:$12:13:$14:$15$16:$17:$18:$19:$20:$21 | sed 'y/ABCDEF/abcdef/') ;; *) die "Invalid arguments for ifname=$1" ;; esac case $ifname_if in eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]|eth[0-9][0-9][0-9][0-9]) warn "ifname=$ifname_if uses the kernel name space for interfaces" warn "This can fail for multiple network interfaces and is discouraged!" warn "Please use a custom name like \"netboot\" or \"bluesocket\"" warn "or use the persistent interface names from udev or biosdevname and no ifname= at all." ;; esac } # some network driver need long time to initialize, wait before it's ready. wait_for_if_link() { local cnt=0 local li local timeout="$(getargs rd.net.timeout.iflink=)" timeout=${timeout:-60} timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do li=$(ip -o link show dev $1 2>/dev/null) [ -n "$li" ] && return 0 sleep 0.1 cnt=$(($cnt+1)) done return 1 } wait_for_if_up() { local cnt=0 local li local timeout="$(getargs rd.net.timeout.ifup=)" timeout=${timeout:-20} timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do li=$(ip -o link show up dev $1) if [ -n "$li" ]; then case "$li" in *\*) return 0;; *\<*,UP,*\>*) return 0;; esac fi if strstr "$li" "LOWER_UP" \ && strstr "$li" "state UNKNOWN" \ && ! strstr "$li" "DORMANT"; then return 0 fi sleep 0.1 cnt=$(($cnt+1)) done return 1 } wait_for_route_ok() { local cnt=0 local timeout="$(getargs rd.net.timeout.route=)" timeout=${timeout:-20} timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do li=$(ip route show) [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0 sleep 0.1 cnt=$(($cnt+1)) done return 1 } wait_for_ipv6_dad_link() { local cnt=0 local timeout="$(getargs rd.net.timeout.ipv6dad=)" timeout=${timeout:-50} timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do [ -n "$(ip -6 addr show dev "$1" scope link)" ] \ && [ -z "$(ip -6 addr show dev "$1" scope link tentative)" ] \ && return 0 [ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \ && return 1 sleep 0.1 cnt=$(($cnt+1)) done return 1 } wait_for_ipv6_dad() { local cnt=0 local timeout="$(getargs rd.net.timeout.ipv6dad=)" timeout=${timeout:-50} timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do [ -n "$(ip -6 addr show dev "$1")" ] \ && [ -z "$(ip -6 addr show dev "$1" tentative)" ] \ && return 0 [ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \ && return 1 sleep 0.1 cnt=$(($cnt+1)) done return 1 } wait_for_ipv6_auto() { local cnt=0 local timeout="$(getargs rd.net.timeout.ipv6auto=)" timeout=${timeout:-40} timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do [ -z "$(ip -6 addr show dev "$1" tentative)" ] \ && [ -n "$(ip -6 route list proto ra dev "$1")" ] \ && return 0 sleep 0.1 cnt=$(($cnt+1)) done return 1 } linkup() { wait_for_if_link $1 2>/dev/null\ && ip link set $1 up 2>/dev/null\ && wait_for_if_up $1 2>/dev/null } type hostname >/dev/null 2>&1 || \ hostname() { cat /proc/sys/kernel/hostname } iface_has_carrier() { local cnt=0 local interface="$1" flags="" [ -n "$interface" ] || return 2 interface="/sys/class/net/$interface" [ -d "$interface" ] || return 2 local timeout="$(getargs rd.net.timeout.carrier=)" timeout=${timeout:-15} timeout=$(($timeout*10)) linkup "$1" li=$(ip -o link show up dev $1) strstr "$li" "NO-CARRIER" && _no_carrier_flag=1 while [ $cnt -lt $timeout ]; do if [ -n "$_no_carrier_flag" ]; then # NO-CARRIER flag was cleared strstr "$li" "NO-CARRIER" || return 0 fi # double check the syscfs carrier flag [ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0 sleep 0.1 cnt=$(($cnt+1)) done return 1 } iface_has_link() { iface_has_carrier "$@" } iface_is_enslaved() { local _li _li=$(ip -o link show dev $1) strstr "$li" " master " || return 1 return 0 } find_iface_with_link() { local iface_path="" iface="" for iface_path in /sys/class/net/*; do iface=${iface_path##*/} str_starts "$iface" "lo" && continue if iface_has_link $iface; then echo "$iface" return 0 fi done return 1 } is_persistent_ethernet_name() { local _netif="$1" local _name_assign_type="0" [ -f "/sys/class/net/$_netif/name_assign_type" ] \ && _name_assign_type=$(cat "/sys/class/net/$_netif/name_assign_type") # NET_NAME_ENUM 1 [ "$_name_assign_type" = "1" ] && return 1 # NET_NAME_PREDICTABLE 2 [ "$_name_assign_type" = "2" ] && return 0 case "$_netif" in # udev persistent interface names eno[0-9]|eno[0-9][0-9]|eno[0-9][0-9][0-9]*) ;; ens[0-9]|ens[0-9][0-9]|ens[0-9][0-9][0-9]*) ;; enp[0-9]s[0-9]*|enp[0-9][0-9]s[0-9]*|enp[0-9][0-9][0-9]*s[0-9]*) ;; enP*p[0-9]s[0-9]*|enP*p[0-9][0-9]s[0-9]*|enP*p[0-9][0-9][0-9]*s[0-9]*) ;; # biosdevname em[0-9]|em[0-9][0-9]|em[0-9][0-9][0-9]*) ;; p[0-9]p[0-9]*|p[0-9][0-9]p[0-9]*|p[0-9][0-9][0-9]*p[0-9]*) ;; *) return 1 esac return 0 } is_kernel_ethernet_name() { local _netif="$1" local _name_assign_type="1" if [ -e "/sys/class/net/$_netif/name_assign_type" ]; then _name_assign_type=$(cat "/sys/class/net/$_netif/name_assign_type") case "$_name_assign_type" in 2|3|4) # NET_NAME_PREDICTABLE 2 # NET_NAME_USER 3 # NET_NAME_RENAMED 4 return 1 ;; 1|*) # NET_NAME_ENUM 1 return 0 ;; esac fi # fallback to error prone manual name check case "$_netif" in eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]*) return 0 ;; *) return 1 esac } iface_get_subchannels() { local _netif local _subchannels _netif="$1" _subchannels=$({ for i in /sys/class/net/$_netif/device/cdev[0-9]*; do [ -e $i ] || continue channel=$(readlink -f $i) printf -- "%s" "${channel##*/}," done }) [ -n "$_subchannels" ] || return 1 printf -- "%s" ${_subchannels%,} } PK!㧶G#modules.d/40network/net-genrules.shnuȯ#!/bin/sh getargbool 0 rd.neednet && NEEDNET=1 # Don't continue if we don't need network if [ -z "$netroot" ] && [ ! -e "/tmp/net.ifaces" ] && [ "$NEEDNET" != "1" ]; then return fi command -v fix_bootif >/dev/null || . /lib/net-lib.sh # Write udev rules { # bridge: attempt only the defined interface for i in /tmp/bridge.*.info; do [ -e "$i" ] || continue unset bridgeslaves unset bridgename . "$i" RAW_IFACES="$RAW_IFACES $bridgeslaves" MASTER_IFACES="$MASTER_IFACES $bridgename" done # bond: attempt only the defined interface (override bridge defines) for i in /tmp/bond.*.info; do [ -e "$i" ] || continue unset bondslaves unset bondname . "$i" # It is enough to fire up only one RAW_IFACES="$RAW_IFACES $bondslaves" MASTER_IFACES="$MASTER_IFACES ${bondname}" done for i in /tmp/team.*.info; do [ -e "$i" ] || continue unset teamslaves unset teammaster . "$i" RAW_IFACES="$RAW_IFACES ${teamslaves}" MASTER_IFACES="$MASTER_IFACES ${teammaster}" done for j in /tmp/vlan.*.phy; do [ -e "$j" ] || continue unset phydevice read phydevice < "$j" RAW_IFACES="$RAW_IFACES $phydevice" for i in /tmp/vlan.*.${phydevice}; do [ -e "$i" ] || continue unset vlanname read vlanname < "$i" MASTER_IFACES="$MASTER_IFACES ${vlanname}" done done MASTER_IFACES="$(trim "$MASTER_IFACES")" RAW_IFACES="$(trim "$RAW_IFACES")" if [ -z "$IFACES" ]; then [ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces fi if [ -e /tmp/net.bootdev ]; then bootdev=$(cat /tmp/net.bootdev) fi ifup='/sbin/ifup $env{INTERFACE}' runcmd="RUN+=\"/sbin/initqueue --name ifup-\$env{INTERFACE} --unique --onetime $ifup\"" # We have some specific interfaces to handle if [ -n "${RAW_IFACES}${IFACES}" ]; then echo 'SUBSYSTEM!="net", GOTO="net_end"' echo 'ACTION!="add|change|move", GOTO="net_end"' for iface in $IFACES $RAW_IFACES; do case "$iface" in ??:??:??:??:??:??) # MAC address cond="ATTR{address}==\"$iface\"" echo "$cond, $runcmd, GOTO=\"net_end\"" ;; ??-??-??-??-??-??) # MAC address in BOOTIF form cond="ATTR{address}==\"$(fix_bootif $iface)\"" echo "$cond, $runcmd, GOTO=\"net_end\"" ;; *) # an interface name cond="ENV{INTERFACE}==\"$iface\"" echo "$cond, $runcmd, GOTO=\"net_end\"" cond="NAME==\"$iface\"" echo "$cond, $runcmd, GOTO=\"net_end\"" ;; esac # The GOTO prevents us from trying to ifup the same device twice done echo 'LABEL="net_end"' for iface in $IFACES; do if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then echo "[ -f /tmp/net.${iface}.did-setup ]" >$hookdir/initqueue/finished/wait-$iface.sh fi done # Default: We don't know the interface to use, handle all # Fixme: waiting for the interface as well. else cond='ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}!="wlan|wwan"' # if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules fi # if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh } > /etc/udev/rules.d/90-net.rules PK!. modules.d/40network/dhcp-root.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # This script is sourced, so root should be set. But let's be paranoid [ -z "$root" ] && root=$(getarg root=) if [ -z "$netroot" ]; then for netroot in $(getargs netroot=); do [ "$netroot" = "dhcp" ] && break [ "$netroot" = "dhcp6" ] && break done [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] || unset netroot fi if [ "$root" = "dhcp" ] || [ "$root" = "dhcp6" ] || [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ]; then # Tell ip= checker that we need dhcp NEEDDHCP="1" # Done, all good! rootok=1 if [ "$netroot" != "dhcp" ] && [ "$netroot" != "dhcp6" ]; then netroot=$root fi # Shut up init error check [ -z "$root" ] && root="dhcp" echo '[ -d $NEWROOT/proc -o -e /dev/root ]' > $hookdir/initqueue/finished/dhcp.sh fi PK!h:T!modules.d/40network/parse-ibft.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh command -v getarg >/dev/null || . /lib/dracut-lib.sh command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh if getargbool 0 rd.iscsi.ibft -d "ip=ibft"; then modprobe -b -q iscsi_boot_sysfs 2>/dev/null modprobe -b -q iscsi_ibft ibft_to_cmdline fi PK!թvF!F!&modules.d/40network/dhclient-script.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh # We already need a set netif here netif=$interface setup_interface() { ip=$new_ip_address mtu=$new_interface_mtu mask=$new_subnet_mask bcast=$new_broadcast_address gw=${new_routers%%,*} domain=$new_domain_name search=$(printf -- "$new_domain_search") namesrv=$new_domain_name_servers hostname=$new_host_name [ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time [ -n "$new_max_life" ] && lease_time=$new_max_life preferred_lft=$lease_time [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override # Taken from debian dhclient-script: # The 576 MTU is only used for X.25 and dialup connections # where the admin wants low latency. Such a low MTU can cause # problems with UDP traffic, among other things. As such, # disallow MTUs from 576 and below by default, so that broken # MTUs are ignored, but higher stuff is allowed (1492, 1500, etc). if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then if ! ip link set $netif mtu $mtu ; then ip link set $netif down ip link set $netif mtu $mtu linkup $netif fi fi ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif \ ${lease_time:+valid_lft $lease_time} \ ${preferred_lft:+preferred_lft ${preferred_lft}} if [ -n "$gw" ] ; then if [ "$mask" == "255.255.255.255" ] ; then # point-to-point connection => set explicit route to gateway echo ip route add $gw dev $netif > /tmp/net.$netif.gw fi echo ip route replace default via $gw dev $netif >> /tmp/net.$netif.gw fi [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf if [ -n "$namesrv" ] ; then for s in $namesrv; do echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf # Note: hostname can be fqdn OR short hostname, so chop off any # trailing domain name and explicity add any domain if set. [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname } setup_interface6() { domain=$new_domain_name search=$(printf -- "$new_domain_search") namesrv=$new_domain_name_servers hostname=$new_host_name [ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time [ -n "$new_max_life" ] && lease_time=$new_max_life preferred_lft=$lease_time [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ dev ${netif} scope global \ ${lease_time:+valid_lft $lease_time} \ ${preferred_lft:+preferred_lft ${preferred_lft}} [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf if [ -n "$namesrv" ] ; then for s in $namesrv; do echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf # Note: hostname can be fqdn OR short hostname, so chop off any # trailing domain name and explicity add any domain if set. [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname } function parse_option_121() { while [ $# -ne 0 ]; do mask="$1" shift # Is the destination a multicast group? if [ $1 -ge 224 -a $1 -lt 240 ]; then multicast=1 else multicast=0 fi # Parse the arguments into a CIDR net/mask string if [ $mask -gt 24 ]; then destination="$1.$2.$3.$4/$mask" shift; shift; shift; shift elif [ $mask -gt 16 ]; then destination="$1.$2.$3.0/$mask" shift; shift; shift elif [ $mask -gt 8 ]; then destination="$1.$2.0.0/$mask" shift; shift else destination="$1.0.0.0/$mask" shift fi # Read the gateway gateway="$1.$2.$3.$4" shift; shift; shift; shift # Multicast routing on Linux # - If you set a next-hop address for a multicast group, this breaks with Cisco switches # - If you simply leave it link-local and attach it to an interface, it works fine. if [ $multicast -eq 1 ]; then temp_result="$destination dev $interface" else temp_result="$destination via $gateway dev $interface" fi echo "/sbin/ip route add $temp_result" done } case $reason in PREINIT) echo "dhcp: PREINIT $netif up" linkup $netif ;; PREINIT6) echo "dhcp: PREINIT6 $netif up" linkup $netif wait_for_ipv6_dad_link $netif ;; BOUND) echo "dhcp: BOND setting $netif" unset layer2 if [ -f /sys/class/net/$netif/device/layer2 ]; then read layer2 < /sys/class/net/$netif/device/layer2 fi if [ "$layer2" != "0" ]; then if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; then warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying" exit 1 fi fi unset layer2 setup_interface set | while read line; do [ "${line#new_}" = "$line" ] && continue echo "$line" done >/tmp/dhclient.$netif.dhcpopts { echo '. /lib/net-lib.sh' echo "setup_net $netif" if [ -n "$new_classless_static_routes" ]; then parse_option_121 $new_classless_static_routes fi echo "source_hook initqueue/online $netif" [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif" echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh" } > $hookdir/initqueue/setup_net_$netif.sh echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh >/tmp/net.$netif.up if [ -e /sys/class/net/${netif}/address ]; then > /tmp/net.$(cat /sys/class/net/${netif}/address).up fi ;; RENEW|REBIND) unset lease_time [ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time [ -n "$new_max_life" ] && lease_time=$new_max_life preferred_lft=$lease_time [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life ip -4 addr change ${new_ip_address}/${new_subnet_mask} broadcast ${new_broadcast_address} dev ${interface} \ ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \ >/dev/null 2>&1 ;; BOUND6) echo "dhcp: BOND6 setting $netif" setup_interface6 set | while read line; do [ "${line#new_}" = "$line" ] && continue echo "$line" done >/tmp/dhclient.$netif.dhcpopts { echo '. /lib/net-lib.sh' echo "setup_net $netif" echo "source_hook initqueue/online $netif" [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif" echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh" } > $hookdir/initqueue/setup_net_$netif.sh echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh >/tmp/net.$netif.up if [ -e /sys/class/net/${netif}/address ]; then > /tmp/net.$(cat /sys/class/net/${netif}/address).up fi ;; RENEW6|REBIND6) unset lease_time [ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time [ -n "$new_max_life" ] && lease_time=$new_max_life preferred_lft=$lease_time [ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface} scope global \ ${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \ >/dev/null 2>&1 ;; *) echo "dhcp: $reason";; esac exit 0 PK!? )dd#modules.d/40network/parse-bridge.shnuȯ#!/bin/sh # # Format: # bridge=: # # is a comma-separated list of physical (ethernet) interfaces # bridge without parameters assumes bridge=br0:eth0 # parsebridge() { local v=${1}: set -- while [ -n "$v" ]; do set -- "$@" "${v%%:*}" v=${v#*:} done case $# in 0) bridgename=br0; bridgeslaves=$iface ;; 1) die "bridge= requires two parameters" ;; 2) bridgename=$1; bridgeslaves=$(str_replace "$2" "," " ") ;; *) die "bridge= requires two parameters" ;; esac } # Parse bridge for bridgename and bridgeslaves for bridge in $(getargs bridge=); do unset bridgename unset bridgeslaves iface=eth0 # Read bridge= parameters if they exist if [ "$bridge" != "bridge" ]; then parsebridge $bridge fi # Simple default bridge if [ -z "$bridgename" ]; then bridgename=br0 bridgeslaves=$iface fi echo "bridgename=$bridgename" > /tmp/bridge.${bridgename}.info echo "bridgeslaves=\"$bridgeslaves\"" >> /tmp/bridge.${bridgename}.info done PK!d modules.d/40network/netroot.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh PATH=/usr/sbin:/usr/bin:/sbin:/bin command -v getarg >/dev/null || . /lib/dracut-lib.sh command -v setup_net >/dev/null || . /lib/net-lib.sh # Huh? Empty $1? [ -z "$1" ] && exit 1 # [ ! -z $2 ] means this is for manually bringing up network # instead of real netroot; If It's called without $2, then there's # no sense in doing something if no (net)root info is available # or root is already there [ -d $NEWROOT/proc ] && exit 0 if [ -z "$netroot" ]; then netroot=$(getarg netroot=) fi [ -z "$netroot" ] && exit 1 # Set or override primary interface netif=$1 [ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev case "$netif" in ??:??:??:??:??:??) # MAC address for i in /sys/class/net/*/address; do mac=$(cat $i) if [ "$mac" = "$netif" ]; then i=${i%/address} netif=${i##*/} break fi done esac # Figure out the handler for root=dhcp by recalling all netroot cmdline # handlers when this is not called from manually network bringing up. if [ -z "$2" ]; then if getarg "root=dhcp" || getarg "netroot=dhcp" || getarg "root=dhcp6" || getarg "netroot=dhcp6"; then # Load dhcp options [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts # If we have a specific bootdev with no dhcpoptions or empty root-path, # we die. Otherwise we just warn if [ -z "$new_root_path" ] ; then [ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'" warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available" exit 1 fi rm -f -- $hookdir/initqueue/finished/dhcp.sh # Set netroot to new_root_path, so cmdline parsers don't call netroot=$new_root_path # FIXME! unset rootok for f in $hookdir/cmdline/90*.sh; do [ -f "$f" ] && . "$f"; done else rootok="1" fi # Check: do we really know how to handle (net)root? [ -z "$root" ] && die "No or empty root= argument" [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'" handler=${netroot%%:*} handler=${handler%%4} handler=$(command -v ${handler}root) if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then die "No handler for netroot type '$netroot'" fi fi # Source netroot hooks before we start the handler source_hook netroot $netif # Run the handler; don't store the root, it may change from device to device # XXX other variables to export? [ -n "$handler" ] && "$handler" "$netif" "$netroot" "$NEWROOT" save_netinfo $netif exit 0 PK!S!modules.d/40network/parse-vlan.shnuȯ#!/bin/sh # # Format: # vlan=: # parsevlan() { local v=${1}: set -- while [ -n "$v" ]; do set -- "$@" "${v%%:*}" v=${v#*:} done unset vlanname phydevice case $# in 2) vlanname=$1; phydevice=$2 ;; *) die "vlan= requires two parameters" ;; esac } for vlan in $(getargs vlan=); do unset vlanname unset phydevice parsevlan "$vlan" echo "$phydevice" > /tmp/vlan.${phydevice}.phy echo "$vlanname" > /tmp/vlan.${vlanname}.${phydevice} done PK!m!modules.d/40network/parse-bond.shnuȯ#!/bin/sh # # Format: # bond=[::[:[:]]] # # bondslaves is a comma-separated list of physical (ethernet) interfaces # options is a comma-separated list on bonding options (modinfo bonding for details) in format compatible with initscripts # if options include multi-valued arp_ip_target option, then its values should be separated by semicolon. # # bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr # # if the mtu is specified, it will be set on the bond master # # We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup # Ditto for bonding options parsebond() { local v=${1}: set -- while [ -n "$v" ]; do set -- "$@" "${v%%:*}" v=${v#*:} done case $# in 0) bondname=bond0; bondslaves="eth0 eth1" ;; 1) bondname=$1; bondslaves="eth0 eth1" ;; 2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;; 3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;; 4) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;; *) die "bond= requires zero to four parameters" ;; esac } # Parse bond for bondname, bondslaves, bondmode, bondoptions and bondmtu for bond in $(getargs bond=); do unset bondname unset bondslaves unset bondoptions unset bondmtu if [ "$bond" != "bond" ]; then parsebond "$bond" fi # Simple default bond if [ -z "$bondname" ]; then bondname=bond0 bondslaves="eth0 eth1" fi # Make it suitable for initscripts export bondoptions=$(str_replace "$bondoptions" ";" ",") echo "bondname=$bondname" > /tmp/bond.${bondname}.info echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info done PK!00$modules.d/40network/parse-ip-opts.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Format: # ip=[dhcp|on|any] # # ip=:[dhcp|on|any][:[][:]] # # ip=::::::{dhcp|on|any|none|off}[:[][:]] # # When supplying more than only ip= line, is mandatory and # bootdev= must contain the name of the primary interface to use for # routing,dns,dhcp-options,etc. # command -v getarg >/dev/null || . /lib/dracut-lib.sh if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] && [ -z "$(getarg BOOTIF=)" ]; then # No ip= argument(s) for netroot provided, defaulting to DHCP return; fi # Count ip= lines to decide whether we need bootdev= or not if [ -z "$NEEDBOOTDEV" ] ; then count=0 for p in $(getargs ip=); do case "$p" in ibft) continue;; esac count=$(( $count + 1 )) done [ $count -gt 1 ] && NEEDBOOTDEV=1 fi unset count # If needed, check if bootdev= contains anything usable BOOTDEV=$(getarg bootdev=) if [ -n "$NEEDBOOTDEV" ] && ! getargbool 0 rd.neednet; then #[ -z "$BOOTDEV" ] && warn "Please supply bootdev argument for multiple ip= lines" echo "rd.neednet=1" > /etc/cmdline.d/dracut-neednet.conf info "Multiple ip= arguments: assuming rd.neednet=1" else unset NEEDBOOTDEV fi # Check ip= lines # XXX Would be nice if we could errorcheck ip addresses here as well for p in $(getargs ip=); do ip_to_var $p # make first device specified the BOOTDEV if [ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEV" ] && [ -n "$dev" ]; then BOOTDEV="$dev" info "Setting bootdev to '$BOOTDEV'" fi # skip ibft since we did it above [ "$autoconf" = "ibft" ] && continue # Empty autoconf defaults to 'dhcp' if [ -z "$autoconf" ] ; then warn "Empty autoconf values default to dhcp" autoconf="dhcp" fi # Error checking for autoconf in combination with other values for autoopt in $(str_replace "$autoconf" "," " "); do case $autoopt in error) die "Error parsing option 'ip=$p'";; bootp|rarp|both) die "Sorry, ip=$autoopt is currenty unsupported";; none|off) [ -z "$ip" ] && \ die "For argument 'ip=$p'\nValue '$autoopt' without static configuration does not make sense" [ -z "$mask" ] && \ die "Sorry, automatic calculation of netmask is not yet supported" ;; auto6);; either6);; dhcp|dhcp6|on|any) \ #[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \ # die "Sorry, 'ip=$p' does not make sense for multiple interface configurations" [ -n "$ip" ] && \ die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'" ;; *) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'";; esac done if [ -n "$dev" ] ; then # We don't like duplicate device configs if [ -n "$IFACES" ] ; then for i in $IFACES ; do [ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'" done fi # IFACES list for later use IFACES="$IFACES $dev" fi # Do we need to check for specific options? if [ -n "$NEEDDHCP" ] || [ -n "$DHCPORSERVER" ] ; then # Correct device? (Empty is ok as well) [ "$dev" = "$BOOTDEV" ] || continue # Server-ip is there? [ -n "$DHCPORSERVER" ] && [ -n "$srv" ] && continue # dhcp? (It's simpler to check for a set ip. Checks above ensure that if # ip is there, we're static [ -z "$ip" ] && continue # Not good! die "Server-ip or dhcp for netboot needed, but current arguments say otherwise" fi if str_starts "$dev" "enx" && [ ${#dev} -eq 15 ]; then printf -- "ifname=%s:%s:%s:%s:%s:%s:%s\n" \ "$dev" \ "${dev:3:2}" \ "${dev:5:2}" \ "${dev:7:2}" \ "${dev:9:2}" \ "${dev:11:2}" \ "${dev:13:2}" >> /etc/cmdline.d/80-enx.conf fi done # put BOOTIF in IFACES to make sure it comes up if getargbool 1 "rd.bootif" && BOOTIF="$(getarg BOOTIF=)"; then BOOTDEV=$(fix_bootif $BOOTIF) IFACES="$BOOTDEV $IFACES" fi # This ensures that BOOTDEV is always first in IFACES if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}" IFACES="$BOOTDEV $IFACES" fi # Store BOOTDEV and IFACES for later use [ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev [ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces PK!Q_%&modules.d/40network/ifname-genrules.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # if there are no ifname parameters, just use NAME=KERNEL if ! getarg ifname= >/dev/null ; then return fi command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh { for p in $(getargs ifname=); do parse_ifname_opts $p if [ -f /tmp/ifname-$ifname_mac ]; then read oldif < /tmp/ifname-$ifname_mac fi if [ -f /tmp/ifname-$ifname_if ]; then read oldmac < /tmp/ifname-$ifname_if fi if [ -n "$oldif" -a -n "$oldmac" -a "$oldif" = "$ifname_if" -a "$oldmac" = "$ifname_mac" ]; then # skip same ifname= declaration continue fi [ -n "$oldif" ] && warn "Multiple interface names specified for MAC $ifname_mac: $oldif" [ -n "$oldmac" ] && warn "Multiple MAC specified for $ifname_if: $oldmac" printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if" echo $ifname_if > /tmp/ifname-$ifname_mac echo $ifname_mac > /tmp/ifname-$ifname_if done } >> /etc/udev/rules.d/80-ifname.rules PK!g6g6modules.d/40network/ifup.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # We don't need to check for ip= errors here, that is handled by the # cmdline parser script # # without $2 means this is for real netroot case # or it is for manually bring up network ie. for kdump scp vmcore PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh # Huh? No $1? [ -z "$1" ] && exit 1 # $netif reads easier than $1 netif=$1 # loopback is always handled the same way if [ "$netif" = "lo" ] ; then ip link set lo up ip addr add 127.0.0.1/8 dev lo exit 0 fi # Run dhclient do_dhcp() { # dhclient-script will mark the netif up and generate the online # event for nfsroot # XXX add -V vendor class and option parsing per kernel local _COUNT=0 local _timeout=$(getargs rd.net.timeout.dhcp=) local _DHCPRETRY=$(getargs rd.net.dhcp.retry=) _DHCPRETRY=${_DHCPRETRY:-1} [ -e /tmp/dhclient.$netif.pid ] && return 0 if ! iface_has_carrier $netif; then warn "No carrier detected on interface $netif" return 1 fi [ -n "$macaddr" ] && ip link set address $macaddr dev $netif [ -n "$mtu" ] && ip link set mtu $mtu dev $netif ip -4 addr flush dev $netif while [ $_COUNT -lt $_DHCPRETRY ]; do info "Starting dhcp for interface $netif" dhclient "$@" \ ${_timeout:+-timeout $_timeout} \ -q \ -cf /etc/dhclient.conf \ -pf /tmp/dhclient.$netif.pid \ -lf /tmp/dhclient.$netif.lease \ $netif \ && return 0 _COUNT=$(($_COUNT+1)) [ $_COUNT -lt $_DHCPRETRY ] && sleep 1 done warn "dhcp for interface $netif failed" return 1 } load_ipv6() { [ -d /proc/sys/net/ipv6 ] && return modprobe ipv6 i=0 while [ ! -d /proc/sys/net/ipv6 ]; do i=$(($i+1)) [ $i -gt 10 ] && break sleep 0.1 done } do_ipv6auto() { local ret load_ipv6 echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects linkup $netif [ -n "$macaddr" ] && ip link set address $macaddr dev $netif [ -n "$mtu" ] && ip link set mtu $mtu dev $netif wait_for_ipv6_auto $netif ret=$? [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname return $ret } # Handle static ip configuration do_static() { strstr $ip '*:*:*' && load_ipv6 if [ -z "$dev" ] && ! iface_has_carrier "$netif"; then warn "No carrier detected on interface $netif" return 1 elif ! linkup "$netif"; then warn "Could not bring interface $netif up!" return 1 fi ip route get "$ip" | { read a rest if [ "$a" = "local" ]; then warn "Not assigning $ip to interface $netif, cause it is already assigned!" return 1 fi return 0 } || return 1 [ -n "$macaddr" ] && ip link set address $macaddr dev $netif [ -n "$mtu" ] && ip link set mtu $mtu dev $netif if strstr $ip '*:*:*'; then # note no ip addr flush for ipv6 ip addr add $ip/$mask ${srv:+peer $srv} dev $netif wait_for_ipv6_dad $netif else if [ -z "$srv" ]; then if ! arping -f -q -D -c 2 -I $netif $ip; then warn "Duplicate address detected for $ip for interface $netif." return 1 fi fi ip -4 addr flush dev $netif ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif fi [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname return 0 } get_vid() { case "$1" in vlan*) echo ${1#vlan} ;; *.*) echo ${1##*.} ;; esac } # check, if we need VLAN's for this interface if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then unset DO_VLAN NO_AUTO_DHCP=yes DO_VLAN_PHY=yes ifup "$netif" modprobe -b -q 8021q for i in /tmp/vlan.*.${netif}; do [ -e "$i" ] || continue read vlanname < "$i" if [ -n "$vlanname" ]; then linkup "$netif" ip link add dev "$vlanname" link "$netif" type vlan id "$(get_vid $vlanname)" ifup "$vlanname" fi done exit 0 fi # Check, if interface is VLAN interface if ! [ -e /tmp/vlan.${netif}.phy ]; then for i in /tmp/vlan.${netif}.*; do [ -e "$i" ] || continue export DO_VLAN=yes break done fi # bridge this interface? if [ -z "$NO_BRIDGE_MASTER" ]; then for i in /tmp/bridge.*.info; do [ -e "$i" ] || continue unset bridgeslaves unset bridgename . "$i" for ethname in $bridgeslaves ; do [ "$netif" != "$ethname" ] && continue NO_BRIDGE_MASTER=yes NO_AUTO_DHCP=yes ifup $ethname linkup $ethname if [ ! -e /tmp/bridge.$bridgename.up ]; then ip link add name $bridgename type bridge echo 0 > /sys/devices/virtual/net/$bridgename/bridge/forward_delay > /tmp/bridge.$bridgename.up fi ip link set dev $ethname master $bridgename ifup $bridgename exit 0 done done fi # enslave this interface to bond? if [ -z "$NO_BOND_MASTER" ]; then for i in /tmp/bond.*.info; do [ -e "$i" ] || continue unset bondslaves unset bondname . "$i" for slave in $bondslaves ; do [ "$netif" != "$slave" ] && continue # already setup [ -e /tmp/bond.$bondname.up ] && exit 0 # wait for all slaves to show up for slave in $bondslaves ; do # try to create the slave (maybe vlan or bridge) NO_BOND_MASTER=yes NO_AUTO_DHCP=yes ifup $slave if ! ip link show dev $slave >/dev/null 2>&1; then # wait for the last slave to show up exit 0 fi done modprobe -q -b bonding echo "+$bondname" > /sys/class/net/bonding_masters 2>/dev/null ip link set $bondname down # Stolen from ifup-eth # add the bits to setup driver parameters here for arg in $bondoptions ; do key=${arg%%=*}; value=${arg##*=}; # %{value:0:1} is replaced with non-bash specific construct if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then OLDIFS=$IFS; IFS=','; for arp_ip in $value; do echo +$arp_ip > /sys/class/net/${bondname}/bonding/$key done IFS=$OLDIFS; else echo $value > /sys/class/net/${bondname}/bonding/$key fi done linkup $bondname for slave in $bondslaves ; do cat /sys/class/net/$slave/address > /tmp/net.${bondname}.${slave}.hwaddr ip link set $slave down echo "+$slave" > /sys/class/net/$bondname/bonding/slaves linkup $slave done # Set mtu on bond master [ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $bondname # add the bits to setup the needed post enslavement parameters for arg in $bondoptions ; do key=${arg%%=*}; value=${arg##*=}; if [ "${key}" = "primary" ]; then echo $value > /sys/class/net/${bondname}/bonding/$key fi done > /tmp/bond.$bondname.up NO_BOND_MASTER=yes ifup $bondname exit $? done done fi if [ -z "$NO_TEAM_MASTER" ]; then for i in /tmp/team.*.info; do [ -e "$i" ] || continue unset teammaster unset teamslaves . "$i" for slave in $teamslaves ; do [ "$netif" != "$slave" ] && continue [ -e /tmp/team.$teammaster.up ] && exit 0 # wait for all slaves to show up for slave in $teamslaves ; do # try to create the slave (maybe vlan or bridge) NO_TEAM_MASTER=yes NO_AUTO_DHCP=yes ifup $slave if ! ip link show dev $slave >/dev/null 2>&1; then # wait for the last slave to show up exit 0 fi done if [ ! -e /tmp/team.$teammaster.up ] ; then # We shall only bring up those _can_ come up # in case of some slave is gone in active-backup mode working_slaves="" for slave in $teamslaves ; do ip link set $slave up 2>/dev/null if wait_for_if_up $slave; then working_slaves="$working_slaves$slave " fi done # Do not add slaves now teamd -d -U -n -N -t $teammaster -f /etc/teamd/$teammaster.conf for slave in $working_slaves; do # team requires the slaves to be down before joining team ip link set $slave down teamdctl $teammaster port add $slave done ip link set $teammaster up > /tmp/team.$teammaster.up NO_TEAM_MASTER=yes ifup $teammaster exit $? fi done done fi # all synthetic interfaces done.. now check if the interface is available if ! ip link show dev $netif >/dev/null 2>&1; then exit 1 fi # disable manual ifup while netroot is set for simplifying our logic # in netroot case we prefer netroot to bringup $netif automaticlly [ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2" if [ -n "$manualup" ]; then >/tmp/net.$netif.manualup rm -f /tmp/net.${netif}.did-setup else [ -e /tmp/net.${netif}.did-setup ] && exit 0 [ -z "$DO_VLAN" ] && \ [ -e /sys/class/net/$netif/address ] && \ [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0 fi # No ip lines default to dhcp ip=$(getarg ip) if [ -z "$NO_AUTO_DHCP" ] && [ -z "$ip" ]; then if [ "$netroot" = "dhcp6" ]; then do_dhcp -6 else do_dhcp -4 fi for s in $(getargs nameserver); do [ -n "$s" ] || continue echo nameserver $s >> /tmp/net.$netif.resolv.conf done fi # Specific configuration, spin through the kernel command line # looking for ip= lines for p in $(getargs ip=); do ip_to_var $p # skip ibft [ "$autoconf" = "ibft" ] && continue case "$dev" in ??:??:??:??:??:??) # MAC address _dev=$(iface_for_mac $dev) [ -n "$_dev" ] && dev="$_dev" ;; ??-??-??-??-??-??) # MAC address in BOOTIF form _dev=$(iface_for_mac $(fix_bootif $dev)) [ -n "$_dev" ] && dev="$_dev" ;; esac # If this option isn't directed at our interface, skip it if [ -n "$dev" ]; then [ "$dev" != "$netif" ] && \ [ "$use_bridge" != 'true' ] && \ [ "$use_vlan" != 'true' ] && continue else iface_is_enslaved "$netif" && continue fi # Store config for later use for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do eval '[ "$'$i'" ] && echo '$i'="$'$i'"' done > /tmp/net.$netif.override for autoopt in $(str_replace "$autoconf" "," " "); do case $autoopt in dhcp|on|any) do_dhcp -4 ;; dhcp6) load_ipv6 do_dhcp -6 ;; auto6) do_ipv6auto ;; either6) do_ipv6auto || do_dhcp -6 ;; *) do_static ;; esac done ret=$? # setup nameserver for s in "$dns1" "$dns2" $(getargs nameserver); do [ -n "$s" ] || continue echo nameserver $s >> /tmp/net.$netif.resolv.conf done if [ $ret -eq 0 ]; then > /tmp/net.${netif}.up if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then > /tmp/net.$(cat /sys/class/net/${netif}/address).up fi case $autoconf in dhcp|on|any|dhcp6) ;; *) if [ $ret -eq 0 ]; then setup_net $netif source_hook initqueue/online $netif if [ -z "$manualup" ]; then /sbin/netroot $netif fi fi ;; esac exit $ret fi done # netif isn't the top stack? Then we should exit here. # eg. netif is bond0. br0 is on top of it. dhcp br0 is correct but dhcp # bond0 doesn't make sense. if [ -n "$DO_BOND_SETUP" -o -n "$DO_TEAM_SETUP" -o -n "$DO_VLAN_SETUP" ]; then exit 0 fi # no ip option directed at our interface? if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then if [ -e /tmp/net.bootdev ]; then BOOTDEV=$(cat /tmp/net.bootdev) if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat /sys/class/net/${netif}/address)" ]; then load_ipv6 do_dhcp fi else if getargs 'ip=dhcp6'; then load_ipv6 do_dhcp -6 fi if getargs 'ip=dhcp'; then do_dhcp -4 fi fi fi exit 0 PK!k"modules.d/99fs-lib/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { return 0 } depends() { return 0 } echo_fs_helper() { local dev=$1 fs=$2 case "$fs" in xfs) echo -n " xfs_db xfs_repair xfs_check xfs_metadump" ;; ext?) echo -n " e2fsck " ;; jfs) echo -n " jfs_fsck " ;; reiserfs) echo -n " reiserfsck " ;; btrfs) echo -n " btrfsck " ;; esac echo -n " fsck.$fs " return 0 } include_fs_helper_modules() { local dev=$1 fs=$2 case "$fs" in xfs|btrfs) instmods crc32c ;; esac } installkernel() { # xfs and btrfs needs crc32c... if [[ $hostonly ]]; then for_each_host_dev_fs include_fs_helper_modules : else instmods crc32c fi } install() { local _helpers inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh" > ${initdir}/etc/fstab.empty [[ "$nofscks" = "yes" ]] && return if [[ "$fscks" = "${fscks#*[^ ]*}" ]]; then _helpers="\ umount mount /sbin/fsck* xfs_db xfs_check xfs_repair xfs_metadump e2fsck jfs_fsck reiserfsck btrfsck " if [[ $hostonly ]]; then _helpers="umount mount " _helpers+=$(for_each_host_dev_fs echo_fs_helper) fi else _helpers="$fscks" fi if [[ "$_helpers" == *e2fsck* ]] && [ -e /etc/e2fsck.conf ]; then inst_simple /etc/e2fsck.conf fi inst_multiple -o $_helpers fsck } PK!modules.d/99fs-lib/fs-lib.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh fsck_ask_reboot() { info "note - fsck suggests reboot, if you" info "leave shell, booting will continue normally" action_on_fail -n "(reboot ?)" } fsck_ask_err() { warn "*** An error occurred during the file system check." warn "*** Dropping you to a shell; the system will try" warn "*** to mount the filesystem(s), when you leave the shell." action_on_fail -n "(Repair filesystem)" } # inherits: _ret _drv _out fsck_tail() { [ $_ret -gt 0 ] && warn "$_drv returned with $_ret" if [ $_ret -ge 4 ]; then [ -n "$_out" ] && echo "$_out"|vwarn fsck_ask_err else [ -n "$_out" ] && echo "$_out"|vinfo [ $_ret -ge 2 ] && fsck_ask_reboot fi } # note: this function sets _drv of the caller fsck_able() { case "$1" in xfs) # { # type xfs_db && # type xfs_repair && # type xfs_check && # type mount && # type umount # } >/dev/null 2>&1 && # _drv="_drv=none fsck_drv_xfs" && # return 0 return 1 ;; ext?) type e2fsck >/dev/null 2>&1 && _drv="_drv=e2fsck fsck_drv_com" && return 0 ;; jfs) type jfs_fsck >/dev/null 2>&1 && _drv="_drv=jfs_fsck fsck_drv_com" && return 0 ;; reiserfs) type reiserfsck >/dev/null 2>&1 && _drv="_drv=reiserfsck fsck_drv_com" && return 0 ;; btrfs) # type btrfsck >/dev/null 2>&1 && # _drv="_drv=none fsck_drv_btrfs" && # return 0 return 1 ;; nfs*) # nfs can be a nop, returning success _drv="_drv=none :" && return 0 ;; *) type fsck >/dev/null 2>&1 && _drv="_drv=fsck fsck_drv_std" && return 0 ;; esac return 1 } # note: all drivers inherit: _drv _fop _dev fsck_drv_xfs() { # xfs fsck is not necessary... Either it mounts or not return 0 } fsck_drv_btrfs() { # btrfs fsck is not necessary... Either it mounts or not return 0 } # common code for checkers that follow usual subset of options and return codes fsck_drv_com() { local _ret local _out if ! strstr "$_fop" "-[ynap]"; then _fop="-a ${_fop}" fi info "issuing $_drv $_fop $_dev" # we enforce non-interactive run, so $() is fine _out=$($_drv $_fop "$_dev") _ret=$? fsck_tail return $_ret } # code for generic fsck, if the filesystem checked is "unknown" to us fsck_drv_std() { local _ret local _out unset _out info "issuing fsck $_fop $_dev" # note, we don't enforce -a here, thus fsck is being run (in theory) # interactively; otherwise some tool might complain about lack of terminal # (and using -a might not be safe) fsck $_fop "$_dev" >/dev/console 2>&1 _ret=$? fsck_tail return $_ret } # checks single filesystem, relying on specific "driver"; we don't rely on # automatic checking based on fstab, so empty one is passed; # takes 4 arguments - device, filesystem, filesystem options, additional fsck options; # first 2 arguments are mandatory (fs may be auto or "") # returns 255 if filesystem wasn't checked at all (e.g. due to lack of # necessary tools or insufficient options) fsck_single() { local FSTAB_FILE=/etc/fstab.empty local _dev="$1" local _fs="${2:-auto}" local _fsopts="$3" local _fop="$4" local _drv [ $# -lt 2 ] && return 255 # if UUID= marks more than one device, take only the first one [ -e "$_dev" ] || _dev=$(devnames "$_dev"| while read line; do if [ -n "$line" ]; then echo $line; break;fi;done) [ -e "$_dev" ] || return 255 _fs=$(det_fs "$_dev" "$_fs") fsck_able "$_fs" || return 255 info "Checking $_fs: $_dev" export FSTAB_FILE eval "$_drv" return $? } # takes list of filesystems to check in parallel; we don't rely on automatic # checking based on fstab, so empty one is passed fsck_batch() { local FSTAB_FILE=/etc/fstab.empty local _drv=fsck local _dev local _ret local _out [ $# -eq 0 ] || ! type fsck >/dev/null 2>&1 && return 255 info "Checking filesystems (fsck -M -T -a):" for _dev in "$@"; do info " $_dev" done export FSTAB_FILE _out="$(fsck -M -T "$@" -- -a)" _ret=$? fsck_tail return $_ret } # verify supplied filesystem type: # if user provided the fs and we couldn't find it, assume user is right # if we found the fs, assume we're right det_fs() { local _dev="$1" local _orig="${2:-auto}" local _fs _fs=$(udevadm info --query=env --name="$_dev" | \ while read line; do if str_starts $line "ID_FS_TYPE="; then echo ${line#ID_FS_TYPE=} break fi done) _fs=${_fs:-auto} if [ "$_fs" = "auto" ]; then _fs="$_orig" fi echo "$_fs" } write_fs_tab() { local _o local _rw local _root local _rootfstype local _rootflags local _fspassno _fspassno="0" _root="$1" _rootfstype="$2" _rootflags="$3" [ -z "$_rootfstype" ] && _rootfstype=$(getarg rootfstype=) [ -z "$_rootflags" ] && _rootflags=$(getarg rootflags=) [ -z "$_rootfstype" ] && _rootfstype="auto" if [ -z "$_rootflags" ]; then _rootflags="ro,x-initrd.mount" else _rootflags="ro,$_rootflags,x-initrd.mount" fi _rw=0 CMDLINE=$(getcmdline) for _o in $CMDLINE; do case $_o in rw) _rw=1;; ro) _rw=0;; esac done if [ "$_rw" = "1" ]; then _rootflags="$_rootflags,rw" if ! getargbool 0 rd.skipfsck; then _fspassno="1" fi fi echo "$_root /sysroot $_rootfstype $_rootflags $_fspassno 0" >> /etc/fstab if type systemctl >/dev/null 2>/dev/null; then systemctl daemon-reload systemctl --no-block start initrd-root-fs.target fi } PK!q,modules.d/99kdumpbase/kdump-error-handler.shnuȯ#!/bin/sh . /lib/kdump-lib-initramfs.sh set -o pipefail export PATH=$PATH:$KDUMP_SCRIPT_DIR get_kdump_confs do_default_action do_final_action PK!LF,modules.d/99kdumpbase/kdump-emergency.targetnu[# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Emergency Mode Documentation=man:systemd.special(7) Requires=emergency.service After=emergency.service AllowIsolate=yes IgnoreOnIsolate=yes PK! 0gg%modules.d/99kdumpbase/module-setup.shnuȯ#!/bin/bash . $dracutfunctions . /lib/kdump/kdump-lib.sh if ! [[ -d "${initdir}/tmp" ]]; then mkdir -p "${initdir}/tmp" fi check() { [[ $debug ]] && set -x #kdumpctl sets this explicitly if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ] then return 1 fi return 0 } depends() { local _dep="base shutdown" if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then _dep="$_dep drm" fi if is_generic_fence_kdump || is_pcs_fence_kdump; then _dep="$_dep network" fi echo $_dep return 0 } kdump_to_udev_name() { local dev="${1//\"/}" case "$dev" in UUID=*) dev=`blkid -U "${dev#UUID=}"` ;; LABEL=*) dev=`blkid -L "${dev#LABEL=}"` ;; esac echo $(get_persistent_dev "$dev") } kdump_is_bridge() { [ -d /sys/class/net/"$1"/bridge ] } kdump_is_bond() { [ -d /sys/class/net/"$1"/bonding ] } kdump_is_team() { [ -f /usr/bin/teamnl ] && teamnl $1 ports &> /dev/null } kdump_is_vlan() { [ -f /proc/net/vlan/"$1" ] } # $1: netdev name source_ifcfg_file() { local ifcfg_file ifcfg_file=$(get_ifcfg_filename $1) if [ -f "${ifcfg_file}" ]; then . ${ifcfg_file} else dwarning "The ifcfg file of $1 is not found!" fi } # $1: netdev name kdump_setup_dns() { local _nameserver _dns local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf source_ifcfg_file $1 [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" while read content; do _nameserver=$(echo $content | grep ^nameserver) [ -z "$_nameserver" ] && continue _dns=$(echo $_nameserver | cut -d' ' -f2) [ -z "$_dns" ] && continue if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then echo "nameserver=$_dns" >> "$_dnsfile" fi done < "/etc/resolv.conf" } #$1: netdev name #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() { local _netdev="$1" _srcaddr="$2" _ipv6_flag local _netmask _gateway _ipaddr _target _nexthop _ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}") if is_ipv6_address $_srcaddr; then _ipv6_flag="-6" fi if [ -n "$_ipaddr" ]; then _gateway=$(ip $_ipv6_flag route list dev $_netdev | \ awk '/^default /{print $3}' | head -n 1) if [ "x" != "x"$_ipv6_flag ]; then # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/" _netmask=${_ipaddr#*\/} _srcaddr="[$_srcaddr]" _gateway="[$_gateway]" else _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2) fi echo -n "${_srcaddr}::${_gateway}:${_netmask}::" fi /sbin/ip $_ipv6_flag route show | grep -v default | grep ".*via.* $_netdev " |\ while read _route; do _target=`echo $_route | cut -d ' ' -f1` _nexthop=`echo $_route | cut -d ' ' -f3` if [ "x" != "x"$_ipv6_flag ]; then _target="[$_target]" _nexthop="[$_nexthop]" fi echo "rd.route=$_target:$_nexthop:$_netdev" done >> ${initdir}/etc/cmdline.d/45route-static.conf } kdump_get_mac_addr() { cat /sys/class/net/$1/address } #Bonding or team master modifies the mac address #of its slaves, we should use perm address kdump_get_perm_addr() { local addr=$(ethtool -P $1 | sed -e 's/Permanent address: //') if [ -z "$addr" ] || [ "$addr" = "00:00:00:00:00:00" ] then derror "Can't get the permanent address of $1" else echo "$addr" fi } # Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0 # Because kernel assigned names are not persistent between 1st and 2nd # kernel. We could probably end up with eth0 being eth1, eth0 being # eth1, and naming conflict happens. kdump_setup_ifname() { local _ifname # If ifname already has 'kdump-' prefix, we must be switching from # fadump to kdump. Skip prefixing 'kdump-' in this case as adding # another prefix may truncate the ifname. Since an ifname with # 'kdump-' is already persistent, this should be fine. if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then _ifname="kdump-$1" else _ifname="$1" fi echo "$_ifname" } kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev for _dev in `ls /sys/class/net/$_netdev/brif/`; do _kdumpdev=$_dev if kdump_is_bond "$_dev"; then kdump_setup_bond "$_dev" elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then kdump_setup_vlan "$_dev" else _mac=$(kdump_get_mac_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf fi _brif+="$_kdumpdev," done echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf } kdump_setup_bond() { local _netdev=$1 local _dev _mac _slaves _kdumpdev for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf _slaves+="$_kdumpdev," done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf # Get bond options specified in ifcfg source_ifcfg_file $_netdev bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf } kdump_setup_team() { local _netdev=$1 local _dev _mac _slaves _kdumpdev for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf _slaves+="$_kdumpdev," done echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf #Buggy version teamdctl outputs to stderr! #Try to use the latest version of teamd. teamdctl "$_netdev" config dump > ${initdir}/tmp/$$-$_netdev.conf if [ $? -ne 0 ] then derror "teamdctl failed." exit 1 fi inst_dir /etc/teamd inst_simple ${initdir}/tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf" rm -f ${initdir}/tmp/$$-$_netdev.conf } kdump_setup_vlan() { local _netdev=$1 local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" local _netmac="$(kdump_get_mac_addr $_phydev)" local _kdumpdev #Just support vlan over bond, it is not easy #to support all other complex setup if kdump_is_bridge "$_phydev"; then derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_team "$_phydev"; then derror "Vlan over team is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then kdump_setup_bond "$_phydev" echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf fi } # setup s390 znet cmdline # $1: netdev name kdump_setup_znet() { local _options="" local _netdev=$1 source_ifcfg_file $_netdev for i in $OPTIONS; do _options=${_options},$i done echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf } # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2 local _static _proto _ip_conf _ip_opts _ifname_opts if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi _netmac=$(kdump_get_mac_addr $_netdev) _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none elif is_ipv6_address $_srcaddr; then _proto=either6 else _proto=dhcp fi _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}" # dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates # We should also check /proc/cmdline for existing ip=xx arg. # For example, iscsi boot will specify ip=xxx arg in cmdline. if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf fi if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then kdump_setup_bond "$_netdev" elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" else _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$(kdump_get_mac_addr $_netdev)" echo "$_ifname_opts" >> $_ip_conf fi kdump_setup_dns "$_netdev" } get_ip_route_field() { if `echo $1 | grep -q $2`; then echo ${1##*$2} | cut -d ' ' -f1 fi } #Function:kdump_install_net #$1: config values of net line in kdump.conf #$2: srcaddr of network device kdump_install_net() { local _server _netdev _srcaddr _route _serv_tmp local config_val="$1" _server=$(get_remote_host $config_val) if is_hostname $_server; then _serv_tmp=`getent ahosts $_server | grep -v : | head -n 1` if [ -z "$_serv_tmp" ]; then _serv_tmp=`getent ahosts $_server | head -n 1` fi _server=`echo $_serv_tmp | cut -d' ' -f1` fi _route=`/sbin/ip -o route get to $_server 2>&1` [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 #the field in the ip output changes if we go to another subnet _srcaddr=$(get_ip_route_field "$_route" "src") _netdev=$(get_ip_route_field "$_route" "dev") kdump_setup_netdev "${_netdev}" "${_srcaddr}" #save netdev used for kdump as cmdline # Whoever calling kdump_install_net() is setting up the default gateway, # ie. bootdev/kdumpnic. So don't override the setting if calling # kdump_install_net() for another time. For example, after setting eth0 as # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway. if [ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ] && [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf fi } default_dump_target_install_conf() { local _target _fstype local _mntpoint _save_path is_user_configured_dump_target && return _save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH # strip the duplicated "/" _save_path=$(echo $_save_path | tr -s /) _mntpoint=$(get_mntpoint_from_path $_save_path) _target=$(get_target_from_path $_save_path) if is_atomic && is_bind_mount $_mntpoint; then _save_path=${_save_path##"$_mntpoint"} # the real dump path in the 2nd kernel, if the mount point is bind mounted. _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path _mntpoint=$(get_mntpoint_from_target $_target) # the absolute path in the 1st kernel _save_path=$_mntpoint/$_save_path fi _fstype=$(get_fs_type_from_target $_target) if $(is_fs_type_nfs $_fstype); then kdump_install_net "$_target" _fstype="nfs" else _target=$(kdump_to_udev_name $_target) fi echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf # strip the duplicated "/" _save_path=$(echo $_save_path | tr -s /) # don't touch the path under root mount if [ "$_mntpoint" != "/" ]; then _save_path=${_save_path##"$_mntpoint"} fi #erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf } adjust_bind_mount_path() { local _target=$1 local _save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH # strip the duplicated "/" _save_path=$(echo $_save_path | tr -s /) local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path _absolute_save_path=$(echo "$_absolute_save_path" | tr -s /) local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) if is_bind_mount $_mntpoint; then _save_path=${_absolute_save_path##"$_mntpoint"} # the real dump path in the 2nd kernel, if the mount point is bind mounted. _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path #erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf fi } #install kdump.conf and what user specifies in kdump.conf kdump_install_conf() { sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf while read config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf if is_atomic; then adjust_bind_mount_path "$config_val" fi ;; ssh|nfs) kdump_install_net "$config_val" ;; dracut_args) if [[ $(get_dracut_args_fstype "$config_val") = nfs* ]] ; then kdump_install_net "$(get_dracut_args_target "$config_val")" fi ;; kdump_pre|kdump_post|extra_bins) dracut_install $config_val ;; core_collector) dracut_install "${config_val%%[[:blank:]]*}" ;; esac done <<< "$(read_strip_comments /etc/kdump.conf)" default_dump_target_install_conf kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf" inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f ${initdir}/tmp/$$-kdump.conf } # Default sysctl parameters should suffice for kdump kernel. # Remove custom configurations sysctl.conf & sysctl.d/* remove_sysctl_conf() { # As custom configurations like vm.min_free_kbytes can lead # to OOM issues in kdump kernel, avoid them rm -f "${initdir}/etc/sysctl.conf" rm -rf "${initdir}/etc/sysctl.d" rm -rf "${initdir}/run/sysctl.d" rm -rf "${initdir}/usr/lib/sysctl.d" } kdump_iscsi_get_rec_val() { local result # The open-iscsi 742 release changed to using flat files in # /var/lib/iscsi. result=$(/sbin/iscsiadm --show -m session -r ${1} | grep "^${2} = ") result=${result##* = } echo $result } kdump_get_iscsi_initiator() { local _initiator local initiator_conf="/etc/iscsi/initiatorname.iscsi" [ -f "$initiator_conf" ] || return 1 while read _initiator; do [ -z "${_initiator%%#*}" ] && continue # Skip comment lines case $_initiator in InitiatorName=*) initiator=${_initiator#InitiatorName=} echo "rd.iscsi.initiator=${initiator}" return 0;; *) ;; esac done < ${initiator_conf} return 1 } # Figure out iBFT session according to session type is_ibft() { [ "$(kdump_iscsi_get_rec_val $1 "node.discovery_type")" = fw ] } kdump_setup_iscsi_device() { local path=$1 local tgt_name; local tgt_ipaddr; local username; local password; local userpwd_str; local username_in; local password_in; local userpwd_in_str; local netdev local srcaddr local idev local netroot_str ; local initiator_str; local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi" dinfo "Found iscsi component $1" # Check once before getting explicit values, so we can bail out early, # e.g. in case of pure-hardware(all-offload) iscsi. if ! /sbin/iscsiadm -m session -r ${path} &>/dev/null ; then return 1 fi if is_ibft ${path}; then return fi tgt_name=$(kdump_iscsi_get_rec_val ${path} "node.name") tgt_ipaddr=$(kdump_iscsi_get_rec_val ${path} "node.conn\[0\].address") # get and set username and password details username=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username") [ "$username" == "" ] && username="" password=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password") [ "$password" == "" ] && password="" username_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username_in") [ -n "$username" ] && userpwd_str="$username:$password" # get and set incoming username and password details [ "$username_in" == "" ] && username_in="" password_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password_in") [ "$password_in" == "" ] && password_in="" [ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in" netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \ sed 's|.*dev \(.*\).*|\1|g') srcaddr=$(echo $netdev | awk '{ print $3; exit }') netdev=$(echo $netdev | awk '{ print $1; exit }') kdump_setup_netdev $netdev $srcaddr # prepare netroot= command line # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc. if is_ipv6_address $tgt_ipaddr; then tgt_ipaddr="[$tgt_ipaddr]" fi netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name" [[ -f $netroot_conf ]] || touch $netroot_conf # If netroot target does not exist already, append. if ! grep -q $netroot_str $netroot_conf; then echo $netroot_str >> $netroot_conf dinfo "Appended $netroot_str to $netroot_conf" fi # Setup initator initiator_str=$(kdump_get_iscsi_initiator) [ $? -ne "0" ] && derror "Failed to get initiator name" && return 1 # If initiator details do not exist already, append. if ! grep -q "$initiator_str" $netroot_conf; then echo "$initiator_str" >> $netroot_conf dinfo "Appended "$initiator_str" to $netroot_conf" fi } kdump_check_iscsi_targets () { # If our prerequisites are not met, fail anyways. type -P iscsistart >/dev/null || return 1 kdump_check_setup_iscsi() ( local _dev _dev=$1 [[ -L /sys/dev/block/$_dev ]] || return cd "$(readlink -f /sys/dev/block/$_dev)" until [[ -d sys || -d iscsi_session ]]; do cd .. done [[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD" ) [[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_and_slaves_all kdump_check_setup_iscsi } } # hostname -a is deprecated, do it by ourself get_alias() { local ips local entries local alias_set ips=$(hostname -I) for ip in $ips do # in /etc/hosts, alias can come at the 2nd column entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }') if [ $? -eq 0 ]; then alias_set="$alias_set $entries" fi done echo $alias_set } is_localhost() { local hostnames=$(hostname -A) local shortnames=$(hostname -A -s) local aliasname=$(get_alias) local nodename=$1 hostnames="$hostnames $shortnames $aliasname" for name in ${hostnames}; do if [ "$name" == "$nodename" ]; then return 0 fi done return 1 } # retrieves fence_kdump nodes from Pacemaker cluster configuration get_pcs_fence_kdump_nodes() { local nodes pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1 # get cluster nodes from cluster cib, get interface and ip address nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -` # nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"' # we need to convert each to node1, node2 ... nodeX in each iteration for node in ${nodelist}; do # convert $node from 'uname="nodeX"' to 'nodeX' eval $node nodename=$uname # Skip its own node name if is_localhost $nodename; then continue fi nodes="$nodes $nodename" done echo $nodes } # retrieves fence_kdump args from config file get_pcs_fence_kdump_args() { if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then . $FENCE_KDUMP_CONFIG_FILE echo $FENCE_KDUMP_OPTS fi } get_generic_fence_kdump_nodes() { local filtered local nodes nodes=$(get_option_value "fence_kdump_nodes") for node in ${nodes}; do # Skip its own node name if is_localhost $node; then continue fi filtered="$filtered $node" done echo $filtered } # setup fence_kdump in cluster # setup proper network and install needed files kdump_configure_fence_kdump () { local kdump_cfg_file=$1 local nodes local args if is_generic_fence_kdump; then nodes=$(get_generic_fence_kdump_nodes) elif is_pcs_fence_kdump; then nodes=$(get_pcs_fence_kdump_nodes) # set appropriate options in kdump.conf echo "fence_kdump_nodes $nodes" >> ${kdump_cfg_file} args=$(get_pcs_fence_kdump_args) if [ -n "$args" ]; then echo "fence_kdump_args $args" >> ${kdump_cfg_file} fi else # fence_kdump not configured return 1 fi # setup network for each node for node in ${nodes}; do kdump_install_net $node done dracut_install /etc/hosts dracut_install /etc/nsswitch.conf dracut_install $FENCE_KDUMP_SEND } # Install a random seed used to feed /dev/urandom # By the time kdump service starts, /dev/uramdom is already fed by systemd kdump_install_random_seed() { local poolsize=`cat /proc/sys/kernel/random/poolsize` if [ ! -d ${initdir}/var/lib/ ]; then mkdir -p ${initdir}/var/lib/ fi dd if=/dev/urandom of=${initdir}/var/lib/random-seed \ bs=$poolsize count=1 2> /dev/null } remove_cpu_online_rule() { local file=${initdir}/usr/lib/udev/rules.d/40-redhat.rules sed -i '/SUBSYSTEM=="cpu"/d' $file } install() { local arch kdump_install_conf remove_sysctl_conf # Onlining secondary cpus breaks kdump completely on KVM on Power hosts # Though we use maxcpus=1 by default but 40-redhat.rules will bring up all # possible cpus by default. (rhbz1270174 rhbz1266322) # Thus before we get the kernel fix and the systemd rule fix let's remove # the cpu online rule in kdump initramfs. arch=$(uname -m) if [[ "$arch" = "ppc64le" ]] || [[ "$arch" = "ppc64" ]]; then remove_cpu_online_rule fi if is_ssh_dump_target; then kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" chmod +x ${initdir}/kdumpscripts/monitor_dd_progress inst "/bin/grep" "/bin/grep" inst "/bin/cat" "/bin/cat" inst "/bin/rm" "/bin/rm" inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/bin/head" "/bin/head" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" ln_r "$systemdsystemunitdir/kdump-capture.service" "$systemdsystemunitdir/initrd.target.wants/kdump-capture.service" inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service" # Replace existing emergency service and emergency target cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target" # Also redirect dracut-emergency to kdump error handler ln_r "$systemdsystemunitdir/emergency.service" "$systemdsystemunitdir/dracut-emergency.service" # Check for all the devices and if any device is iscsi, bring up iscsi # target. Ideally all this should be pushed into dracut iscsi module # at some point of time. kdump_check_iscsi_targets # For the lvm type target under kdump, in /etc/lvm/lvm.conf we can # safely replace "reserved_memory=XXXX"(default value is 8192) with # "reserved_memory=1024" to lower memory pressure under kdump. We do # it unconditionally here, if "/etc/lvm/lvm.conf" doesn't exist, it # actually does nothing. sed -i -e \ 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ ${initdir}/etc/lvm/lvm.conf &>/dev/null # Kdump turns out to require longer default systemd mount timeout # than 1st kernel(90s by default), we use default 300s for kdump. grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null if [ $? -ne 0 ]; then mkdir -p ${initdir}/etc/systemd/system.conf.d echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf fi } PK!`qjmodules.d/99kdumpbase/kdump.shnuȯ#!/bin/sh # continue here only if we have to save dump. if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ]; then exit 0 fi exec &> /dev/console . /lib/dracut-lib.sh . /lib/kdump-lib-initramfs.sh set -o pipefail DUMP_RETVAL=0 export PATH=$PATH:$KDUMP_SCRIPT_DIR do_dump() { local _ret eval $DUMP_INSTRUCTION _ret=$? if [ $_ret -ne 0 ]; then echo "kdump: saving vmcore failed" fi return $_ret } do_kdump_pre() { if [ -n "$KDUMP_PRE" ]; then "$KDUMP_PRE" fi } do_kdump_post() { if [ -n "$KDUMP_POST" ]; then "$KDUMP_POST" "$1" fi } add_dump_code() { DUMP_INSTRUCTION=$1 } dump_raw() { local _raw=$1 [ -b "$_raw" ] || return 1 echo "kdump: saving to raw disk $_raw" if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then _src_size=`ls -l /proc/vmcore | cut -d' ' -f5` _src_size_mb=$(($_src_size / 1048576)) monitor_dd_progress $_src_size_mb & fi echo "kdump: saving vmcore" $CORE_COLLECTOR /proc/vmcore | dd of=$_raw bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 sync echo "kdump: saving vmcore complete" return 0 } dump_ssh() { local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" local _host=$2 echo "kdump: saving to $_host:$_dir" cat /var/lib/random-seed > /dev/urandom ssh -q $_opt $_host mkdir -p $_dir || return 1 save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host echo "kdump: saving vmcore" if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" || return 1 ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore" || return 1 else $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" || return 1 ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore.flat" || return 1 fi echo "kdump: saving vmcore complete" return 0 } save_vmcore_dmesg_ssh() { local _dmesg_collector=$1 local _path=$2 local _opts="$3" local _location=$4 echo "kdump: saving vmcore-dmesg.txt" $_dmesg_collector /proc/vmcore | ssh $_opts $_location "dd of=$_path/vmcore-dmesg-incomplete.txt" _exitcode=$? if [ $_exitcode -eq 0 ]; then ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt echo "kdump: saving vmcore-dmesg.txt complete" else echo "kdump: saving vmcore-dmesg.txt failed" fi } get_host_ip() { local _host if is_nfs_dump_target || is_ssh_dump_target then kdumpnic=$(getarg kdumpnic=) [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 _host=`echo $_host | head -n 1 | cut -d' ' -f2` _host="${_host%%/*}" [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host fi return 0 } read_kdump_conf() { if [ ! -f "$KDUMP_CONF" ]; then echo "kdump: $KDUMP_CONF not found" return fi get_kdump_confs # rescan for add code for dump target while read config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in dracut_args) config_val=$(get_dracut_args_target "$config_val") [[ -n "$config_val" ]] && add_dump_code "dump_fs $config_val" ;; ext[234]|xfs|btrfs|minix|nfs) add_dump_code "dump_fs $config_val" ;; raw) add_dump_code "dump_raw $config_val" ;; ssh) add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac done <<< "$(read_strip_comments $KDUMP_CONF)" } fence_kdump_notify() { if [ -n "$FENCE_KDUMP_NODES" ]; then $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & fi } read_kdump_conf fence_kdump_notify get_host_ip if [ $? -ne 0 ]; then echo "kdump: get_host_ip exited with non-zero status!" exit 1 fi if [ -z "$DUMP_INSTRUCTION" ]; then add_dump_code "dump_fs $NEWROOT" fi do_kdump_pre if [ $? -ne 0 ]; then echo "kdump: kdump_pre script exited with non-zero status!" do_final_action fi make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' do_dump DUMP_RETVAL=$? do_kdump_post $DUMP_RETVAL if [ $? -ne 0 ]; then echo "kdump: kdump_post script exited with non-zero status!" fi if [ $DUMP_RETVAL -ne 0 ]; then exit 1 fi do_final_action PK!k+modules.d/99kdumpbase/kdump-capture.servicenu[# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Kdump Vmcore Save Service After=initrd.target initrd-parse-etc.service sysroot.mount After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dracut-pre-pivot.service Before=initrd-cleanup.service ConditionPathExists=/etc/initrd-release OnFailure=emergency.target OnFailureIsolate=yes [Service] Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot Type=oneshot ExecStart=/bin/kdump.sh StandardInput=null StandardOutput=syslog StandardError=syslog+console KillMode=process RemainAfterExit=yes # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP PK!-e -modules.d/99kdumpbase/kdump-emergency.servicenu[# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # This service will be placed in kdump initramfs and replace both the systemd # emergency service and dracut emergency shell. IOW, any emergency will be # kick this service and in turn isolating to kdump error handler. [Unit] Description=Kdump Emergency DefaultDependencies=no IgnoreOnIsolate=yes [Service] ExecStart=/usr/bin/systemctl --no-block isolate kdump-error-handler.service Type=oneshot StandardInput=tty-force StandardOutput=inherit StandardError=inherit KillMode=process IgnoreSIGPIPE=no # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP PK!)modules.d/99kdumpbase/monitor_dd_progressnu[#!/bin/sh SRC_FILE_MB=$1 while true do DD_PID=`pidof dd` if [ -n "$DD_PID" ]; then break fi done while true do sleep 5 if [ ! -d /proc/$DD_PID ]; then break fi kill -s USR1 $DD_PID CURRENT_SIZE=`tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g"` [ -n "$CURRENT_SIZE" ] && { CURRENT_MB=$(($CURRENT_SIZE / 1048576)) echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r" } done rm -f /tmp/dd_progress_file PK!{ 1modules.d/99kdumpbase/kdump-error-handler.servicenu[# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # This service will run the real kdump error handler code. Executing the # default action configured in kdump.conf [Unit] Description=Kdump Error Handler DefaultDependencies=no After=systemd-vconsole-setup.service Wants=systemd-vconsole-setup.service AllowIsolate=yes [Service] Environment=HOME=/ Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot WorkingDirectory=/ ExecStart=/bin/kdump-error-handler.sh ExecStopPost=-/usr/bin/systemctl --fail --no-block default Type=oneshot StandardInput=tty-force StandardOutput=inherit StandardError=inherit KillMode=process IgnoreSIGPIPE=no # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. KillSignal=SIGHUP PK!*modules.d/90kernel-modules/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh installkernel() { if [[ -z $drivers ]]; then block_module_filter() { local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host' # subfunctions inherit following FDs local _merge=8 _side2=9 function bmf1() { local _f while read _f; do case "$_f" in *.ko) [[ $(< $_f) =~ $_blockfuncs ]] && echo "$_f" ;; *.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;; *.ko.xz) [[ $(xz -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;; esac done return 0 } function rotor() { local _f1 _f2 while read _f1; do echo "$_f1" if read _f2; then echo "$_f2" 1>&${_side2} fi done | bmf1 1>&${_merge} return 0 } # Use two parallel streams to filter alternating modules. set +x eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1" [[ $debug ]] && set -x return 0 } hostonly='' instmods \ sr_mod sd_mod scsi_dh ata_piix hid_generic unix \ ehci-hcd ehci-pci ehci-platform \ ohci-hcd ohci-pci \ uhci-hcd \ xhci-hcd xhci-pci xhci-plat-hcd instmods yenta_socket scsi_dh_rdac scsi_dh_emc scsi_dh_alua \ atkbd i8042 usbhid firewire-ohci pcmcia hv-vmbus \ atkbd i8042 usbhid firewire-ohci pcmcia usb_storage \ nvme hv-vmbus sdhci_acpi nfit instmods \ "=drivers/hid" \ "=drivers/input/serio" \ "=drivers/input/keyboard" if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]; then # arm/aarch64 specific modules hostonly='' instmods \ connector-hdmi connector-dvi encoder-tfp410 \ encoder-tpd12s015 i2c-tegra gpio-regulator \ as3722-regulator orion-ehci ehci-tegra instmods \ "=drivers/dma" \ "=drivers/i2c/busses" \ "=drivers/regulator" \ "=drivers/rtc" \ "=drivers/usb/host" \ "=drivers/usb/phy" \ "=drivers/scsi/hisi_sas" \ ${NULL} fi # install virtual machine support instmods virtio virtio_blk virtio_ring virtio_pci virtio_scsi \ "=drivers/pcmcia" =ide "=drivers/usb/storage" find_kernel_modules | block_module_filter | instmods # if not on hostonly mode, install all known filesystems, # if the required list is not set via the filesystems variable if ! [[ $hostonly ]]; then if [[ -z $filesystems ]]; then silent_omit_drivers="kernel/fs/nfs|kernel/fs/nfsd|kernel/fs/lockd" \ instmods '=fs' fi else for i in "${host_fs_types[@]}"; do hostonly='' instmods $i done fi fi : } install() { inst_multiple -o /lib/modprobe.d/*.conf [[ $hostonly ]] && inst_multiple -o /etc/modprobe.d/*.conf /etc/modprobe.conf if ! dracut_module_included "systemd"; then inst_hook cmdline 01 "$moddir/parse-kernel.sh" fi inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh } PK!4*modules.d/90kernel-modules/parse-kernel.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh _modprobe_d=/etc/modprobe.d if [ -d /usr/lib/modprobe.d ] ; then _modprobe_d=/usr/lib/modprobe.d elif [ -d /lib/modprobe.d ] ; then _modprobe_d=/lib/modprobe.d elif [ ! -d $_modprobe_d ] ; then mkdir -p $_modprobe_d fi for i in $(getargs rd.driver.pre -d rdloaddriver=); do ( IFS=, for p in $i; do modprobe $p 2>&1 | vinfo done ) done [ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d for i in $(getargs rd.driver.blacklist -d rdblacklist=); do ( IFS=, for p in $i; do echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf done ) done for p in $(getargs rd.driver.post -d rdinsmodpost=); do echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf _do_insmodpost=1 done [ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh unset _do_insmodpost _modprobe_d PK!q//(modules.d/90kernel-modules/insmodpost.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh . /lib/dracut-lib.sh for modlist in $(getargs rd.driver.post -d rdinsmodpost=); do ( IFS=, for m in $modlist; do modprobe $m done ) done PK!gK#modules.d/98selinux/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { return 255 } depends() { return 0 } install() { inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh" inst_multiple setenforce } PK!FY )modules.d/98selinux/selinux-loadpolicy.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # FIXME: load selinux policy. this should really be done after we switchroot rd_load_policy() { # If SELinux is disabled exit now getarg "selinux=0" > /dev/null && return 0 SELINUX="enforcing" [ -e "$NEWROOT/etc/selinux/config" ] && . "$NEWROOT/etc/selinux/config" # Check whether SELinux is in permissive mode permissive=0 getarg "enforcing=0" > /dev/null if [ $? -eq 0 -o "$SELINUX" = "permissive" ]; then permissive=1 fi # Attempt to load SELinux Policy if [ -x "$NEWROOT/usr/sbin/load_policy" -o -x "$NEWROOT/sbin/load_policy" ]; then local ret=0 local out info "Loading SELinux policy" mount -o bind /sys $NEWROOT/sys # load_policy does mount /proc and /sys/fs/selinux in # libselinux,selinux_init_load_policy() if [ -x "$NEWROOT/sbin/load_policy" ]; then out=$(LANG=C chroot "$NEWROOT" /sbin/load_policy -i 2>&1) ret=$? info $out else out=$(LANG=C chroot "$NEWROOT" /usr/sbin/load_policy -i 2>&1) ret=$? info $out fi umount $NEWROOT/sys/fs/selinux umount $NEWROOT/sys if [ "$SELINUX" = "disabled" ]; then return 0; fi if [ $ret -eq 0 -o $ret -eq 2 ]; then # If machine requires a relabel, force to permissive mode [ -e "$NEWROOT"/.autorelabel ] && LANG=C /usr/sbin/setenforce 0 mount --rbind /dev "$NEWROOT/dev" LANG=C chroot "$NEWROOT" /sbin/restorecon -R /dev umount -R "$NEWROOT/dev" return 0 fi warn "Initial SELinux policy load failed." if [ $ret -eq 3 -o $permissive -eq 0 ]; then warn "Machine in enforcing mode." warn "Not continuing" action_on_fail -n selinux || exit 1 fi return 0 elif [ $permissive -eq 0 -a "$SELINUX" != "disabled" ]; then warn "Machine in enforcing mode and cannot execute load_policy." warn "To disable selinux, add selinux=0 to the kernel command line." warn "Not continuing" action_on_fail -n selinux || exit 1 fi } rd_load_policy PK! $modules.d/98usrmount/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { local _init [[ $mount_needs ]] && return 1 _init=$(readlink -f /sbin/init) [[ "$_init" == "${_init##/usr}" ]] && return 255 return 0 } depends() { echo 'fs-lib' } install() { if ! dracut_module_included "systemd"; then inst_hook pre-pivot 50 "$moddir/mount-usr.sh" fi : } PK!$pp!modules.d/98usrmount/mount-usr.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type info >/dev/null 2>&1 || . /lib/dracut-lib.sh type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh filtersubvol() { local _oldifs _oldifs="$IFS" IFS="," set $* IFS="$_oldifs" while [ $# -gt 0 ]; do case $1 in subvol\=*) :;; *) printf '%s' "${1}," ;; esac shift done } fsck_usr() { local _dev=$1 local _fs=$2 local _fsopts=$3 local _fsckoptions if [ -f "$NEWROOT"/fsckoptions ]; then _fsckoptions=$(cat "$NEWROOT"/fsckoptions) fi if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then _fsckoptions="-f $_fsckoptions" elif [ -f "$NEWROOT"/.autofsck ]; then [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then AUTOFSCK_OPT="$AUTOFSCK_OPT -f" fi if [ -n "$AUTOFSCK_SINGLEUSER" ]; then warn "*** Warning -- the system did not shut down cleanly. " warn "*** Dropping you to a shell; the system will continue" warn "*** when you leave the shell." action_on_fail fi _fsckoptions="$AUTOFSCK_OPT $_fsckoptions" fi fsck_single "$_dev" "$_fs" "$_fsopts" "$_fsckoptions" } mount_usr() { local _dev _mp _fs _opts _rest _usr_found _ret _freq _passno # check, if we have to mount the /usr filesystem while read _dev _mp _fs _opts _freq _passno; do [ "${_dev%%#*}" != "$_dev" ] && continue if [ "$_mp" = "/usr" ]; then case "$_dev" in LABEL=*) _dev="$(echo $_dev | sed 's,/,\\x2f,g')" _dev="/dev/disk/by-label/${_dev#LABEL=}" ;; UUID=*) _dev="${_dev#block:}" _dev="/dev/disk/by-uuid/${_dev#UUID=}" ;; esac if strstr "$_opts" "subvol=" && \ [ "${root#block:}" -ef $_dev ] && \ [ -n "$rflags" ]; then # for btrfs subvolumes we have to mount /usr with the same rflags rflags=$(filtersubvol "$rflags") rflags=${rflags%%,} _opts="${_opts:+${_opts},}${rflags}" elif getargbool 0 ro; then # if "ro" is specified, we want /usr to be mounted read-only _opts="${_opts:+${_opts},}ro" elif getargbool 0 rw; then # if "rw" is specified, we want /usr to be mounted read-write _opts="${_opts:+${_opts},}rw" fi echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_freq $_passno" _usr_found="1" break fi done < "$NEWROOT/etc/fstab" >> /etc/fstab if [ "$_usr_found" != "" ]; then # we have to mount /usr _fsck_ret=0 if ! getargbool 0 rd.skipfsck; then if [ "0" != "${_passno:-0}" ]; then fsck_usr "$_dev" "$_fs" "$_opts" _fsck_ret=$? [ $_fsck_ret -ne 255 ] && echo $_fsck_ret >/run/initramfs/usr-fsck fi fi info "Mounting /usr with -o $_opts" mount "$NEWROOT/usr" 2>&1 | vinfo if ! ismounted "$NEWROOT/usr"; then warn "Mounting /usr to $NEWROOT/usr failed" warn "*** Dropping you to a shell; the system will continue" warn "*** when you leave the shell." action_on_fail fi fi } if [ -f "$NEWROOT/etc/fstab" ]; then mount_usr fi PK!؆x|&&&modules.d/95ssh-client/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # fixme: assume user is root check() { [[ $mount_needs ]] && return 1 # If our prerequisites are not met, fail. require_binaries ssh scp || return 1 if [[ $sshkey ]]; then [ ! -f $sshkey ] && { derror "ssh key: $sshkey is not found!" return 1 } fi return 255 } depends() { # We depend on network modules being loaded echo network } inst_sshenv() { if [ -d /root/.ssh ]; then inst_dir /root/.ssh chmod 700 ${initdir}/root/.ssh fi # Copy over ssh key and knowhosts if needed [[ $sshkey ]] && { inst_simple $sshkey [[ -f /root/.ssh/known_hosts ]] && inst_simple /root/.ssh/known_hosts [[ -f /etc/ssh/ssh_known_hosts ]] && inst_simple /etc/ssh/ssh_known_hosts } # Copy over root and system-wide ssh configs. [[ -f /root/.ssh/config ]] && inst_simple /root/.ssh/config if [[ -f /etc/ssh/ssh_config ]]; then inst_simple /etc/ssh/ssh_config sed -i -e 's/\(^[[:space:]]*\)ProxyCommand/\1# ProxyCommand/' ${initdir}/etc/ssh/ssh_config while read key val || [ -n "$key" ]; do if [[ $key == "GlobalKnownHostsFile" ]]; then inst_simple "$val" # Copy customized UserKnowHostsFile elif [[ $key == "UserKnownHostsFile" ]]; then # Make sure that ~/foo will be copied as /root/foo in kdump's initramfs if str_starts "$val" "~/"; then val="/root/${val#"~/"}" fi inst_simple "$val" fi done < /etc/ssh/ssh_config fi return 0 } install() { inst_multiple ssh scp inst_sshenv } PK!TT'modules.d/97biosdevname/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { [[ "$mount_needs" ]] && return 1 require_binaries biosdevname || return 1 return 0 } depends() { return 0 } install() { inst_multiple biosdevname inst_rules 71-biosdevname.rules } PK!|AV,modules.d/97biosdevname/parse-biosdevname.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh if ! getargbool 1 biosdevname; then info "biosdevname=0: removing biosdevname network renaming" udevproperty UDEV_BIOSDEVNAME= rm -f -- /etc/udev/rules.d/71-biosdevname.rules else info "biosdevname=1: activating biosdevname network renaming" udevproperty UDEV_BIOSDEVNAME=1 fi PK!J%modules.d/98pollcdrom/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { return 255 } depends() { return 0 } install() { inst_hook initqueue/settled 99 "$moddir/pollcdrom.sh" } PK!?"modules.d/98pollcdrom/pollcdrom.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Licensed under the GPLv2 # # Copyright 2008-2012, Red Hat, Inc. # Harald Hoyer if [ ! -e /sys/module/block/parameters/events_dfl_poll_msecs ]; then # if the kernel does not support autopolling # then we have to do a # dirty hack for some cdrom drives, # which report no medium for quiet # some time. for cdrom in /sys/block/sr*; do [ -e "$cdrom" ] || continue # skip, if cdrom medium was already found strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \ ID_CDROM_MEDIA && continue echo change > "$cdrom/uevent" done fi PK!%+[  #modules.d/45url-lib/module-setup.shnuȯ#!/bin/bash # module-setup for url-lib check() { require_binaries curl || return 1 return 255 } depends() { echo network return 0 } install() { local _dir _crt _found _lib inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh" inst_multiple curl # also install libs for curl https inst_libdir_file "libnsspem.so*" inst_libdir_file "libnsssysinit.so*" inst_libdir_file "libsoftokn3.so*" inst_libdir_file "libsqlite3.so*" for _dir in $libdirs; do [[ -d $_dir ]] || continue for _lib in $_dir/libcurl.so.*; do [[ -e $_lib ]] || continue _crt=$(grep -F --binary-files=text -z .crt $_lib) [[ $_crt ]] || continue [[ $_crt == /*/* ]] || continue if ! inst "$_crt"; then dwarn "Couldn't install '$_crt' SSL CA cert bundle; HTTPS might not work." continue fi _found=1 done done [[ $_found ]] || dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work." } PK![ȿׯmodules.d/45url-lib/url-lib.shnuȯ#!/bin/sh # url-lib.sh - functions for handling URLs (file fetching etc.) # # Authors: # Will Woods type mkuniqdir >/dev/null 2>&1 || . /lib/dracut-lib.sh # fetch_url URL [OUTFILE] # fetch the given URL to a locally-visible location. # if OUTFILE is given, the URL will be fetched to that filename, # overwriting it if present. # If the URL is something mountable (e.g. nfs://) and no OUTFILE is given, # the server will be left mounted until pre-pivot. # the return values are as follows: # 0: success # 253: unknown error (file missing) # 254: unhandled URL scheme / protocol # 255: bad arguments / unparseable URLs # other: fetch command failure (whatever curl/mount/etc return) fetch_url() { local url="$1" outloc="$2" local handler="$(get_url_handler $url)" [ -n "$handler" ] || return 254 [ -n "$url" ] || return 255 "$handler" "$url" "$outloc" } # get_url_handler URL # returns the first HANDLERNAME corresponding to the URL's scheme get_url_handler() { local scheme="${1%%:*}" item="" for item in $url_handler_map; do [ "$scheme" = "${item%%:*}" ] && echo "${item#*:}" && return 0 done return 1 } # add_url_handler HANDLERNAME SCHEME [SCHEME...] # associate the named handler with the named scheme(s). add_url_handler() { local handler="$1"; shift local schemes="$@" scheme="" set -- for scheme in $schemes; do [ "$(get_url_handler $scheme)" = "$handler" ] && continue set -- "$@" "$scheme:$handler" done set -- $@ $url_handler_map # add new items to *front* of list url_handler_map="$@" } ### HTTP, HTTPS, FTP ################################################# export CURL_HOME="/run/initramfs/url-lib" mkdir -p $CURL_HOME curl_args="--globoff --location --retry 3 --fail --show-error" getargbool 0 rd.noverifyssl && curl_args="$curl_args --insecure" proxy=$(getarg proxy=) [ -n "$proxy" ] && curl_args="$curl_args --proxy $proxy" curl_fetch_url() { local url="$1" outloc="$2" echo "$url" > /proc/self/fd/0 if [ -n "$outloc" ]; then curl $curl_args --output - -- "$url" > "$outloc" || return $? else local outdir="$(mkuniqdir /tmp curl_fetch_url)" ( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? ) outloc="$outdir/$(ls -A $outdir)" fi if ! [ -f "$outloc" ]; then warn "Downloading '$url' failed!" return 253 fi if [ -z "$2" ]; then echo "$outloc" ; fi } add_url_handler curl_fetch_url http https ftp set_http_header() { echo "header = \"$1: $2\"" >> $CURL_HOME/.curlrc } ### NFS ############################################################## [ -e /lib/nfs-lib.sh ] && . /lib/nfs-lib.sh nfs_already_mounted() { local server="$1" path="$2" localdir="" s="" p="" cat /proc/mounts | while read src mnt rest; do splitsep ":" "$src" s p if [ "$server" = "$s" ]; then if [ "$path" = "$p" ]; then echo $mnt elif str_starts "$path" "$p"; then echo $mnt/${path#$p/} fi fi done } nfs_fetch_url() { local url="$1" outloc="$2" nfs="" server="" path="" options="" nfs_to_var "$url" || return 255 local filepath="${path%/*}" filename="${path##*/}" mntdir="" # skip mount if server:/filepath is already mounted mntdir=$(nfs_already_mounted "$server" "$filepath") if [ -z "$mntdir" ]; then local mntdir="$(mkuniqdir /run nfs_mnt)" mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir" # lazy unmount during pre-pivot hook inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l -- "$mntdir" fi if [ -z "$outloc" ]; then outloc="$mntdir/$filename" else cp -f -- "$mntdir/$filename" "$outloc" || return $? fi [ -f "$outloc" ] || return 253 if [ -z "$2" ]; then echo "$outloc" ; fi } command -v nfs_to_var >/dev/null && add_url_handler nfs_fetch_url nfs nfs4 PK!3  modules.d/95nfs/parse-nfsroot.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Preferred format: # root=nfs[4]:[server:]path[:options] # # This syntax can come from DHCP root-path as well. # # Legacy format: # root=/dev/nfs nfsroot=[server:]path[,options] # # In Legacy root=/dev/nfs mode, if the 'nfsroot' parameter is not given # on the command line or is empty, the dhcp root-path is used as # [server:]path[:options] or the default "/tftpboot/%s" will be used. # # If server is unspecified it will be pulled from one of the following # sources, in order: # static ip= option on kernel command line # DHCP next-server option # DHCP server-id option # DHCP root-path option # # NFSv4 is only used if explicitly requested with nfs4: prefix, otherwise # NFSv3 is used. # type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh # This script is sourced, so root should be set. But let's be paranoid [ -z "$root" ] && root=$(getarg root=) [ -z "$nfsroot" ] && nfsroot=$(getarg nfsroot=) [ -n "$netroot" ] && oldnetroot="$netroot" # netroot= cmdline argument must be ignored, but must be used if # we're inside netroot to parse dhcp root-path if [ -n "$netroot" ] ; then for n in $(getargs netroot=); do [ "$n" = "$netroot" ] && break done if [ "$n" = "$netroot" ]; then #warn "Ignoring netroot argument for NFS" netroot=$root fi else netroot=$root; fi # LEGACY: nfsroot= is valid only if root=/dev/nfs if [ -n "$nfsroot" ] ; then # @deprecated warn "Argument nfsroot is deprecated and might be removed in a future release. See 'man dracut.kernel' for more information." if [ "$(getarg root=)" != "/dev/nfs" ]; then die "Argument nfsroot only accepted for legacy root=/dev/nfs" fi netroot=nfs:$nfsroot; fi case "$netroot" in /dev/nfs) netroot=nfs;; /dev/*) if [ -n "$oldnetroot" ]; then netroot="$oldnetroot" else unset netroot fi return ;; # LEGACY: root=:/> /etc/idmapd.conf fi nfsroot_to_var $netroot [ "$path" = "error" ] && die "Argument nfsroot must contain a valid path!" # Set fstype, might help somewhere fstype=${nfs#/dev/} # Rewrite root so we don't have to parse this uglyness later on again netroot="$fstype:$server:$path:$options" # If we don't have a server, we need dhcp if [ -z "$server" ] ; then DHCPORSERVER="1" fi; # Done, all good! rootok=1 # Shut up init error check or make sure that block parser wont get # confused by having /dev/nfs[4] root="$fstype" echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/nfsroot.sh PK!]ic99modules.d/95nfs/nfsroot.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh . /lib/nfs-lib.sh [ "$#" = 3 ] || exit 1 # root is in the form root=nfs[4]:[server:]path[:options], either from # cmdline or dhcp root-path netif="$1" root="$2" NEWROOT="$3" nfs_to_var $root $netif [ -z "$server" ] && die "Required parameter 'server' is missing" mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || ln -s null /dev/root ; [ -e /dev/nfs ] || ln -s null /dev/nfs; } [ -f $NEWROOT/etc/fstab ] && cat $NEWROOT/etc/fstab > /dev/null # inject new exit_if_exists echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm -- "$job"' > $hookdir/initqueue/nfs.sh # force udevsettle to break > $hookdir/initqueue/work need_shutdown PK!@ @ modules.d/95nfs/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { # If our prerequisites are not met, fail anyways. require_any_binary rpcbind portmap || return 1 require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1 [[ $hostonly ]] || [[ $mount_needs ]] && { for fs in "${host_fs_types[@]}"; do [[ "$fs" == "nfs" ]] && return 0 [[ "$fs" == "nfs3" ]] && return 0 [[ "$fs" == "nfs4" ]] && return 0 done return 255 } return 0 } depends() { # We depend on network modules being loaded echo network } installkernel() { hostonly='' instmods =net/sunrpc =fs/nfs ipv6 nfs_acl nfs_layout_nfsv41_files } install() { local _i local _nsslibs inst_multiple -o portmap rpcbind rpc.statd mount.nfs \ mount.nfs4 umount rpc.idmapd sed /etc/netconfig inst_multiple /etc/services /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/idmapd.conf if [ -f /lib/modprobe.d/nfs.conf ]; then inst_multiple /lib/modprobe.d/nfs.conf else [ -d $initdir/etc/modprobe.d/ ] || mkdir $initdir/etc/modprobe.d echo "alias nfs4 nfs" > $initdir/etc/modprobe.d/nfs.conf fi inst_libdir_file 'libnfsidmap_nsswitch.so*' 'libnfsidmap/*.so' 'libnfsidmap*.so*' _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|') _nsslibs=${_nsslibs#|} _nsslibs=${_nsslibs%|} inst_libdir_file -n "$_nsslibs" 'libnss_*.so*' inst_hook cmdline 90 "$moddir/parse-nfsroot.sh" inst_hook pre-udev 99 "$moddir/nfs-start-rpc.sh" inst_hook cleanup 99 "$moddir/nfsroot-cleanup.sh" inst "$moddir/nfsroot.sh" "/sbin/nfsroot" inst "$moddir/nfs-lib.sh" "/lib/nfs-lib.sh" mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs" mkdir -m 0755 -p "$initdir/var/lib/rpcbind" mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm" # Rather than copy the passwd file in, just set a user for rpcbind # We'll save the state and restart the daemon from the root anyway egrep '^nfsnobody:|^rpc:|^rpcuser:' /etc/passwd >> "$initdir/etc/passwd" egrep '^nogroup:|^rpc:|^nobody:' /etc/group >> "$initdir/etc/group" # rpc user needs to be able to write to this directory to save the warmstart # file chmod 770 "$initdir/var/lib/rpcbind" egrep -q '^rpc:' /etc/passwd \ && egrep -q '^rpc:' /etc/group \ && chown rpc.rpc "$initdir/var/lib/rpcbind" dracut_need_initqueue } PK!ߖfmodules.d/95nfs/nfs-lib.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh . /lib/net-lib.sh # TODO: make these things not pollute the calling namespace # nfs_to_var NFSROOT [NETIF] # use NFSROOT to set $nfs, $server, $path, and $options. # NFSROOT is something like: nfs[4]::/[:|,] # NETIF is used to get information from DHCP options, if needed. nfs_to_var() { # Unfortunately, there's multiple styles of nfs "URL" in use, so we need # extra functions to parse them into $nfs, $server, $path, and $options. # FIXME: local netif=${2:-$netif}? case "$1" in nfs://*) rfc2224_nfs_to_var "$1" ;; nfs:*[*) anaconda_nfsv6_to_var "$1" ;; nfs:*:*:/*) anaconda_nfs_to_var "$1" ;; *) nfsroot_to_var "$1" ;; esac # if anything's missing, try to fill it in from DHCP options if [ -z "$server" ] || [ -z "$path" ]; then nfsroot_from_dhcp $2; fi # if there's a "%s" in the path, replace it with the hostname/IP if strstr "$path" "%s"; then local node="" read node < /proc/sys/kernel/hostname [ "$node" = "(none)" ] && node=$(get_ip $2) path=${path%%%s*}$node${path#*%s} # replace only the first %s fi } # root=nfs:[:][:] # root=nfs4:[:][:] nfsroot_to_var() { # strip nfs[4]: local arg="$@:" nfs="${arg%%:*}" arg="${arg##$nfs:}" # check if we have a server if strstr "$arg" ':/*' ; then server="${arg%%:/*}" arg="/${arg##*:/}" fi path="${arg%%:*}" # rest are options options="${arg##$path}" # strip leading ":" options="${options##:}" # strip ":" options="${options%%:}" # Does it really start with '/'? [ -n "${path%%/*}" ] && path="error"; #Fix kernel legacy style separating path and options with ',' if [ "$path" != "${path#*,}" ] ; then options=${path#*,} path=${path%%,*} fi } # RFC2224: nfs://[:]/ rfc2224_nfs_to_var() { nfs="nfs" server="${1#nfs://}" path="/${server#*/}" server="${server%%/*}" server="${server%%:}" # anaconda compat (nfs://:/) local port="${server##*:}" [ "$port" != "$server" ] && options="port=$port" } # Anaconda-style path with options: nfs:::/ # (without mount options, anaconda is the same as dracut) anaconda_nfs_to_var() { nfs="nfs" options="${1#nfs:}" server="${options#*:}" server="${server%:/*}" options="${options%%:*}" path="/${1##*:/}" } # IPv6 nfs path will be treated separately anaconda_nfsv6_to_var() { nfs="nfs" path="$1:" options="${path#*:/}" path="/${options%%:*}" server="${1#*nfs:}" if str_starts $server '['; then server="${server%:/*}" options="${options#*:*}" else server="${server%:/*}" options="${server%%:*}" server="${server#*:}" fi } # nfsroot_from_dhcp NETIF # fill in missing server/path from DHCP options. nfsroot_from_dhcp() { local f for f in /tmp/net.$1.override /tmp/dhclient.$1.dhcpopts; do [ -f $f ] && . $f done [ -n "$new_root_path" ] && nfsroot_to_var "$nfs:$new_root_path" [ -z "$path" ] && [ "$(getarg root=)" == "/dev/nfs" ] && path=/tftpboot/%s [ -z "$server" ] && server=$srv [ -z "$server" ] && server=$new_dhcp_server_identifier [ -z "$server" ] && server=$new_next_server [ -z "$server" ] && server=${new_root_path%%:*} } # Look through $options, fix "rw"/"ro", move "lock"/"nolock" to $nfslock munge_nfs_options() { local f="" flags="" nfsrw="ro" OLDIFS="$IFS" IFS=, for f in $options; do case $f in ro|rw) nfsrw=$f ;; lock|nolock) nfslock=$f ;; *) flags=${flags:+$flags,}$f ;; esac done IFS="$OLDIFS" # Override rw/ro if set on cmdline getarg ro >/dev/null && nfsrw=ro getarg rw >/dev/null && nfsrw=rw options=$nfsrw${flags:+,$flags} } # mount_nfs NFSROOT MNTDIR [NETIF] mount_nfs() { local nfsroot="$1" mntdir="$2" netif="$3" local nfs="" server="" path="" options="" nfs_to_var "$nfsroot" $netif munge_nfs_options if [ "$nfs" = "nfs4" ]; then options=$options${nfslock:+,$nfslock} else # NFSv{2,3} doesn't support using locks as it requires a helper to # transfer the rpcbind state to the new root [ "$nfslock" = "lock" ] \ && warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2 options=$options,nolock fi mount -t $nfs -o$options "$server:$path" "$mntdir" } PK!"modules.d/95nfs/nfsroot-cleanup.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type incol2 >/dev/null 2>&1 || . /lib/dracut-lib.sh [ -f /tmp/nfs.rpc_pipefs_path ] && rpcpipefspath=`cat /tmp/nfs.rpc_pipefs_path` [ -z "$rpcpipefspath" ] && rpcpipefspath=var/lib/nfs/rpc_pipefs pid=$(pidof rpc.statd) [ -n "$pid" ] && kill $pid pid=$(pidof rpc.idmapd) [ -n "$pid" ] && kill $pid pid=$(pidof rpcbind) [ -n "$pid" ] && kill $pid if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then # try to create the destination directory [ -d $NEWROOT/$rpcpipefspath ] || \ mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2>/dev/null if [ -d $NEWROOT/$rpcpipefspath ]; then # mount --move does not seem to work??? mount --bind /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath umount /var/lib/nfs/rpc_pipefs 2>/dev/null else umount /var/lib/nfs/rpc_pipefs 2>/dev/null fi fi PK!>9 modules.d/95nfs/nfs-start-rpc.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then [ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \ mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs # Start rpcbind or rpcbind # FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why? command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind # Start rpc.statd as mount won't let us use locks on a NFSv4 # filesystem without talking to it. NFSv4 does locks internally, # rpc.lockd isn't needed [ -z "$(pidof rpc.statd)" ] && rpc.statd [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd else warn 'Kernel module "sunrpc" not in the initramfs, or support for filesystem "rpc_pipefs" missing!' fi PK!( modules.d/95nbd/parse-nbdroot.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Preferred format: # root=nbd:srv:port[:fstype[:rootflags[:nbdopts]]] # [root=*] netroot=nbd:srv:port[:fstype[:rootflags[:nbdopts]]] # # nbdopts is a comma separated list of options to give to nbd-client # # root= takes precedence over netroot= if root=nbd[...] # # Sadly there's no easy way to split ':' separated lines into variables netroot_to_var() { local v=${1}: set -- while [ -n "$v" ]; do set -- "$@" "${v%%:*}" v=${v#*:} done unset server port server=$2; port=$3; } # This script is sourced, so root should be set. But let's be paranoid [ -z "$root" ] && root=$(getarg root=) if [ -z "$netroot" ]; then for netroot in $(getargs netroot=); do [ "${netroot%%:*}" = "nbd" ] && break done [ "${netroot%%:*}" = "nbd" ] || unset netroot fi # Root takes precedence over netroot if [ "${root%%:*}" = "nbd" ] ; then if [ -n "$netroot" ] ; then warn "root takes precedence over netroot. Ignoring netroot" fi netroot=$root unset root fi # If it's not nbd we don't continue [ "${netroot%%:*}" = "nbd" ] || return # Check required arguments netroot_to_var $netroot [ -z "$server" ] && die "Argument server for nbdroot is missing" [ -z "$port" ] && die "Argument port for nbdroot is missing" # NBD actually supported? incol2 /proc/devices nbd || modprobe nbd || die "nbdroot requested but kernel/initrd does not support nbd" # Done, all good! rootok=1 # Shut up init error check if [ -z "$root" ]; then root=block:/dev/root wait_for_dev -n /dev/root fi PK!($modules.d/95nbd/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { local _rootdev # if an nbd device is not somewhere in the chain of devices root is # mounted on, fail the hostonly check. [[ $hostonly ]] || [[ $mount_needs ]] && { is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;} _rootdev=$(find_root_block_device) [[ -b /dev/block/$_rootdev ]] || return 1 check_block_and_slaves is_nbd "$_rootdev" || return 255 } require_binaries nbd-client || return 1 return 0 } depends() { # We depend on network modules being loaded echo network rootfs-block } installkernel() { instmods nbd } install() { inst nbd-client inst_hook cmdline 90 "$moddir/parse-nbdroot.sh" inst_script "$moddir/nbdroot.sh" "/sbin/nbdroot" dracut_need_initqueue } PK!MK* * modules.d/95nbd/nbdroot.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh PATH=/usr/sbin:/usr/bin:/sbin:/bin # Huh? Empty $1? [ -z "$1" ] && exit 1 # Huh? Empty $2? [ -z "$2" ] && exit 1 # Huh? Empty $3? [ -z "$3" ] && exit 1 # root is in the form root=nbd:srv:port[:fstype[:rootflags[:nbdopts]]] netif="$1" nroot="$2" NEWROOT="$3" # If it's not nbd we don't continue [ "${nroot%%:*}" = "nbd" ] || return nroot=${nroot#nbd:} nbdserver=${nroot%%:*}; nroot=${nroot#*:} nbdport=${nroot%%:*}; nroot=${nroot#*:} nbdfstype=${nroot%%:*}; nroot=${nroot#*:} nbdflags=${nroot%%:*} nbdopts=${nroot#*:} # If nbdport not an integer, then assume name based import if [ ! -z $(echo "$nbdport" | sed 's/[0-9]//g') ]; then nbdport="-N $nbdport" fi if [ "$nbdopts" = "$nbdflags" ]; then unset nbdopts fi if [ "$nbdflags" = "$nbdfstype" ]; then unset nbdflags fi if [ "$nbdfstype" = "$nbdport" ]; then unset nbdfstype fi if [ -z "$nbdfstype" ]; then nbdfstype=auto fi # look through the NBD options and pull out the ones that need to # go before the host etc. Append a ',' so we know we terminate the loop nbdopts=${nbdopts}, while [ -n "$nbdopts" ]; do f=${nbdopts%%,*} nbdopts=${nbdopts#*,} if [ -z "$f" ]; then break fi if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then preopts="$preopts $f" continue fi opts="$opts $f" done # look through the flags and see if any are overridden by the command line nbdflags=${nbdflags}, while [ -n "$nbdflags" ]; do f=${nbdflags%%,*} nbdflags=${nbdflags#*,} if [ -z "$f" ]; then break fi if [ "$f" = "ro" -o "$f" = "rw" ]; then nbdrw=$f continue fi fsopts=${fsopts:+$fsopts,}$f done getarg ro && nbdrw=ro getarg rw && nbdrw=rw fsopts=${fsopts:+$fsopts,}${nbdrw} # XXX better way to wait for the device to be made? i=0 while [ ! -b /dev/nbd0 ]; do [ $i -ge 20 ] && exit 1 if [ $UDEVVERSION -ge 143 ]; then udevadm settle --exit-if-exists=/dev/nbd0 else sleep 0.1 fi i=$(($i + 1)) done # If we didn't get a root= on the command line, then we need to # add the udev rules for mounting the nbd0 device if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-nbd-root.rules udevadm control --reload type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh write_fs_tab /dev/root "$nbdfstype" "$fsopts" wait_for_dev -n /dev/root if [ -z "$DRACUT_SYSTEMD" ]; then printf '/bin/mount %s\n' \ "$NEWROOT" \ > $hookdir/mount/01-$$-nbd.sh fi fi if strstr "$(nbd-client --help 2>&1)" "systemd-mark"; then preopts="--systemd-mark $preopts" fi nbd-client $preopts "$nbdserver" $nbdport /dev/nbd0 $opts || exit 1 # NBD doesn't emit uevents when it gets connected, so kick it echo change > /sys/block/nbd0/uevent udevadm settle need_shutdown exit 0 PK!x&1; ) fi PK!J+modules.d/50plymouth/plymouth-pretrigger.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh if type plymouthd >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -d -n rd_NO_PLYMOUTH; then # first trigger graphics subsystem udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1 # first trigger graphics and tty subsystem udevadm trigger --action=add --subsystem-match=graphics --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1 udevadm settle --timeout=30 2>&1 | vinfo info "Starting plymouth daemon" mkdir -m 0755 /run/plymouth read consoledev rest < /sys/class/tty/console/active consoledev=${consoledev:-tty0} [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" plymouthd --attach-to-session --pid-file /run/plymouth/pid plymouth --show-splash 2>&1 | vinfo # reset tty after plymouth messed with it [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" fi fi PK! L*modules.d/50plymouth/plymouth-emergency.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh plymouth --hide-splash 2>/dev/null || : PK!6(modules.d/50plymouth/plymouth-newroot.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh if type plymouth >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then plymouth --newroot=$NEWROOT fi PK! modules.d/90dm/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { require_binaries dmsetup || return 1 return 255 } depends() { return 0 } installkernel() { instmods =drivers/md instmods dm_mod dm-cache dm-cache-mq dm-cache-cleaner } install() { modinfo -k $kernel dm_mod >/dev/null 2>&1 && \ inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh" inst_multiple dmsetup inst_multiple -o dmeventd inst_libdir_file "libdevmapper-event.so*" inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules # Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules # files, but provides the one below: inst_rules 64-device-mapper.rules # debian udev rules inst_rules 60-persistent-storage-dm.rules 55-dm.rules inst_rules "$moddir/11-dm.rules" inst_rules "$moddir/59-persistent-storage-dm.rules" prepare_udev_rules 59-persistent-storage-dm.rules inst_hook shutdown 30 "$moddir/dm-shutdown.sh" } PK!Ӵlmodules.d/90dm/11-dm.rulesnu[SUBSYSTEM!="block", GOTO="dm_end" KERNEL!="dm-[0-9]*", GOTO="dm_end" ACTION!="add|change", GOTO="dm_end" OPTIONS+="db_persist" LABEL="dm_end" PK!~-modules.d/90dm/59-persistent-storage-dm.rulesnu[SUBSYSTEM!="block", GOTO="dm_end" ACTION!="add|change", GOTO="dm_end" # Also don't process disks that are slated to be a multipath device ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="dm_end" KERNEL!="dm-[0-9]*", GOTO="dm_end" ACTION=="add", GOTO="dm_end" IMPORT{program}="/sbin/dmsetup info -c --nameprefixes --unquoted --rows --noheadings -o name,uuid,suspended,readonly,major,minor,open,tables_loaded,names_using_dev -j%M -m%m" ENV{DM_NAME}!="?*", GOTO="dm_end" ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_end" ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="dm_end" ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="dm_end" IMPORT BLKID LABEL="dm_end" PK!h:modules.d/90dm/dm-pre-udev.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod modprobe dm_mirror 2>/dev/null PK!lOOmodules.d/90dm/dm-shutdown.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh _do_dm_shutdown() { local ret local final=$1 info "Disassembling device-mapper devices" dmsetup -v remove_all ret=$? if [ "x$final" != "x" ]; then info "dmsetup ls --tree" dmsetup ls --tree 2>&1 | vinfo fi return $ret } if command -v dmsetup >/dev/null; then _do_dm_shutdown $1 else : fi PK!%modules.d/90dmraid/dmraid.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh dev="$1" devenc=$(str_replace "$1" '/' '\2f') [ -e /tmp/dmraid.$devenc ] && exit 0 >/tmp/dmraid.$devenc DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=) if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then DM_CLEANUP="no" # run dmraid if udev has settled info "Scanning for dmraid devices $DM_RAIDS" SETS=$(dmraid -c -s) if [ "$SETS" = "no raid disks" -o "$SETS" = "no raid sets" ]; then return fi info "Found dmraid sets:" echo $SETS|vinfo if [ -n "$DM_RAIDS" ]; then # only activate specified DM RAIDS for r in $DM_RAIDS; do for s in $SETS; do if [ "${s##$r}" != "$s" ]; then info "Activating $s" dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo [ -e "/dev/mapper/$s" ] && kpartx -a "/dev/mapper/$s" 2>&1 | vinfo udevsettle fi done done else # scan and activate all DM RAIDS for s in $SETS; do info "Activating $s" dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo [ -e "/dev/mapper/$s" ] && kpartx -a "/dev/mapper/$s" 2>&1 | vinfo done fi need_shutdown fi PK!MFF"modules.d/90dmraid/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { local _rootdev # if we don't have dmraid installed on the host system, no point # in trying to support it in the initramfs. require_binaries dmraid || return 1 [[ $hostonly ]] || [[ $mount_needs ]] && { for dev in "${!host_fs_types[@]}"; do [[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue DEVPATH=$(get_devpath_block "$dev") for holder in "$DEVPATH"/holders/*; do [[ -e "$holder" ]] || continue [[ -e "$holder/dm" ]] && return 0 break done done return 255 } return 0 } depends() { echo dm rootfs-block return 0 } cmdline() { local _activated declare -A _activated for dev in "${!host_fs_types[@]}"; do local holder DEVPATH DM_NAME majmin [[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue DEVPATH=$(get_devpath_block "$dev") for holder in "$DEVPATH"/holders/*; do [[ -e "$holder" ]] || continue dev="/dev/${holder##*/}" DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2>/dev/null)" [[ ${DM_NAME} ]] && break done [[ ${DM_NAME} ]] || continue if ! [[ ${_activated[${DM_NAME}]} ]]; then printf "%s" " rd.dm.uuid=${DM_NAME}" _activated["${DM_NAME}"]=1 fi done } install() { local _i if [[ $hostonly_cmdline == "yes" ]]; then cmdline >> "${initdir}/etc/cmdline.d/90dmraid.conf" echo >> "${initdir}/etc/cmdline.d/90dmraid.conf" fi inst_multiple dmraid inst_multiple -o kpartx inst $(command -v partx) /sbin/partx inst "$moddir/dmraid.sh" /sbin/dmraid_scan inst_rules 64-md-raid.rules inst_libdir_file "libdmraid-events*.so*" inst_rules "$moddir/61-dmraid-imsm.rules" #inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup inst_hook pre-trigger 30 "$moddir/parse-dm.sh" } PK!y'modules.d/90dmraid/61-dmraid-imsm.rulesnu[# This file causes block devices with RAID (dmraid) signatures to # automatically cause dmraid_scan to be run. # See udev(8) for syntax SUBSYSTEM!="block", GOTO="dm_end" ACTION!="add|change", GOTO="dm_end" # Also don't process disks that are slated to be a multipath device ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="dm_end" ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end" ENV{ID_FS_TYPE}!="*_raid_member", , GOTO="dm_end" ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}!="?*", GOTO="dm_end" ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}!="?*", GOTO="dm_end" ENV{rd_NO_DM}=="?*", GOTO="dm_end" ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_end" PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/dm-[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \ GOTO="dm_end" ENV{DEVTYPE}!="partition", \ RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}" RUN+="/sbin/initqueue --onetime --unique --settled /sbin/dmraid_scan $env{DEVNAME}" LABEL="dm_end" PK!modules.d/90dmraid/parse-dm.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # nodmraid for anaconda / rc.sysinit compatibility if ! getargbool 1 rd.dm -d -n rd_NO_DM || getarg "rd.dm=0" -d nodmraid; then info "rd.dm=0: removing DM RAID activation" udevproperty rd_NO_DM=1 fi if ! command -v mdadm >/dev/null \ || ! getargbool 1 rd.md.imsm -d -n rd_NO_MDIMSM -n noiswmd \ || ! getargbool 1 rd.md -d -n rd_NO_MD; then info "rd.md.imsm=0: no MD RAID for imsm/isw raids" udevproperty rd_NO_MDIMSM=1 fi if ! command -v mdadm >/dev/null \ || ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF -n noddfmd \ || ! getargbool 1 rd.md -d -n rd_NO_MD; then info "rd.md.ddf=0: no MD RAID for SNIA ddf raids" udevproperty rd_NO_MDDDF=1 fi DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=) if [ -z "$DM_RAIDS" ] && ! getargbool 0 rd.auto; then udevproperty rd_NO_DM=1 fi PK!^z$modules.d/95terminfo/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh install() { local _terminfodir # terminfo bits make things work better if you fall into interactive mode for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do [ -f ${_terminfodir}/l/linux ] && break done if [ -d ${_terminfodir} ]; then for i in "l/linux" "v/vt100" "v/vt102" "v/vt220"; do inst_dir "$_terminfodir/${i%/*}" cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_terminfodir}/${i%/*}" "$_terminfodir/$i" done fi } PK!O%modules.d/99base/initqueue.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Licensed under the GPLv2+ # # Copyright 2008-2010, Red Hat, Inc. # Harald Hoyer PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh while [ $# -gt 0 ]; do case "$1" in --onetime) onetime="yes";; --online) qname="/online";; --settled) qname="/settled";; --finished) qname="/finished";; --timeout) qname="/timeout";; --unique) unique="yes";; --name) name="$2";shift;; --env) env="$2"; shift;; *) break;; esac shift done if [ -z "$unique" ]; then job="${name}$$" else job="${name:-$1}" job=${job##*/} fi exe=$1 shift [ -x "$exe" ] || exe=$(command -v $exe) { [ -n "$onetime" ] && echo '[ -e "$job" ] && rm -f -- "$job"' [ -n "$env" ] && echo "$env" echo "$exe" "$@" } > "/tmp/$$-${job}.sh" mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh" [ -z "$qname" ] && >> $hookdir/initqueue/work exit 0 PK!1.vmodules.d/99base/memtrace-ko.shnuȯ#!/bin/sh # Try to find out kernel modules with large total memory allocation during loading. # For large slab allocation, it will fall into buddy, also not trace "mm_page_free" # considering large free is quite rare for module_init, thus saving tons of events # to avoid trace data overwritten. # # Therefore, tracing "mm_page_alloc"alone should be enough for the purpose. # "sys/kernel/tracing" has the priority if exists. get_trace_base() { # trace access through debugfs would be obsolete if "/sys/kernel/tracing" is available. if [ -d "/sys/kernel/tracing" ]; then echo "/sys/kernel" else echo "/sys/kernel/debug" fi } # We want to enable these trace events. get_want_events() { echo "module:module_put module:module_load kmem:mm_page_alloc" } get_event_filter() { echo "comm == systemd-udevd || comm == modprobe || comm == insmod" } is_trace_ready() { local trace_base want_events current_events trace_base=$(get_trace_base) ! [ -f "$trace_base/tracing/trace" ] && return 1 [ "$(cat $trace_base/tracing/tracing_on)" -eq 0 ] && return 1 # Also check if trace events were properly setup. want_events=$(get_want_events) current_events=$(echo $(cat $trace_base/tracing/set_event)) [ "$current_events" != "$want_events" ] && return 1 return 0 } prepare_trace() { local trace_base trace_base=$(get_trace_base) # old debugfs interface case. if ! [ -d "$trace_base/tracing" ]; then mount none -t debugfs $trace_base # new tracefs interface case. elif ! [ -f "$trace_base/tracing/trace" ]; then mount none -t tracefs "$trace_base/tracing" fi if ! [ -f "$trace_base/tracing/trace" ]; then echo "WARN: Mount trace failed for kernel module memory analyzing." return 1 fi # Active all the wanted trace events. echo "$(get_want_events)" > $trace_base/tracing/set_event # There are three kinds of known applications for module loading: # "systemd-udevd", "modprobe" and "insmod". # Set them as the global events filter. # NOTE: Some kernel may not support this format of filter, anyway # the operation will fail and it doesn't matter. echo "$(get_event_filter)" > $trace_base/tracing/events/kmem/filter 2>&1 echo "$(get_event_filter)" > $trace_base/tracing/events/module/filter 2>&1 # Set the number of comm-pid if supported. if [ -f "$trace_base/tracing/saved_cmdlines_size" ]; then # Thanks to filters, 4096 is big enough(also well supported). echo 4096 > $trace_base/tracing/saved_cmdlines_size fi # Enable and clear trace data for the first time. echo 1 > $trace_base/tracing/tracing_on echo > $trace_base/tracing/trace echo "Prepare trace success." return 0 } order_to_pages() { local pages=1 local order=$1 while [ "$order" != 0 ]; do order=$((order-1)) pages=$(($pages*2)) done echo $pages } parse_trace_data() { local module_name tmp_eval pages cat "$(get_trace_base)/tracing/trace" | while read pid cpu flags ts function args do # Skip comment lines if [ "$pid" = "#" ]; then continue fi pid=${pid##*-} function=${function%:} if [ "$function" = "module_load" ]; then # One module is being loaded, save the task pid for tracking. # Remove the trailing after whitespace, there may be the module flags. module_name=${args%% *} # Mark current_module to track the task. eval current_module_$pid="$module_name" tmp_eval=$(eval echo '${module_loaded_'${module_name}'}') if [ -n "$tmp_eval" ]; then echo "WARN: \"$module_name\" was loaded multiple times!" fi eval unset module_loaded_$module_name eval nr_alloc_pages_$module_name=0 continue fi module_name=$(eval echo '${current_module_'${pid}'}') if [ -z "$module_name" ]; then continue fi # Once we get here, the task is being tracked(is loading a module). if [ "$function" = "module_put" ]; then # Mark the module as loaded when the first module_put event happens after module_load. tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}') echo "$tmp_eval pages consumed by \"$module_name\"" eval module_loaded_$module_name=1 # Module loading finished, so untrack the task. eval unset current_module_$pid eval unset nr_alloc_pages_$module_name continue fi if [ "$function" = "mm_page_alloc" ]; then # Get order first, then convert to actual pages. pages=$(echo $args | sed -e 's/.*order=\([0-9]*\) .*/\1/') pages=$(order_to_pages "$pages") tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}') eval nr_alloc_pages_$module_name="$(($tmp_eval+$pages))" fi done } cleanup_trace() { local trace_base if is_trace_ready; then trace_base=$(get_trace_base) echo 0 > $trace_base/tracing/tracing_on echo > $trace_base/tracing/trace echo > $trace_base/tracing/set_event echo 0 > $trace_base/tracing/events/kmem/filter echo 0 > $trace_base/tracing/events/module/filter fi } show_usage() { echo "Find out kernel modules with large memory consumption during loading based on trace." echo "Usage:" echo "1) run it first to setup trace." echo "2) run again to parse the trace data if any." echo "3) run with \"--cleanup\" option to cleanup trace after use." } if [ "$1" = "--help" ]; then show_usage exit 0 fi if [ "$1" = "--cleanup" ]; then cleanup_trace exit 0 fi if is_trace_ready ; then echo "tracekomem - Rough memory consumption by loading kernel modules (larger value with better accuracy)" parse_trace_data else prepare_trace fi exit $? PK! Zۮmodules.d/99base/rdsosreport.shnuȯ#!/bin/sh echo 'Generating "/run/initramfs/rdsosreport.txt"' [ -d /run/initramfs ] || mkdir -p /run/initramfs exec >/run/initramfs/rdsosreport.txt 2>&1 set -x cat /lib/dracut/dracut-* cat /proc/cmdline [ -f /etc/cmdline ] && cat /etc/cmdline for _i in /etc/cmdline.d/*.conf; do [ -f "$_i" ] || break echo $_i cat $_i done cat /proc/self/mountinfo cat /proc/mounts blkid blkid -o udev ls -l /dev/disk/by* for _i in /etc/conf.d/*.conf; do [ -f "$_i" ] || break echo $_i cat $_i done if command -v lvm >/dev/null 2>/dev/null; then lvm pvdisplay lvm vgdisplay lvm lvdisplay fi command -v dmsetup >/dev/null 2>/dev/null && dmsetup ls --tree cat /proc/mdstat command -v ip >/dev/null 2>/dev/null && ip addr if command -v journalctl >/dev/null 2>/dev/null; then journalctl -ab --no-pager -o short-monotonic else dmesg [ -f /run/initramfs/init.log ] && cat /run/initramfs/init.log fi PK!cJ modules.d/99base/module-setup.shnuȯ#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh check() { return 0 } depends() { echo udev-rules return 0 } install() { local _d inst_multiple mount mknod mkdir sleep chroot \ sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid inst $(command -v modprobe) /sbin/modprobe inst_multiple -o findmnt less kmod if [ ! -e "${initdir}/bin/sh" ]; then inst_multiple bash (ln -s bash "${initdir}/bin/sh" || :) fi #add common users in /etc/passwd, it will be used by nfs/ssh currently egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo 'root:x:0:0::/root:/bin/sh' >> "$initdir/etc/passwd" egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd" # install our scripts and hooks inst_script "$moddir/init.sh" "/init" inst_script "$moddir/initqueue.sh" "/sbin/initqueue" inst_script "$moddir/loginit.sh" "/sbin/loginit" inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport" inst_script "$moddir/memtrace-ko.sh" "/sbin/tracekomem" [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib mkdir -m 0755 -p ${initdir}/lib/dracut mkdir -m 0755 -p ${initdir}/lib/dracut/hooks mkdir -p ${initdir}/tmp inst_simple "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh" if ! dracut_module_included "systemd"; then inst_multiple switch_root || dfatal "Failed to install switch_root" inst_hook cmdline 10 "$moddir/parse-root-opts.sh" fi mkdir -p "${initdir}/var" if ! dracut_module_included "systemd"; then inst_multiple -o $systemdutildir/systemd-timestamp fi if [[ $realinitpath ]]; then for i in $realinitpath; do echo "rd.distroinit=$i" done > "${initdir}/etc/cmdline.d/distroinit.conf" fi ln -fs /proc/self/mounts "$initdir/etc/mtab" if [[ $ro_mnt = yes ]]; then echo ro >> "${initdir}/etc/cmdline.d/base.conf" fi if [ -e /etc/os-release ]; then . /etc/os-release VERSION+=" " PRETTY_NAME+=" " else VERSION="" PRETTY_NAME="" fi NAME=dracut ID=dracut VERSION+="dracut-$DRACUT_VERSION" PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)" VERSION_ID=$DRACUT_VERSION ANSI_COLOR="0;34" { echo NAME=\"$NAME\" echo VERSION=\"$VERSION\" echo ID=$ID echo VERSION_ID=$VERSION_ID echo PRETTY_NAME=\"$PRETTY_NAME\" echo ANSI_COLOR=\"$ANSI_COLOR\" } > $initdir/etc/initrd-release echo dracut-$DRACUT_VERSION > $initdir/lib/dracut/dracut-$DRACUT_VERSION ln -sf initrd-release $initdir/etc/os-release ## save host_devs which we need bring up if [[ $hostonly_cmdline == "yes" ]]; then if [[ -f "$initdir/lib/dracut/need-initqueue" ]] || ! dracut_module_included "systemd"; then ( if dracut_module_included "systemd"; then DRACUT_SYSTEMD=1 fi PREFIX="$initdir" . "$moddir/dracut-lib.sh" for _dev in "${host_devs[@]}"; do [[ "$_dev" == "$root_dev" ]] && continue # We only actually wait for real devs - swap is only needed # for resume and udev rules generated when parsing resume= # argument take care of the waiting for us for _dev2 in "${swap_devs[@]}"; do [[ "$_dev" == "$_dev2" ]] && continue 2 done _pdev=$(get_persistent_dev $_dev) case "$_pdev" in /dev/?*) wait_for_dev $_pdev;; *) ;; esac done ) fi fi } PK!Xdd#modules.d/99base/parse-root-opts.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh root=$(getarg root=) rflags="$(getarg rootflags=)" getargbool 0 ro && rflags="${rflags},ro" getargbool 0 rw && rflags="${rflags},rw" rflags="${rflags#,}" fstype="$(getarg rootfstype=)" if [ -z "$fstype" ]; then fstype="auto" fi PK!![HHmodules.d/99base/loginit.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # turn off debugging set +x QUIET=$1 printf -- "$$" > /run/initramfs/loginit.pid [ -e /dev/kmsg ] && exec 5>/dev/kmsg || exec 5>/dev/null exec 6>/run/initramfs/init.log while read line; do if [ "$line" = "DRACUT_LOG_END" ]; then rm -f -- /run/initramfs/loginit.pipe exit 0 fi echo "<31>dracut: $line" >&5 # if "quiet" is specified we output to /dev/console [ -n "$QUIET" ] || echo "dracut: $line" echo "$line" >&6 done PK!@ j]]modules.d/99base/dracut-lib.shnuȯ#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh export DRACUT_SYSTEMD export NEWROOT if [ -n "$NEWROOT" ]; then [ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT fi if ! [ -d /run/initramfs ]; then mkdir -p -m 0755 /run/initramfs/log ln -sfn /run/initramfs/log /var/log fi [ -d /run/lock ] || mkdir -p -m 0755 /run/lock [ -d /run/log ] || mkdir -p -m 0755 /run/log debug_off() { set +x } debug_on() { [ "$RD_DEBUG" = "yes" ] && set -x } # returns OK if $1 contains $2 strstr() { [ "${1#*$2*}" != "$1" ] } # returns OK if $1 contains $2 at the beginning str_starts() { [ "${1#$2*}" != "$1" ] } # returns OK if $1 contains $2 at the end str_ends() { [ "${1%*$2}" != "$1" ] } trim() { local var="$*" var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters echo -n "$var" } if [ -z "$DRACUT_SYSTEMD" ]; then warn() { check_quiet echo "<28>dracut Warning: $*" > /dev/kmsg echo "dracut Warning: $*" >&2 } info() { check_quiet echo "<30>dracut: $*" > /dev/kmsg [ "$DRACUT_QUIET" != "yes" ] && \ echo "dracut: $*" >&2 } else warn() { echo "Warning: $*" >&2 } info() { check_quiet [ "$DRACUT_QUIET" != "yes" ] && \ echo "$*" >&2 } fi vwarn() { while read line || [ -n "$line" ]; do warn $line; done } vinfo() { while read line || [ -n "$line" ]; do info $line; done } # replaces all occurrences of 'search' in 'str' with 'replacement' # # str_replace str search replacement # # example: # str_replace ' one two three ' ' ' '_' str_replace() { local in="$1"; local s="$2"; local r="$3" local out='' while strstr "${in}" "$s"; do chop="${in%%$s*}" out="${out}${chop}$r" in="${in#*$s}" done echo "${out}${in}" } killall_proc_mountpoint() { local _pid local _t for _pid in /proc/*; do _pid=${_pid##/proc/} case $_pid in *[!0-9]*) continue;; esac [ -e "/proc/$_pid/exe" ] || continue [ -e "/proc/$_pid/root" ] || continue strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" && kill -9 "$_pid" done } getcmdline() { local _line local _i local CMDLINE_ETC_D local CMDLINE_ETC local CMDLINE_PROC unset _line if [ -e /etc/cmdline ]; then while read -r _line; do CMDLINE_ETC="$CMDLINE_ETC $_line"; done ", we want the exact match if [ "$_o" = "$1" ]; then _val="1"; unset _doecho fi continue fi if [ "${_o#*=}" = "$_o" ]; then # if cmdline argument has no "=", we assume "=1" _val="1"; unset _doecho continue fi _val="${_o#*=}" _doecho=1 fi done if [ -n "$_val" ]; then [ "x$_doecho" != "x" ] && echo "$_val"; return 0; fi return 1; } getarg() { debug_off local _deprecated _newoption while [ $# -gt 0 ]; do case $1 in -d) _deprecated=1; shift;; -y) if _dogetarg $2 >/dev/null; then if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn "Option '$2' is deprecated." fi echo 1 debug_on return 0 fi _deprecated=0 shift 2;; -n) if _dogetarg $2 >/dev/null; then echo 0; if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn "Option '$2' is deprecated." fi debug_on return 1 fi _deprecated=0 shift 2;; *) if [ -z "$_newoption" ]; then _newoption="$1" fi if _dogetarg $1; then if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn "Option '$1' is deprecated." fi debug_on return 0; fi _deprecated=0 shift;; esac done debug_on return 1 } # getargbool # False if "getarg " returns "0", "no", or "off". # True if getarg returns any other non-empty string. # If not found, assumes - usually 0 for false, 1 for true. # example: getargbool 0 rd.info # true: rd.info, rd.info=1, rd.info=xxx # false: rd.info=0, rd.info=off, rd.info not present (default val is 0) getargbool() { local _b unset _b local _default _default="$1"; shift _b=$(getarg "$@") [ $? -ne 0 -a -z "$_b" ] && _b="$_default" if [ -n "$_b" ]; then [ $_b = "0" ] && return 1 [ $_b = "no" ] && return 1 [ $_b = "off" ] && return 1 fi return 0 } isdigit() { case "$1" in *[!0-9]*|"") return 1;; esac return 0 } # getargnum # Will echo the arg if it's in range [minval - maxval]. # If it's not set or it's not valid, will set it . # Note all values are required to be >= 0 here. # should be with [minval -maxval]. getargnum() { local _b unset _b local _default _min _max _default="$1"; shift _min="$1"; shift _max="$1"; shift _b=$(getarg "$1") [ $? -ne 0 -a -z "$_b" ] && _b=$_default if [ -n "$_b" ]; then isdigit "$_b" && _b=$(($_b)) && \ [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return fi echo $_default } _dogetargs() { debug_off local _o _found _key unset _o unset _found CMDLINE=$(getcmdline) _key="$1" set -- for _o in $CMDLINE; do if [ "$_o" = "$_key" ]; then _found=1; elif [ "${_o%%=*}" = "${_key%=}" ]; then [ -n "${_o%%=*}" ] && set -- "$@" "${_o#*=}"; _found=1; fi done if [ -n "$_found" ]; then [ $# -gt 0 ] && printf '%s' "$*" return 0 fi return 1; } getargs() { debug_off local _val _i _args _gfound _deprecated unset _val unset _gfound _newoption="$1" _args="$@" set -- for _i in $_args; do if [ "$i" = "-d" ]; then _deprecated=1 continue fi _val="$(_dogetargs $_i)" if [ $? -eq 0 ]; then if [ "$_deprecated" = "1" ]; then [ -n "$_newoption" ] && warn "Option '$_i' is deprecated, use '$_newoption' instead." || warn "Option $_i is deprecated!" fi _gfound=1 fi [ -n "$_val" ] && set -- "$@" "$_val" _deprecated=0 done if [ -n "$_gfound" ]; then if [ $# -gt 0 ]; then printf '%s' "$*" else printf 1 fi debug_on return 0 fi debug_on return 1; } # Prints value of given option. If option is a flag and it's present, # it just returns 0. Otherwise 1 is returned. # $1 = options separated by commas # $2 = option we are interested in # # Example: # $1 = cipher=aes-cbc-essiv:sha256,hash=sha256,verify # $2 = hash # Output: # sha256 getoptcomma() { local line=",$1,"; local opt="$2"; local tmp case "${line}" in *,${opt}=*,*) tmp="${line#*,${opt}=}" echo "${tmp%%,*}" return 0 ;; *,${opt},*) return 0;; esac return 1 } # Splits given string 'str' with separator 'sep' into variables 'var1', 'var2', # 'varN'. If number of fields is less than number of variables, remaining are # not set. If number of fields is greater than number of variables, the last # variable takes remaining fields. In short - it acts similary to 'read'. # # splitsep sep str var1 var2 varN # # example: # splitsep ':' 'foo:bar:baz' v1 v2 # in result: # v1='foo', v2='bar:baz' # # TODO: ':' inside fields. splitsep() { debug_off local sep="$1"; local str="$2"; shift 2 local tmp while [ -n "$str" -a "$#" -gt 1 ]; do tmp="${str%%$sep*}" eval "$1='${tmp}'" str="${str#"$tmp"}" str="${str#$sep}" shift done [ -n "$str" -a -n "$1" ] && eval "$1='$str'" debug_on return 0 } setdebug() { [ -f /etc/initrd-release ] || return if [ -z "$RD_DEBUG" ]; then if [ -e /proc/cmdline ]; then RD_DEBUG=no if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then RD_DEBUG=yes [ -n "$BASH" ] && \ export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; fi fi export RD_DEBUG fi debug_on } setdebug source_all() { local f local _dir _dir=$1; shift [ "$_dir" ] && [ -d "/$_dir" ] || return for f in "/$_dir"/*.sh; do [ -e "$f" ] && . "$f" "$@"; done } hookdir=/lib/dracut/hooks export hookdir source_hook() { local _dir _dir=$1; shift source_all "/lib/dracut/hooks/$_dir" "$@" } check_finished() { local f for f in $hookdir/initqueue/finished/*.sh; do [ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0 { [ -e "$f" ] && ( . "$f" ) ; } || return 1 done return 0 } source_conf() { local f [ "$1" ] && [ -d "/$1" ] || return for f in "/$1"/*.conf; do [ -e "$f" ] && . "$f"; done } die() { { echo "<24>dracut: FATAL: $*"; echo "<24>dracut: Refusing to continue"; } > /dev/kmsg { echo "warn dracut: FATAL: \"$*\""; echo "warn dracut: Refusing to continue"; } >> $hookdir/emergency/01-die.sh [ -d /run/initramfs ] || mkdir -p -- /run/initramfs > /run/initramfs/.die getargbool 0 "rd.debug=" && emergency_shell if [ -n "$DRACUT_SYSTEMD" ]; then systemctl --no-block --force halt fi exit 1 } check_quiet() { if [ -z "$DRACUT_QUIET" ]; then DRACUT_QUIET="yes" getargbool 0 rd.info -d -y rdinfo && DRACUT_QUIET="no" getargbool 0 rd.debug -d -y rdinitdebug && DRACUT_QUIET="no" if [ -z "$DRACUT_SYSTEMD" ]; then getarg quiet || DRACUT_QUIET="yes" a=$(getarg loglevel=) [ -n "$a" ] && [ $a -ge 28 ] && DRACUT_QUIET="yes" fi export DRACUT_QUIET fi } check_occurances() { # Count the number of times the character $ch occurs in $str # Return 0 if the count matches the expected number, 1 otherwise local str="$1" local ch="$2" local expected="$3" local count=0 while [ "${str#*$ch}" != "${str}" ]; do str="${str#*$ch}" count=$(( $count + 1 )) done [ $count -eq $expected ] } incol2() { debug_off local dummy check; local file="$1"; local str="$2"; [ -z "$file" ] && return 1; [ -z "$str" ] && return 1; while read dummy check restofline; do if [ "$check" = "$str" ]; then debug_on return 0 fi done < $file debug_on return 1 } udevsettle() { [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version) if [ $UDEVVERSION -ge 143 ]; then udevadm settle --exit-if-exists=$hookdir/initqueue/work $settle_exit_if_exists else udevadm settle --timeout=30 fi } udevproperty() { [ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version) if [ $UDEVVERSION -ge 143 ]; then for i in "$@"; do udevadm control --property=$i; done else for i in "$@"; do udevadm control --env=$i; done fi } find_mount() { local dev mnt etc wanted_dev wanted_dev="$(readlink -e -q $1)" while read dev mnt etc; do [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0 done < /proc/mounts return 1 } # usage: ismounted # usage: ismounted /dev/ if command -v findmnt >/dev/null; then ismounted() { findmnt "$1" > /dev/null 2>&1 } else ismounted() { if [ -b "$1" ]; then find_mount "$1" > /dev/null && return 0 return 1 fi while read a m a; do [ "$m" = "$1" ] && return 0 done < /proc/mounts return 1 } fi # root=nfs:[:][:] # root=nfs4:[:][:] nfsroot_to_var() { # strip nfs[4]: local arg="$@:" nfs="${arg%%:*}" arg="${arg##$nfs:}" # check if we have a server if strstr "$arg" ':/*' ; then server="${arg%%:/*}" arg="/${arg##*:/}" fi path="${arg%%:*}" # rest are options options="${arg##$path}" # strip leading ":" options="${options##:}" # strip ":" options="${options%%:}" # Does it really start with '/'? [ -n "${path%%/*}" ] && path="error"; #Fix kernel legacy style separating path and options with ',' if [ "$path" != "${path#*,}" ] ; then options=${path#*,} path=${path%%,*} fi } # Create udev rule match for a device with its device name, or the udev property # ID_FS_UUID or ID_FS_LABEL # # example: # udevmatch LABEL=boot # prints: # ENV{ID_FS_LABEL}="boot" # # TOOD: symlinks udevmatch() { case "$1" in UUID=????????-????-????-????-????????????|LABEL=*|PARTLABEL=*|PARTUUID=????????-????-????-????-????????????) printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}" ;; UUID=*) printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}" ;; PARTUUID=*) printf 'ENV{ID_FS_PARTUUID}=="%s*"' "${1#*=}" ;; /dev/?*) printf -- 'KERNEL=="%s"' "${1#/dev/}" ;; *) return 255 ;; esac } # Prints unique path for potential file inside specified directory. It consists # of specified directory, prefix and number at the end which is incremented # until non-existing file is found. # # funiq dir prefix # # example: # # ls /mnt # cdrom0 cdrom1 # # # funiq /mnt cdrom # /mnt/cdrom2 funiq() { local dir="$1"; local prefix="$2" local i=0 [ -d "${dir}" ] || return 1 while [ -e "${dir}/${prefix}$i" ]; do i=$(($i+1)) || return 1 done echo "${dir}/${prefix}$i" } # Creates unique directory and prints its path. It's using funiq to generate # path. # # mkuniqdir subdir new_dir_name mkuniqdir() { local dir="$1"; local prefix="$2" local retdir; local retdir_new [ -d "${dir}" ] || mkdir -m 0755 -p "${dir}" || return 1 retdir=$(funiq "${dir}" "${prefix}") || return 1 until mkdir -m 0755 "${retdir}" 2>/dev/null; do retdir_new=$(funiq "${dir}" "${prefix}") || return 1 [ "$retdir_new" = "$retdir" ] && return 1 retdir="$retdir_new" done echo "${retdir}" } # Copy the contents of SRC into DEST, merging the contents of existing # directories (kinda like rsync, or cpio -p). # Creates DEST if it doesn't exist. Overwrites files with the same names. # # copytree SRC DEST copytree() { local src="$1" dest="$2" mkdir -p "$dest"; dest=$(readlink -e -q "$dest") ( cd "$src"; cp -af . -t "$dest" ) } # Evaluates command for UUIDs either given as arguments for this function or all # listed in /dev/disk/by-uuid. UUIDs doesn't have to be fully specified. If # beginning is given it is expanded to all matching UUIDs. To pass full UUID to # your command use '$___' as a place holder. Remember to escape '$'! # # foreach_uuid_until [ -p prefix ] command UUIDs # # prefix - string to put just before $___ # command - command to be evaluated # UUIDs - list of UUIDs separated by space # # The function returns after *first successful evaluation* of the given command # with status 0. If evaluation fails for every UUID function returns with # status 1. # # Example: # foreach_uuid_until "mount -U \$___ /mnt; echo OK; umount /mnt" \ # "01234 f512 a235567f-12a3-c123-a1b1-01234567abcb" foreach_uuid_until() ( cd /dev/disk/by-uuid [ "$1" = -p ] && local prefix="$2" && shift 2 local cmd="$1"; shift; local uuids_list="$*" local uuid; local full_uuid; local ___ [ -n "${cmd}" ] || return 1 for uuid in ${uuids_list:-*}; do for full_uuid in ${uuid}*; do [ -e "${full_uuid}" ] || continue ___="${prefix}${full_uuid}" eval ${cmd} && return 0 done done return 1 ) # Get kernel name for given device. Device may be the name too (then the same # is returned), a symlink (full path), UUID (prefixed with "UUID=") or label # (prefixed with "LABEL="). If just a beginning of the UUID is specified or # even an empty, function prints all device names which UUIDs match - every in # single line. # # NOTICE: The name starts with "/dev/". # # Example: # devnames UUID=123 # May print: # /dev/dm-1 # /dev/sdb1 # /dev/sdf3 devnames() { local dev="$1"; local d; local names case "$dev" in UUID=*) dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \ && return 255 [ -z "$dev" ] && return 255 ;; LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;; /dev/?*) ;; *) return 255 ;; esac for d in $dev; do names="$names $(readlink -e -q "$d")" || return 255 done echo "${names# }" } usable_root() { local _i [ -d "$1" ] || return 1 for _i in "$1"/usr/lib*/ld-*.so "$1"/lib*/ld-*.so; do [ -e "$_i" ] && return 0 done for _i in proc sys dev; do [ -e "$1"/$_i ] || return 1 done return 0 } inst_hook() { local _hookname _unique _name _job _exe while [ $# -gt 0 ]; do case "$1" in --hook) _hookname="/$2";shift;; --unique) _unique="yes";; --name) _name="$2";shift;; *) break;; esac shift done if [ -z "$_unique" ]; then _job="${_name}$$" else _job="${_name:-$1}" _job=${_job##*/} fi _exe=$1 shift [ -x "$_exe" ] || _exe=$(command -v $_exe) if [ -n "$onetime" ]; then { echo '[ -e "$_job" ] && rm -f -- "$_job"' echo "$_exe $@" } > "/tmp/$$-${_job}.sh" else echo "$_exe $@" > "/tmp/$$-${_job}.sh" fi mv -f "/tmp/$$-${_job}.sh" "$hookdir/${_hookname}/${_job}.sh" } # inst_mount_hook