....................................../////.===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.133.106.206
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 :  /bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bin/percona-release
#!/bin/bash
#
#
#If you want to make script non-interactive please change this variable to NO
INTERACTIVE=YES
#
if [[ $(id -u) -gt 0 ]]; then
  echo "Please run $(basename ${0}) as root!"
  exit 1
fi
#

shell_quote_string() {
  echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g'
}

append_arg_to_args () {
  args="$args "$(shell_quote_string "$1")
}

parse_arguments() {
    pick_args=
    if test "$1" = PICK-ARGS-FROM-ARGV
    then
        pick_args=1
        shift
    fi

    for arg do
        val=$(echo "$arg" | sed -e 's;^--[^=]*=;;')
        case "$arg" in
            --user_name=*) USER_NAME="$val" ;;
            --repo_token=*) REPO_TOKEN="$val" ;;
            --help) show_help ;;
            *)
              if test -n "$pick_args"
              then
                  append_arg_to_args "$arg"
              fi
              ;;
        esac
    done
}

PRODUCTS_ABBREVIATIONS=("pdmdb" "pdps" "pdpxc" "pmm" "ppg11" "ppg12" "ppg13" "ppg14" "psmdb" "px")

function sort_array {
  ARRAY=$1
  local flagforabbr="pdmdb"
  PRODUCTS=()
  OTHER_PRODUCTS=()
  for element in ${ARRAY[@]}
    do
      counter=1
      for abbr in ${PRODUCTS_ABBREVIATIONS[@]}
        do
          if [[ "${element//-/}" =~ ^$abbr.*$ ]]; then
            if [[ $flagforabbr == $abbr ]]; then
              PRODUCTS+="$element "
            else
              flagforabbr=$abbr
              echo ${PRODUCTS}
              PRODUCTS=()
              PRODUCTS+="$element "
              break
            fi
          else
            if [[ $counter == ${#PRODUCTS_ABBREVIATIONS[@]} ]]; then
              OTHER_PRODUCTS+="$element "
            else
              counter=$((counter+1))
            fi
          fi
        done
    done
  echo -e ${PRODUCTS}
  echo -e ${OTHER_PRODUCTS}
}

function get_repos_from_site {
  if [ "${REPOSITORIES}" != "" ]; then
      return
  fi

  REPOSITORIES=$(curl -s ${URL} | tail -n +28  | grep href | grep -v https | awk -Fhref=\" '{print $2}' | awk -F\/ '{print $1}')
  if [ -z "$REPOSITORIES" ]; then
    REPOSITORIES="original ps-56 ps-57 ps-80 pxb-24 pxb-80 pxc-56 pxc-57 pxc-80 psmdb-36 psmdb-40 psmdb-42 tools ppg-11 ppg-11.5 ppg-11.6 ppg-11.7 ppg-11.8 ppg-12 ppg-12.2 ppg-12.3 pdmdb-4.2 pdmdb-4.2.6 pdmdb-4.2.7 pdmdb-4.2.8 pdps-8.0.19 pdpxc-8.0.19 pdps-8.0.20 pdps-8.0 pdpxc-8.0 prel telemetry proxysql sysbench pt mysql-shell pbm pmm-client pmm2-client pmm3-client pdmdb-4.4 pdmdb-4.4.0 psmdb-44"
  fi

  REPOSITORIES="${REPOSITORIES} ps-80-pro ps-84-pro psmdb-60-pro psmdb-70-pro ps-57-eol pxc-57-eol pxc-80-pro pxc-84-pro"
  REPOSITORIES="${REPOSITORIES/percona/original}"
  for repo in ${REPOSITORIES[@]}
    do
      if [[ ${repo} =~ ^mysql-shell$|^pmm-client$|^pmm2-client$|^pmm3-client$|^pmm2-components$ ]]; then
        ALIASES+="${repo} "
      else
        ALIASES+="${repo//-/} "
      fi
    done
  REPOSITORIES="${REPOSITORIES//$'\n'/ }"
}

COMMANDS="enable enable-silent enable-only setup disable show help"
COMPONENTS="release testing experimental"
REPOSITORIES=""
URL="http://repo.percona.com"
SUPPORTED_ARCHS="i386 noarch x86_64 aarch64 sources"

if [[ -f /etc/default/percona-release ]]; then
    source /etc/default/percona-release
fi

# Special proxy handling for cURL
CURL_PROXY=
CURL_EXEC=( /usr/bin/curl )
if [[ -n "${https_proxy}" ]] || [[ -n "${http_proxy}" ]] ||
   [[ -n "${HTTPS_PROXY}" ]] || [[ -n "${HTTP_PROXY}" ]]; then
    if [[ "${URL}" =~ ^https: ]]; then
        APT_PROXY_SCHEME=https
        CURL_PROXY="${https_proxy:-${HTTPS_PROXY}}"
    else
        APT_PROXY_SCHEME=http
        CURL_PROXY="${http_proxy:-${HTTP_PROXY}}"
    fi
    if [[ -n "${CURL_PROXY}" ]]; then
        CURL_EXEC=( /usr/bin/curl "--proxy" "${CURL_PROXY}" )
    fi
fi

#
DESCRIPTION=""
DEFAULT_REPO_DESC="Percona Packaging Repository"
PREL_DESC="Percona Release"
TELEMETRY_DESC="Percona Telemetry"
VALKEY_DESC="Percona Valkey"
PT_DESC="Percona Toolkit"
SYSBENCH_DESC="Sysbench"
PROXYSQL_DESC="Proxysql"
PBM_DESC="Percona Backup MongoDB"
MYSQL_SHELL_DESC="Percona MySQL Shell"
PMM_CLIENT_DESC="PMM Client"
PMM2_CLIENT_DESC="PMM2 Client"
PMM3_CLIENT_DESC="PMM3 Client"
PS56_DESC="Percona Server for MySQL 5.6"
PS57_DESC="Percona Server for MySQL 5.7"
PS80_DESC="Percona Server for MySQL 8.0"
PS80_PRO_DESC="Percona Server for MySQL 8.0 Pro"
PS57_EOL_DESC="Percona Server for MySQL 5.7 EOL"
PXC57_EOL_DESC="Percona XtraDB Cluster 5.7 EOL"
PXB24_DESC="Percona XtraBackup 2.4"
PXB80_DESC="Percona XtraBackup 8.0"
PXC56_DESC="Percona XtraDB Cluster 5.6"
PXC57_DESC="Percona XtraDB Cluster 5.7"
PXC80_DESC="Percona XtraDB Cluster 8.0"
PSMDB36_DESC="Percona Server for MongoDB 3.6"
PSMDB40_DESC="Percona Server for MongoDB 4.0"
PSMDB42_DESC="Percona Server for MongoDB 4.2"
PSMDB_DESC="Percona Server for MongoDB"
TOOLS_DESC="Percona Tools"
PPG11_DESC="Percona Distribution for PostgreSQL 11"
PPG11_5_DESC="Percona Distribution for PostgreSQL 11.5"
PPG11_6_DESC="Percona Distribution for PostgreSQL 11.6"
PPG11_7_DESC="Percona Distribution for PostgreSQL 11.7"
PPG11_8_DESC="Percona Distribution for PostgreSQL 11.8"
PDMDB4_2_DESC="Percona Distribution for MongoDB 4.2"
PDMDB4_2_6_DESC="Percona Distribution for MongoDB 4.2.6"
PDMDB4_2_7_DESC="Percona Distribution for MongoDB 4.2.7"
PDMDB4_2_8_DESC="Percona Distribution for MongoDB 4.2.8"
PPG12_DESC="Percona Distribution for PostgreSQL 12"
PPG12_2_DESC="Percona Distribution for PostgreSQL 12.2"
PPG12_3_DESC="Percona Distribution for PostgreSQL 12.3"
PDPXC80_19_DESC="Percona Distribution for MySQL 8.0.19 - PXC"
PDPS80_19_DESC="Percona Distribution for MySQL 8.0.19 - PS"
PDPS80_20_DESC="Percona Distribution for MySQL 8.0.20 - PS"
PDPS80_DESC="Percona Distribution for MySQL 8.0 - PS"
PDPXC80_DESC="Percona Distribution for MySQL 8.0 - PXC"
PPG_DESC="Percona Distribution for PostgreSQL"
PDMDB_DESC="Percona Distribution for MongoDB"
PDPS_DESC="Percona Distribution for MySQL - PS"
PDPS8X_INNOVATION_DESC="Percona Distribution for MySQL - PS 8x Innovation"
PS8X_INNOVATION_DESC="Percona Server for MySQL - PS 8x Innovation"
PXC8X_INNOVATION_DESC="Percona XtraDB Cluster 8x Innovation"
PDPXC8X_INNOVATION_DESC="Percona Distribution XtraDB Cluster 8x Innovation"
PXB8X_INNOVATION_DESC="Percona XtraBackup 8x Innovation"
PDPS9X_INNOVATION_DESC="Percona Distribution for MySQL - PS 9x Innovation"
PS9X_INNOVATION_DESC="Percona Server for MySQL - PS 9x Innovation"
PXC9X_INNOVATION_DESC="Percona XtraDB Cluster 9x Innovation"
PDPXC9X_INNOVATION_DESC="Percona Distribution XtraDB Cluster 9x Innovation"
PXB9X_INNOVATION_DESC="Percona XtraBackup 9x Innovation"
PS_DESC="Percona Server for MySQL - PS"
PDPXC_DESC="Percona Distribution for MySQL - PXC"
#
PS56REPOS="ps-56 tools"
PS57REPOS="ps-57 pxb-24"
PS80REPOS="ps-80 tools"
PS57EOLREPOS="ps-57-eol"
PXC57EOLREPOS="pxc-57-eol"
PS80PROREPOS="ps-80-pro"
PXC56REPOS="pxc-56 tools"
PXC57REPOS="pxc-57 pxb-24"
PXC80REPOS="pxc-80 tools"
PXB24REPOS="pxb-24"
PXB80REPOS="pxb-80"
PSMDB36REPOS="psmdb-36 pbm"
PSMDB40REPOS="psmdb-40 tools"
PSMDB42REPOS="psmdb-42 tools"
PSMDB60PROREPOS="psmdb-60-pro"
PSMDB70PROREPOS="psmdb-70-pro"
PPG11REPOS="ppg-11"
PPG11_5_REPOS="ppg-11.5"
PPG11_6_REPOS="ppg-11.6"
PPG11_7_REPOS="ppg-11.7"
PPG11_8_REPOS="ppg-11.8"
PDMDB4_2_6_REPOS="pdmdb-4.2.6"
PDMDB4_2_7_REPOS="pdmdb-4.2.7"
PDMDB4_2_8_REPOS="pdmdb-4.2.8"
PDMDB4_2_REPOS="pdmdb-4.2"
PPG12_REPOS="ppg-12"
PPG12_2_REPOS="ppg-12.2"
PPG12_3_REPOS="ppg-12.3"
PDPS80_REPOS="pdps-8.0"
PDPS8X_INNOVATION_REPOS="pdps-8x-innovation"
PS8X_INNOVATION_REPOS="ps-8x-innovation"
PS84_LTS_REPOS="ps-84-lts"
PDPS84_LTS_REPOS="pdps-84-lts"
PXC8X_INNOVATION_REPOS="pxc-8x-innovation"
PXC84_LTS_REPOS="pxc-84-lts"
PDPXC8X_INNOVATION_REPOS="pdpxc-8x-innovation"
PDPXC84_LTS_REPOS="pdpxc-84-lts"
PXB8X_INNOVATION_REPOS="pxb-8x-innovation"
PXB84_LTS_REPOS="pxb-84-lts"
PDPS9X_INNOVATION_REPOS="pdps-9x-innovation"
PS9X_INNOVATION_REPOS="ps-9x-innovation"
PXC9X_INNOVATION_REPOS="pxc-9x-innovation"
PDPXC9X_INNOVATION_REPOS="pdpxc-9x-innovation"
PXB9X_INNOVATION_REPOS="pxb-9x-innovation"
PDPXC80_REPOS="pdpxc-8.0"
PDPS80_19_REPOS="pdps-8.0.19"
PDPS80_20_REPOS="pdps-8.0.20"
PDPXC80_19_REPOS="pdpxc-8.0.19"
PREL_REPOS="prel telemetry"
PROXYSQL_REPOS="proxysql"
SYSBENCH_REPOS="sysbench"
PT_REPOS="pt"
MYSQL_SHELL_REPOS="mysql-shell"
PBM_REPOS="PBM"
PMM_CLIENT_REPOS="pmm-client"
PMM2_CLIENT_REPOS="pmm2-client"
PMM3_CLIENT_REPOS="pmm3-client"
TOOLS_REPOS="tools"
ORIGINAL_REPOS="original"
#
AUTOUPDATE=NO
MODIFIED=NO
REPOFILE=""
#          RH derivatives      and          Amazon Linux
if [[ -f /etc/redhat-release ]] || [[ -f /etc/system-release ]]; then
  LOCATION=/etc/yum.repos.d
  EXT=repo
  PKGTOOL=dnf
  ARCH=$(rpm --eval %_arch)
elif [[ -f /etc/debian_version ]]; then
  LOCATION=/etc/apt/sources.list.d
  EXT=list
  PKGTOOL="apt-get"
  CODENAME=$(lsb_release -sc)
else
  echo "==>> ERROR: Unsupported operating system"
  exit 1
fi
#
function show_enabled {
  echo "The following repositories are enabled on your system:"
  if [[ -f /etc/redhat-release ]] || [[ -f /etc/system-release ]]; then
    for line in $(dnf repolist enabled | egrep -ie "percona|sysbench|proxysql|pmm" | awk '{print $1}' | awk -F'/' '{print $1}' ); do
      count=$(grep -o '-' <<< $line | wc -l)
      if [[ $count = 3 ]]; then
        echo $line | awk -F '-' '{print $1"-"$2,"- "$3,"| "$4}'
      else
        echo $line | awk -F '-' '{print $1" - "$2" | " $3}'
      fi
    done
  elif [[ -f /etc/debian_version ]]; then
    grep -E '^deb\s' /etc/apt/sources.list /etc/apt/sources.list.d/*.list | cut -f2- -d: | grep "${URL/http*:\/\//}" | awk '{print $3$5}' | sed "s;${URL}/;;g" | sed 's;/apt; - ;g' | sed 's;percona;original;g' | sed 's;main;release;g'
  else
    echo "==>> ERROR: Unsupported operating system"
    exit 1
  fi
}
#
function is_supported_arch {
  local arch=$1

  for _arch in ${SUPPORTED_ARCHS}; do
        [[ ${_arch} = ${arch} ]] && return
  done
  return 1
}

function check_specified_alias {
  local found=NO
  [[ -z ${1} ]] && echo "ERROR: No product alias specified!" && show_help && exit 2
  for _alias in ${ALIASES}; do
    NAME=$(echo ${1} | sed 's/-//' )
    # Ignore alias in case of -pro repos
    [[ ${NAME} == *pro ]] && found=YES
    [[ ${NAME} == *eol ]] && found=YES
    [[ ${NAME} == *innovation ]] && found=YES
    [[ ${NAME} == *lts ]] && found=YES
    [[ ${_alias} = ${NAME} ]] && found=YES
  done
  if [[ ${found} = NO ]]; then
    echo "ERROR: Unknown alias specification: ${1}"
    echo "Available product aliases are: ${ALIASES}"
    exit 2
  fi
}

function read_credentials_from_config {

  config_file="${HOME}/.percona-private-repos.config"

  section_name=$1

  # Check if section_name is provided
  if [ -z "$section_name" ]; then
    echo "Usage: $0 <section_name>"
    exit 1
  fi

  # Check if the config file exists
  if [ ! -f "$config_file" ]; then
    echo "Config file not found: $config_file"
    exit 1
  fi

  # Read the specified section from the config file
  section_content=$(awk -v section="$section_name" '/^\[/{flag=0} /^\['"$section_name"'\]/{flag=1;next} flag' "$config_file")

  # Check if the section exists
  if [ -z "$section_content" ]; then
    echo "Section not found: [$section_name]"
    exit 1
  fi

  # Parse the section content and export variables
  while IFS= read -r line; do
    if [[ "$line" =~ ^[a-zA-Z_][a-zA-Z0-9_]*= ]]; then
        export "$line"
    fi
  done <<< "$section_content"
}

function check_specified_repo {
  local found=NO
  [[ -z ${1} ]] && echo "ERROR: No repository specified!" && show_help && exit 2
  for _repo in ${REPOSITORIES}; do
    [[ ${_repo} = ${1} ]] && found=YES
  done
  if [[ ${found} = NO ]]; then
    echo "ERROR: Unknown repository: ${1}"
    echo "Available repositories are: ${REPOSITORIES}"
    exit 2
  fi

  if [[ "${REPO_NAME}" == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
    if [[ -z ${USER_NAME} ]] || [[ -z ${REPO_TOKEN} ]]; then
      echo -e "ERROR: ${REPO_NAME} requires user_name and repo_token for ${REPO_NAME} repository. Either pass credentials using --user_name and --repo_token switches or create file ${HOME}/.percona-private-repos.config with following values:\n\n[${REPO_NAME}]\nUSER_NAME=<Your PRO repository user name>\nREPO_TOKEN=<Your PRO repository token>" && exit 2
    fi
  fi
}

#
function check_os_support {
   REPO_NAME=$1
   COMPONENT=$2
   if [[ ${PKGTOOL} = dnf ]]; then
    if [ -f /etc/os-release ]; then
      OS_VER=$(grep VERSION_ID= /etc/os-release | awk -F'"' '{print $2}' | awk -F'.' '{print $1}')
    else
      OS_VER=$(cat /etc/system-release | awk '{print $(NF-1)}' | awk -F'.' '{print $1}')
    fi

    if [[ ${REPO_NAME} == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
      [[ -z ${USER_NAME} ]] && echo -e "ERROR: ${REPO_NAME} requires user_name for ${REPO_NAME} repository. Use --user_name switch to pass user name" && exit 2
      [[ -z ${REPO_TOKEN} ]] && echo -e "ERROR: ${REPO_NAME} requires repo_token for ${REPO_NAME} repository. Use --repo_token switch to pass repository token" && exit 2
    fi

    if [[ ${REPO_NAME} == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
      if [[ ${OS_VER} == 2023 ]]; then
        reply=$("${CURL_EXEC[@]}" -Is http://repo.percona.com/private/${USER_NAME}-${REPO_TOKEN}/${REPO_NAME}/yum/${COMPONENT}/${OS_VER}/ | head -n 1 | awk '{print $2}')
      else
        reply=$("${CURL_EXEC[@]}" -Is http://repo.percona.com/private/${USER_NAME}-${REPO_TOKEN}/${REPO_NAME}/yum/release/${OS_VER}/ | head -n 1 | awk '{print $2}')
      fi
    else
      if [[ ${OS_VER} == 2023 ]]; then
        reply=$("${CURL_EXEC[@]}" -Is http://repo.percona.com/${REPO_NAME}/yum/${COMPONENT}/${OS_VER}/ | head -n 1 | awk '{print $2}')
      else
        reply=$("${CURL_EXEC[@]}" -Is http://repo.percona.com/${REPO_NAME}/yum/release/${OS_VER}/ | head -n 1 | awk '{print $2}')
      fi
    fi
  elif [[ ${PKGTOOL} = "apt-get" ]]; then
    OS_VER=$(lsb_release -sc)
    if [[ ${REPO_NAME} == *-pro ]] || [[ ${REPO_NAME} == *-eol ]]; then
      reply=$("${CURL_EXEC[@]}" -Is http://repo.percona.com/private/${USER_NAME}-${REPO_TOKEN}/${REPO_NAME}/apt/dists/${OS_VER}/ | head -n 1 | awk '{print $2}')
    else
      reply=$("${CURL_EXEC[@]}" -Is http://repo.percona.com/${REPO_NAME}/apt/dists/${OS_VER}/ | head -n 1 | awk '{print $2}')
    fi
  fi
  if [[ ${reply} != 200 ]]; then
      if [[ ${REPO_NAME} == *-pro ]] || [[ ${REPO_NAME} == *-eol ]]; then
        echo "Specified repository ($REPO_NAME) is not supported for current operating system or check your credentials."
      else
        echo "Specified repository is not supported for current operating system!"
      fi
      exit 2
  fi
}
#
function check_repo_availability {
  if [[ "$2" == "-y" ]]; then
    REPO_NAME=${3}
    COMPONENT=${4}
  else
    REPO_NAME=${2}
    COMPONENT=${3}
  fi

  if [[ -z ${COMPONENT} ]] || [[ ${COMPONENT} == *"--user_name="* ]] || [[ ${COMPONENT} == *"--repo_token="* ]]; then
    COMPONENT="release"
  fi

  if [[ "${REPO_NAME}" == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
    if [ -f "${HOME}/.percona-private-repos.config" ]; then
      read_credentials_from_config ${REPO_NAME}
    else
      parse_arguments PICK-ARGS-FROM-ARGV "$@"
    fi
  fi

  if [[ "${REPO_NAME}" == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
        if [[ -z ${USER_NAME} ]] || [[ -z ${REPO_TOKEN} ]]; then
          echo -e "ERROR: ${REPO_NAME} requires user_name and repo_token for ${REPO_NAME} repository. Either pass credentials using --user_name and --repo_token switches or create file ${HOME}/.percona-private-repos.config with following values:\n\n[${REPO_NAME}]\nUSER_NAME=<Your PRO repository user name>\nREPO_TOKEN=<Your PRO repository token>" && exit 2
        fi
  fi

  if [[ -z ${COMPONENT} ]] || [[ ${COMPONENT} == *"user_name="* ]] || [[ ${COMPONENT} == *"repo_token="* ]]; then
     COMPONENT="release"
  fi
  [[ -z ${REPO_NAME} ]] && return 0
  [[ ${REPO_NAME} == "original" ]] && REPO_NAME=percona
  [[ ${REPO_NAME} == "all" ]] && return 0
  if ! [[ ${REPO_NAME} =~ ^mysql-shell$|^pmm-client$|^pmm2-client$|^pmm3-client$|^pmm2-components$ ]]; then
    REPO_NAME=$(echo ${REPO_NAME} | sed 's/-//' | sed 's/\([0-9]\)/-\1/')
  fi
  if [[ ${REPO_NAME} == *xinnovation ]]; then
    REPO_NAME=$(echo ${REPO_NAME} | sed 's/innovation/-innovation/' )
  fi
  if [[ ${REPO_NAME} == *4lts ]]; then
    REPO_NAME=$(echo ${REPO_NAME} | sed 's/lts/-lts/' )
  fi

  if [[ ${REPO_NAME} == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
    [[ -z ${USER_NAME} ]] && echo -e "ERROR: ${REPO_NAME} requires user_name for ${REPO_NAME} repository. Use --user_name switch to pass user name" && exit 2
    [[ -z ${REPO_TOKEN} ]] && echo -e "ERROR: ${REPO_NAME} requires repo_token for ${REPO_NAME} repository. Use --repo_token switch to pass repository token" && exit 2
    REPO_LINK="http://repo.percona.com/private/${USER_NAME}-${REPO_TOKEN}/${REPO_NAME}/"
  else
    REPO_LINK="http://repo.percona.com/${REPO_NAME}/"
  fi
  reply=$("${CURL_EXEC[@]}" -Is ${REPO_LINK} | head -n 1 | awk '{print $2}')
  if [[ ${reply} == 200 ]]; then
    if [[ ${REPOSITORIES} != "*${REPO_NAME}*" ]]; then
      REPO_ALIAS=$(echo ${REPO_NAME} | sed 's/-//')
      ALIASES="${REPOSITORIES} ${REPO_ALIAS}"
      REPOSITORIES="${REPOSITORIES} ${REPO_NAME}"
      check_os_support ${REPO_NAME} ${COMPONENT}
    fi
  else
    if [[ ${REPO_NAME} == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
      echo "Specified repository does not exist: ${REPO_LINK} or check your repository credentials"
    else
      echo "Specified repository does not exist: ${REPO_LINK}"
    fi
    exit 2
  fi
}
#

function check_specified_component {
  local message=""
  local found=NO
  for _component in all ${COMPONENTS}; do
    [[ ${_component} = ${1} ]] && found=YES
  done
  [[ ${found} = NO ]] && message="ERROR: Unknown component specification: ${1}"
  [[ -n ${message} ]] && echo ${message} && show_help && exit 2
}
#
function show_message {
  echo "<*> All done!"
  if [[ ${MODIFIED} = YES ]] && [[ ${PKGTOOL} = "apt-get" ]]; then
    echo "==> Please run \"${PKGTOOL} update\" to apply changes"
  fi
}
#
function show_help {
  echo
  echo "Usage:     $(basename ${0}) enable | enable-silent | enable-only | setup | disable (<REPO> | all) [COMPONENT] | show"
  echo "  Example: $(basename ${0}) enable tools release"
  echo "  Example: $(basename ${0}) enable-only ps-80 experimental"
  echo "  Example: $(basename ${0}) setup ps57 | ps-57"
  echo "  Example: $(basename ${0}) setup -y ps57 | setup -y ps-57"
  echo "  Example: $(basename ${0}) show"
  echo "  Example: $(basename ${0}) enable ps-80-pro release --user_name=<User Name> --repo_token=<Pro repository token>"
  echo "  Example: $(basename ${0}) enable-only ps-80 experimental --user_name=<User Name> --repo_token=<Pro repository token>"
  echo "  Example: $(basename ${0}) setup ps-80-pro --user_name=<User Name> --repo_token=<Pro repository token>"
  echo "  Example: $(basename ${0}) setup -y ps-80-pro --user_name=<User Name> --repo_token=<Pro repository token>"
  echo
  echo "Available commands:          ${COMMANDS}"
  echo
  echo "Available setup products:    "
  sort_array "${ALIASES} ps-80-pro psmdb-70-pro psmdb-60-pro"
  echo
  echo "Available repositories:      "
  sort_array "${REPOSITORIES} ps-80-pro psmdb-70-pro psmdb-60-pro"
  echo
  echo "Available components:        ${COMPONENTS}"
  echo
  echo "The \"-y\" option for the setup command automatically answers \"yes\" for all interactive questions."
  echo "The \"show\" command will list all enabled Percona repos on the system."
  echo "Please see percona-release page for help: https://docs.percona.com/percona-software-repositories/percona-release.html"
}
#
function run_update {
  if [[ ${PKGTOOL} = "apt-get" ]]; then
    AUTOUPDATE="YES"
    ${PKGTOOL} update
  fi
}
#
function create_yum_repo {
  local _repo=${1}
  if [ -f /etc/os-release ]; then
      OS_VER=$(grep VERSION_ID= /etc/os-release | awk -F'"' '{print $2}' | awk -F'.' '{print $1}')
  fi
  ARCH_LIST="${ARCH} sources"
  [[ ${1} = "original" ]] && _repo=percona && ARCH_LIST="${ARCH} noarch sources"
  [[ ${1} = "prel" ]] && ARCH_LIST="noarch"
  [[ ${1} = "telemetry" ]] && ARCH_LIST="${ARCH} sources"
  for _key in ${ARCH_LIST}; do
    if ! is_supported_arch "$_key"; then
      echo "WARNING: Skipping ${_key} architecture, as it's not supported"
      continue
    fi

    echo "[${_repo}-${2}-${_key}]" >> ${REPOFILE}
    echo "name = ${DESCRIPTION} ${2}/${_key} YUM repository" >> ${REPOFILE}
    if [[ ${_key} = sources ]]; then
      DIR=SRPMS
      rPATH=""
      ENABLE=0
    else
      DIR=RPMS
      rPATH="/${_key}"
      ENABLE=1
    fi

    if [[ ${_repo} == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
      [[ -z ${USER_NAME} ]] && echo -e "ERROR: ${REPO_NAME} requires user_name for ${REPO_NAME} repository. Use --user_name switch to pass user name" && exit 2
      [[ -z ${REPO_TOKEN} ]] && echo -e "ERROR: ${REPO_NAME} requires repo_token for ${REPO_NAME} repository. Use --repo_token switch to pass repository token" && exit 2
      echo "baseurl = ${URL}/private/${USER_NAME}-${REPO_TOKEN}/${_repo}/yum/${2}/\$releasever/${DIR}${rPATH}" >> ${REPOFILE}
    else
      echo "baseurl = ${URL}/${_repo}/yum/${2}/\$releasever/${DIR}${rPATH}" >> ${REPOFILE}
    fi
    echo "enabled = ${ENABLE}" >> ${REPOFILE}
    echo "gpgcheck = 1" >> ${REPOFILE}
    if [[ ${OS_VER} == 2023 ]]; then
      sed -i 's/$releasever/2023/g' /etc/yum.repos.d/percona*.repo
    fi
    [[ -n "${CURL_PROXY}" ]] && echo "proxy = ${CURL_PROXY}" >> ${REPOFILE}
    echo "gpgkey = file:///etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY" >> ${REPOFILE}
    echo >> ${REPOFILE}
  done
}
#
function create_apt_repo {
  local _repo=${1}
  local _proxyline=

  [[ ${1} = "original" ]] && _repo=percona
  REPOURL="${URL}/${_repo}/apt ${CODENAME}"

  if [[ ${_repo} == *-pro ]] || [[ "${REPO_NAME}" == *-eol ]]; then
    [[ -z ${USER_NAME} ]] && echo -e "ERROR: ${REPO_NAME} requires user_name for ${REPO_NAME} repository. Use --user_name switch to pass user name" && exit 2
    [[ -z ${REPO_TOKEN} ]] && echo -e "ERROR: ${REPO_NAME} requires repo_token for ${REPO_NAME} repository. Use --repo_token switch to pass repository token" && exit 2
    REPOURL="${URL}/private/${USER_NAME}-${REPO_TOKEN}/${_repo}/apt ${CODENAME}"
  fi

  if [[ -n "${CURL_PROXY}" ]]; then
      _proxyline="Acquire::${APT_PROXY_SCHEME}::Proxy::${URL/${APT_PROXY_SCHEME}:\/\//} \"${CURL_PROXY}\";"

      if [[ ! -f /etc/apt/apt.conf.d/99-percona-release ]] || ( ! grep -Rq "${_proxyline}" /etc/ ); then
          echo "${_proxyline}" >> /etc/apt/apt.conf.d/99-percona-release
      fi
  fi
  if [[ ${2} = release ]]; then
    _component=main
    echo "deb [signed-by=/usr/share/keyrings/percona-keyring.gpg] ${REPOURL} ${_component}" >> ${REPOFILE}
    echo "deb-src [signed-by=/usr/share/keyrings/percona-keyring.gpg] ${REPOURL} ${_component}" >> ${REPOFILE}
  else
    echo "deb [signed-by=/usr/share/keyrings/percona-keyring.gpg] ${REPOURL} ${_component}" >> ${REPOFILE}
  fi
}
#
function enable_component {
  local _repo=percona-${1}
  [[ -n ${2} ]] && check_specified_component ${2}
  if [[ ${2} = all ]]; then
    dCOMP=${COMPONENTS}
  elif [[ -z ${2} ]]; then
    dCOMP=release
  else
    dCOMP=${2}
  fi
#
  for _component in ${dCOMP}; do
    if [[ ${_repo} = percona-original ]]; then
      [[ -f ${LOCATION}/percona-percona-${_component}.${EXT} ]] && _repo="percona-percona"
    elif [[  ${_repo} = percona-percona ]]; then
      [[ -f ${LOCATION}/percona-original-${_component}.${EXT} ]] && _repo="percona-original"
    fi
    REPOFILE=${LOCATION}/${_repo}-${_component}.${EXT}
    echo "#" > ${REPOFILE}
    echo "# This repo is managed by \"$(basename ${0})\" utility, do not edit!" >> ${REPOFILE}
    echo "#" >> ${REPOFILE}
    if [[ ${PKGTOOL} = dnf ]]; then
      create_yum_repo ${1} ${_component}
    elif [[ ${PKGTOOL} = "apt-get" ]]; then
      create_apt_repo ${1} ${_component}
    fi
  done
}
#
function disable_component {
  local _repo=percona-${1}
  if [[ ${1} = all ]]; then
    for REPO_FILE in $(find ${LOCATION} -type f -iname "percona*.${EXT}" -not -iname "*prel-release*" -not -iname "*telemetry-release*"); do
      mv -f ${REPO_FILE} ${REPO_FILE}.bak 2>/dev/null
    done
  elif [[ -z ${2} ]]; then
    for comp in testing experimental; do
      mv -f ${LOCATION}/${_repo}-${comp}.${EXT} ${LOCATION}/${_repo}-${comp}.${EXT}.bak 2>/dev/null
    done
    if [[ ${_repo} != *prel && ${_repo} != *telemetry ]]; then
      mv -f ${LOCATION}/${_repo}-release.${EXT} ${LOCATION}/${_repo}-release.${EXT}.bak 2>/dev/null
    fi
  else
    check_specified_component ${2}
    if [[ ${_repo} != *prel && ${_repo} != *telemetry ]]; then
      mv -f ${LOCATION}/${_repo}-${2}.${EXT} ${LOCATION}/${_repo}-${2}.${EXT}.bak 2>/dev/null
    else
      if [[ ${2} != "release" ]]; then
        mv -f ${LOCATION}/${_repo}-${2}.${EXT} ${LOCATION}/${_repo}-${2}.${EXT}.bak 2>/dev/null
      fi
    fi
  fi
}
#
function enable_repository {
  check_specified_repo ${1}
  [[ ${1} = "ps-56" ]]    && DESCRIPTION=${PS56_DESC}
  [[ ${1} = "ps-57" ]]    && DESCRIPTION=${PS57_DESC}
  [[ ${1} = "ps-80" ]]    && DESCRIPTION=${PS80_DESC}
  [[ ${1} = "ps-80-pro" ]]    && DESCRIPTION=${PS80_PRO_DESC}
  [[ ${1} = "ps-57-eol" ]]    && DESCRIPTION=${PS57_EOL_DESC}
  [[ ${1} = "pxc-57-eol" ]]    && DESCRIPTION=${PXC57_EOL_DESC}
  [[ ${1} = "pxc-56" ]]   && DESCRIPTION=${PXC56_DESC}
  [[ ${1} = "pxc-57" ]]   && DESCRIPTION=${PXC57_DESC}
  [[ ${1} = "pxc-80" ]]   && DESCRIPTION=${PXC80_DESC}
  [[ ${1} = "pxb-24" ]]   && DESCRIPTION=${PXB24_DESC}
  [[ ${1} = "pxb-80" ]]   && DESCRIPTION=${PXB80_DESC}
  [[ ${1} = "psmdb-36" ]]  && DESCRIPTION=${PSMDB36_DESC}
  [[ ${1} = "psmdb-40" ]]  && DESCRIPTION=${PSMDB40_DESC}
  [[ ${1} = "psmdb-42" ]]  && DESCRIPTION=${PSMDB42_DESC}
  [[ ${1} = "tools" ]]    && DESCRIPTION=${TOOLS_DESC}
  [[ ${1} = "ppg-11" ]]    && DESCRIPTION=${PPG11_DESC}
  [[ ${1} = "ppg-11.5" ]]    && DESCRIPTION=${PPG11_5_DESC}
  [[ ${1} = "ppg-11.6" ]]    && DESCRIPTION=${PPG11_6_DESC}
  [[ ${1} = "ppg-11.7" ]]    && DESCRIPTION=${PPG11_7_DESC}
  [[ ${1} = "ppg-11.8" ]]    && DESCRIPTION=${PPG11_8_DESC}
  [[ ${1} = "pdmdb-4.2" ]]    && DESCRIPTION=${PDMDB4_2_DESC}
  [[ ${1} = "pdmdb-4.2.6" ]]    && DESCRIPTION=${PDMDB4_2_6_DESC}
  [[ ${1} = "pdmdb-4.2.7" ]]    && DESCRIPTION=${PDMDB4_2_7_DESC}
  [[ ${1} = "pdmdb-4.2.8" ]]    && DESCRIPTION=${PDMDB4_2_8_DESC}
  [[ ${1} = "ppg-12" ]]    && DESCRIPTION=${PPG12_DESC}
  [[ ${1} = "ppg-12.2" ]]    && DESCRIPTION=${PPG12_2_DESC}
  [[ ${1} = "ppg-12.3" ]]    && DESCRIPTION=${PPG12_3_DESC}
  [[ ${1} = "pdps-8.0" ]]    && DESCRIPTION=${PDPS80_DESC}
  [[ ${1} = "pdpxc-8.0" ]]    && DESCRIPTION=${PDPXC80_DESC}
  [[ ${1} = "pdps-8.0.19" ]]    && DESCRIPTION=${PDMYSQL80_19_DESC}
  [[ ${1} = "pdps-8.0.20" ]]    && DESCRIPTION=${PDMYSQL80_20_DESC}
  [[ ${1} = "pdpxc-8.0.19" ]]    && DESCRIPTION=${PDPXC80_19_DESC}
  [[ ${1} = "pdps-8x-innovation" ]]    && DESCRIPTION=${PDPS8X_INNOVATION_DESC}
  [[ ${1} = "ps-8x-innovation" ]]    && DESCRIPTION=${PS8X_INNOVATION_DESC}
  [[ ${1} = "ps-84-lts" ]]    && DESCRIPTION=${PS84_LTS_DESC}
  [[ ${1} = "pxc-8x-innovation" ]]    && DESCRIPTION=${PXC8X_INNOVATION_DESC}
  [[ ${1} = "pxc-84-lts" ]]    && DESCRIPTION=${PXC84_LTS_DESC}
  [[ ${1} = "pdpxc-8x-innovation" ]]    && DESCRIPTION=${PDPXC8X_INNOVATION_DESC}
  [[ ${1} = "pxb-8x-innovation" ]]    && DESCRIPTION=${PXB8X_INNOVATION_DESC}
  [[ ${1} = "pxb-84-lts" ]]    && DESCRIPTION=${PXB84_LTS_DESC}
  [[ ${1} = "pdps-9x-innovation" ]]    && DESCRIPTION=${PDPS9X_INNOVATION_DESC}
  [[ ${1} = "ps-9x-innovation" ]]    && DESCRIPTION=${PS9X_INNOVATION_DESC}
  [[ ${1} = "pxc-9x-innovation" ]]    && DESCRIPTION=${PXC9X_INNOVATION_DESC}
  [[ ${1} = "pdpxc-9x-innovation" ]]    && DESCRIPTION=${PDPXC9X_INNOVATION_DESC}
  [[ ${1} = "pxb-9x-innovation" ]]    && DESCRIPTION=${PXB9X_INNOVATION_DESC}
  [[ ${1} = "prel" ]]    && DESCRIPTION=${PREL_DESC}
  [[ ${1} = "telemetry" ]]    && DESCRIPTION=${TELEMETRY_DESC}
  [[ ${1} = "valkey" ]]    && DESCRIPTION=${VALKEY_DESC}
  [[ ${1} = "proxysql" ]]    && DESCRIPTION=${PROXYSQL_DESC}
  [[ ${1} = "sysbench" ]]    && DESCRIPTION=${SYSBENCH_DESC}
  [[ ${1} = "pt" ]]    && DESCRIPTION=${PT_DESC}
  [[ ${1} = "pbm" ]]    && DESCRIPTION=${PBM_DESC}
  [[ ${1} = "mysql-shell" ]]    && DESCRIPTION=${MYSQL_SHELL_DESC}
  [[ ${1} = "pmm-client" ]]    && DESCRIPTION=${PMM_CLIENT_DESC}
  [[ ${1} = "pmm2-client" ]]    && DESCRIPTION=${PMM2_CLIENT_DESC}
  [[ ${1} = "pmm3-client" ]]    && DESCRIPTION=${PMM3_CLIENT_DESC}
  if [[ -z ${DESCRIPTION} ]]; then
    REPO_NAME=$(echo ${1} | sed 's/-//')
    name=$(echo ${REPO_NAME} | sed 's/[0-9].*//g')
    version=$(echo ${REPO_NAME} | sed 's/[a-z]*//g')
    if [[ $version != *.* && $name != "ppg" ]] ; then
      version=$(echo $version | sed -r ':A;s|([0-9])([0-9]){1}|\1.\2|g')
    fi
    [[ ${name} == ppg* ]]    && DESCRIPTION="${PPG_DESC} $version"
    [[ ${name} == pdmdb* ]]    && DESCRIPTION="${PDMDB_DESC} $version"
    [[ ${name} == ps* ]]    && DESCRIPTION="${PS_DESC} $version"
    [[ ${name} == psmdb* ]]    && DESCRIPTION="${PSMDB_DESC} $version"
    [[ ${name} == pdps* ]]    && DESCRIPTION="${PDPS_DESC} $version"
    [[ ${name} == pdpxc* ]]    && DESCRIPTION="${PDPXC_DESC} $version"
  fi
  [[ -z ${DESCRIPTION} ]] && DESCRIPTION=${DEFAULT_REPO_DESC}
  echo "* Enabling the ${DESCRIPTION} repository"

  if [[ -z ${2} ]] || [[ ${2} == *"--user_name="* ]] || [[ ${2} == *"--repo_token="* ]]; then
    COMPONENT="release"
  else
    COMPONENT=${2}
  fi
  enable_component ${1} ${COMPONENT}
  MODIFIED=YES
}
#
function disable_repository {
  local _repos=${1}
  if [[ ${1} = all ]]; then
    disable_component all
  else
    check_specified_repo ${1}
    if [[ ${1} != "prel" && ${1} != "telemetry" ]]; then
      disable_component ${1} ${2}
    else
      if [[ ${2} != "release" ]]; then
        disable_component ${1} ${2}
      fi
    fi
  fi
  MODIFIED=YES
}
#
function update_rpm {
  if [[ -f /usr/bin/dnf ]]; then
    RHEL=$(rpm --eval %rhel)
    UPDATES=$(dnf check-update rpm)
    if [ $? -eq 100 ]; then
      if [[ -f /usr/bin/dnf && ${RHEL} = 8 ]]; then
        RHEL=$(rpm --eval %rhel)
        if [[ ${INTERACTIVE} = YES ]]; then
          echo "On Red Hat 8 systems it is recommended to update rpm package to install ${PRODUCT}"
          read -r -p "Do you want to update it? [y/N] " response
          if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
          then
            dnf -y update rpm
          else
            echo "Please note that using an old version of rpm package can cause dependency issues or conflicts with existing packages."
            echo "If in the future you decide to update rpm package please execute the next command:"
            echo "  dnf update rpm"
          fi
        else
          echo "On Red Hat 8 systems it is recommended to update rpm package to install ${PRODUCT}"
          dnf -y update rpm
        fi
      fi
    fi
  fi
}
#
function check_enabled_modules {
  MOD="${1} ${2}"
  if [[ -f /usr/bin/dnf ]]; then
    for element in ${MOD[@]}
    do
      check_command=$(dnf -q module list --enabled | awk '{print $1}' | grep ${element})
      if [[ -n ${check_command} ]]; then
        ENABLED_MODULES=YES
        return
      fi
    done
  fi
  ENABLED_MODULES=NO
}
#
function disable_dnf_module {
  REPO_NAME=${1}
  MODULE="mysql"
  PRODUCT="Percona-Server"
  if [[ ${REPO_NAME} == ppg* ]]; then
    MODULE="postgresql"
    PRODUCT="Percona PostgreSQL Distribution"
  fi
  if [[ ${REPO_NAME} == pdps* ]]; then
    MODULE="mysql"
    PRODUCT="Percona Distribution for MySQL - PS"
  fi
  if [[ ${REPO_NAME} == pdpxc* ]]; then
    MODULE="mysql"
    PRODUCT="Percona Distribution for MySQL - PXC"
  fi
  if [[ ${REPO_NAME} = pxc* ]];  then
    MODULE="mysql"
    PRODUCT="Percona XtraDB Cluster"
  fi
  check_enabled_modules ${MODULE}
  if [[ -f /usr/bin/dnf && ${ENABLED_MODULES} = YES ]]; then
    if [[ ${INTERACTIVE} = YES ]]; then
      echo "On Red Hat 8 and 9 systems it is needed to disable the following DNF module(s): ${MODULE}  to install ${PRODUCT}"
      read -r -p "Do you want to disable it? [y/N] " response
      if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
      then
        echo "Disabling dnf module..."
        dnf -y module disable ${MODULE}
        echo "DNF ${MODULE} module was disabled"
      else
        echo "Please note that some packages might be unavailable as packages that aren't included into DNF module are filtered"
        echo "If in the future you decide to disable module(s) please execute the next command:"
        echo "  dnf module disable ${MODULE}"
      fi
    else
      echo "On Red Hat 8 and 9 systems it is needed to disable the following DNF module(s): ${MODULE}  to install ${PRODUCT}"
      echo "Disabling DNF module..."
      dnf -y module disable ${MODULE}
      echo "DNF ${MODULE} module was disabled"
    fi
  fi
}
#
function enable_alias {
  local REPOS=""
  if [[ ${1} != *-pro ]] && [[ ${1} != *-innovation ]] && [[ ${1} != *-eol  ]] && [[ ${1} != *-lts  ]]; then
    local NAME=$( echo ${1} | sed 's/-//' )
  else
    local NAME=${1}
  fi
  check_specified_alias ${NAME}
  if [[ ${NAME} == *xinnovation ]]; then
    NAME=$( echo ${NAME} | sed 's/innovation/-innovation/' )
  fi
  if [[ ${NAME} == *4lts ]]; then
    NAME=$(echo ${NAME} | sed 's/lts/-lts/' )
  fi
  [[ ${NAME} = ps56 ]] && REPOS=${PS56REPOS:-}
  [[ ${NAME} = ps57 ]] && REPOS=${PS57REPOS:-}
  [[ ${NAME} = ps80 ]] && REPOS=${PS80REPOS:-}
  [[ ${NAME} = ps57-eol ]] && REPOS=${PS57EOLREPOS:-}
  [[ ${NAME} = pxc57-eol ]] && REPOS=${PXC57EOLREPOS:-}
  [[ ${NAME} = ps80-pro ]] && REPOS=${PS80PROREPOS:-}
  [[ ${NAME} = psmdb60-pro ]] && REPOS=${PSMDB60PROREPOS:-}
  [[ ${NAME} = psmdb70-pro ]] && REPOS=${PSMDB70PROREPOS:-}
  [[ ${NAME} = pxc56 ]] && REPOS=${PXC56REPOS:-}
  [[ ${NAME} = pxc57 ]] && REPOS=${PXC57REPOS:-}
  [[ ${NAME} = pxc80 ]] && REPOS=${PXC80REPOS:-}
  [[ ${NAME} = pxb24 ]] && REPOS=${PXB24REPOS:-}
  [[ ${NAME} = pxb80 ]] && REPOS=${PXB80REPOS:-}
  [[ ${NAME} = psmdb36 ]] && REPOS=${PSMDB36REPOS:-}
  [[ ${NAME} = psmdb40 ]] && REPOS=${PSMDB40REPOS:-}
  [[ ${NAME} = psmdb42 ]] && REPOS=${PSMDB42REPOS:-}
  [[ ${NAME} = ppg11 ]] && REPOS=${PPG11REPOS:-}
  [[ ${NAME} = ppg11.5 ]] && REPOS=${PPG11_5_REPOS:-}
  [[ ${NAME} = ppg11.6 ]] && REPOS=${PPG11_6_REPOS:-}
  [[ ${NAME} = ppg11.7 ]] && REPOS=${PPG11_7_REPOS:-}
  [[ ${NAME} = ppg11.8 ]] && REPOS=${PPG11_8_REPOS:-}
  [[ ${NAME} = pdmdb4.2 ]] && REPOS=${PDMDB4_2_REPOS:-}
  [[ ${NAME} = pdmdb4.2.6 ]] && REPOS=${PDMDB4_2_6_REPOS:-}
  [[ ${NAME} = pdmdb4.2.7 ]] && REPOS=${PDMDB4_2_7_REPOS:-}
  [[ ${NAME} = pdmdb4.2.8 ]] && REPOS=${PDMDB4_2_8_REPOS:-}
  [[ ${NAME} = ppg12 ]] && REPOS=${PPG12_REPOS:-}
  [[ ${NAME} = ppg12.2 ]] && REPOS=${PPG12_2_REPOS:-}
  [[ ${NAME} = ppg12.3 ]] && REPOS=${PPG12_3_REPOS:-}
  [[ ${NAME} = pdps8.0 ]] && REPOS=${PDPS80_REPOS:-}
  [[ ${NAME} = pdps8.0.19 ]] && REPOS=${PDPS80_19_REPOS:-}
  [[ ${NAME} = pdps8.0.20 ]] && REPOS=${PDPS80_20_REPOS:-}
  [[ ${NAME} = pdpxc8.0 ]] && REPOS=${PDPXC80_REPOS:-}
  [[ ${NAME} = pdpxc8.0.19 ]] && REPOS=${PDPXC80_19_REPOS:-}
  [[ ${NAME} = pdps8x-innovation ]] && REPOS=${PDPS8X_INNOVATION_REPOS:-}
  [[ ${NAME} = ps8x-innovation ]] && REPOS=${PS8X_INNOVATION_REPOS:-}
  [[ ${NAME} = ps84-lts ]] && REPOS=${PS84_LTS_REPOS:-}
  [[ ${NAME} = pxc8x-innovation ]] && REPOS=${PXC8X_INNOVATION_REPOS:-}
  [[ ${NAME} = pxc84-lts ]] && REPOS=${PXC84_LTS_REPOS:-}
  [[ ${NAME} = pdpxc8x-innovation ]] && REPOS=${PDPXC8X_INNOVATION_REPOS:-}
  [[ ${NAME} = pdpxc84-lts ]] && REPOS=${PDPXC84_LTS_REPOS:-}
  [[ ${NAME} = pxb8x-innovation ]] && REPOS=${PXB8X_INNOVATION_REPOS:-}
  [[ ${NAME} = pxb84-lts ]] && REPOS=${PXB84_LTS_REPOS:-}
  [[ ${NAME} = pdps84-lts ]] && REPOS=${PDPS84_LTS_REPOS:-}
  [[ ${NAME} = pdps9x-innovation ]] && REPOS=${PDPS9X_INNOVATION_REPOS:-}
  [[ ${NAME} = ps9x-innovation ]] && REPOS=${PS9X_INNOVATION_REPOS:-}
  [[ ${NAME} = pxc9x-innovation ]] && REPOS=${PXC9X_INNOVATION_REPOS:-}
  [[ ${NAME} = pdpxc9x-innovation ]] && REPOS=${PDPXC9X_INNOVATION_REPOS:-}
  [[ ${NAME} = pxb9x-innovation ]] && REPOS=${PXB9X_INNOVATION_REPOS:-}
  [[ ${NAME} = prel ]] && REPOS=${PREL_REPOS:-}
  [[ ${NAME} = telemetry ]] && REPOS=${PREL_REPOS:-}
  [[ ${NAME} = proxysql ]] && REPOS=${PROXYSQL_REPOS:-}
  [[ ${NAME} = sysbench ]] && REPOS=${SYSBENCH_REPOS:-}
  [[ ${NAME} = pt ]] && REPOS=${PT_REPOS:-}
  [[ ${NAME} = pbm ]] && REPOS=${PBM_REPOS:-}
  [[ ${NAME} = mysqlshell ]] && REPOS=${MYSQL_SHELL_REPOS:-}
  [[ ${NAME} = pmmclient ]] && REPOS=${PMM_CLIENT_REPOS:-}
  [[ ${NAME} = pmm2client ]] && REPOS=${PMM2_CLIENT_REPOS:-}
  [[ ${NAME} = pmm3client ]] && REPOS=${PMM3_CLIENT_REPOS:-}
  [[ ${NAME} = tools ]] && REPOS=${TOOLS_REPOS:-}
  [[ ${NAME} = original ]] && REPOS=${ORIGINAL_REPOS:-}
  [[ ${NAME} = percona ]] && REPOS=${ORIGINAL_REPOS:-}
  if [[ -z ${DESCRIPTION} ]]; then
    if [[ -z "${REPOS}" ]]; then
      name=$(echo ${NAME} | sed 's/[0-9].*//g')
      version=$(echo ${NAME} | sed 's/[a-z]*//g')
      [[ ${name} = "ppg" ]] && REPOS="$name-$version"
      [[ ${name} = "pdmdb" ]] && REPOS="$name-$version"
      [[ ${name} = "psmdb" ]] && REPOS="$name-$version"
      [[ ${name} = "pdps" ]] && REPOS="$name-$version"
      [[ ${name} = "pdpxc" ]] && REPOS="$name-$version"
    fi
  fi
  if [[ ${NAME} = ps80 ]] || [[ ${NAME} == ps80-pro ]] || [[ ${NAME} == psmdb70-pro ]] || [[ ${NAME} == psmdb60-pro ]] || [[ ${NAME} == pxc* ]] || [[ ${NAME} == ppg* ]] || [[ ${NAME} == pdps* ]] || [[ ${NAME} == pdpxc* ]] || [[ ${NAME} == *innovation ]] || [[ ${NAME} == *lts ]]; then
    disable_dnf_module ${NAME}
    update_rpm ${NAME}
  fi
  for _repo in ${REPOS}; do
    if [[ -z $(echo ${REPOSITORIES} | grep -o ${_repo}) ]]; then
      echo "ERROR: Selected product uses \"${REPOS}\" repositories. But the \"${_repo}\" repository is disabled"
      echo "Add \"${_repo}\" repository to REPOSITORIES=\"\" variable in /etc/default/percona-release file and re-run the script"
      exit 1
    fi
    enable_repository ${_repo} $2
  done
  run_update
}
#
function check_setup_command {
  if [[ "$1" == "-y" || "${!#}" == "-y" ]]; then
      export INTERACTIVE=no
  elif [[ -n ${2} ]]; then
    echo "* \"setup\" command supports only \"-y\""
    show_help
    exit 2
  fi
}
#
get_repos_from_site
#
if [[ ${COMMANDS} != *$(echo ${1} | sed 's/^--//g')* ]]; then
  echo "ERROR: Unknown action specified: ${1}"
  show_help
  exit 2
fi
#
check_repo_availability $@
case $(echo ${1} | sed 's/^--//g') in
  enable )
    shift
    enable_repository $@
    run_update
    ;;
  enable-silent )
    shift
    enable_repository $@
    ;;
  enable-only )
    shift
    echo "* Disabling all Percona Repositories"
    disable_repository all all
    enable_repository $@
    run_update
    ;;
  setup )
    shift
    check_setup_command $@
    check_specified_alias ${@##-*}
    echo "* Disabling all Percona Repositories"
    disable_repository all all
    enable_alias ${@##-*}
    ;;
  disable )
    shift
    disable_repository $@
    run_update
    ;;
  show )
    shift
    show_enabled
    ;;
  * )
    show_help
    exit 3
    ;;
esac
#
if [[ ${AUTOUPDATE} = NO ]]; then
  show_message
fi
#


Youez - 2016 - github.com/yon3zu
LinuXploit