MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //proc/self/root/sbin/azure-repo-svc
#!/bin/bash

PATH=/sbin:/bin:/usr/bin:/usr/sbin
export PATH

Debug=1

ProtocolFile="/var/lib/waagent/Protocol"
RepoConf="/etc/yum.repos.d/CentOS-Base.repo"

main() {

    let try=0
    while [ "$try" -lt 10 ]
    do
        if [ ! -r "$ProtocolFile" ]; then
            ((try++))
            sleep 2
        else
            break
        fi
    done

    if [ "$try" -eq 10 ]; then
        RETVAL=1
        exit $RETVAL
    fi

    if [ -r "$ProtocolFile" ]; then
        protocol=$(cat $ProtocolFile)
        if [ "$protocol" = "WireProtocol" ]; then
            # Public Azure
            [ "$Debug" -eq 1 ] && echo "Azure wire server detected."

            if ( `grep -qe '^[\s\t]*\#[\s\t]*baseurl=' $RepoConf` ); then
                yum clean all 1>/dev/null 2>&1
            fi
            sed -i 's/^[\s\t]*mirrorlist=/\#mirrorlist=/g'  $RepoConf
            sed -i 's/^[\s\t]*\#[\s\t]*baseurl=/baseurl=/g' $RepoConf

        elif [ "$protocol" = "MetadataProtocol" ]; then
            # Azure Stack
            [ "$Debug" -eq 1 ] && echo "Azure Stack metadata endpoint detected."

            if ( `grep -qe '^[\s\t]*\#[\s\t]*mirrorlist=' $RepoConf` ); then
                yum clean all 1>/dev/null 2>&1
            fi
            sed -i 's/^[\s\t]*\#[\s\t]*mirrorlist=/mirrorlist=/g' $RepoConf
            sed -i 's/^[\s\t]*baseurl=/\#baseurl=/g'              $RepoConf

        else
            echo "Error: $ProtocolFile contents do not match any known endpoint types."
            RETVAL=1
            exit $RETVAL
        fi
    else
        RETVAL=1
        echo "File not found: $ProtocolFile"
        exit $RETVAL
    fi

    return 0
}

main "$@"