HEX
Server: nginx/1.26.1
System: Linux iZrj9cbdvwu1cot8sjlyzlZ 5.10.134-15.al8.x86_64 #1 SMP Thu Jul 20 00:44:04 CST 2023 x86_64
User: www (1000)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //opt/alibabacloud/hbrclient/setup
#!/bin/bash

while getopts "m:t:k:u:n:h:p:x:l:ds" arg
do
    case $arg in
        m)
            clientMode="--mode $OPTARG"
            ;;
        t)
            clientType="$OPTARG"
            ;;
        k)
            token="--userToken $OPTARG"
            ;;
        u)
            userDefinedKey="--userDefinedKey $OPTARG"
            ;;
        n)
            networkType="--networkType $OPTARG"
            ;;
        h)
            host="--host $OPTARG"
            ;;
        p)
            port="--port $OPTARG"
            ;;
        x)
            proxy="--proxy $OPTARG"
            ;;
        l)
            listeningPort="--listeningPort $OPTARG"
            ;;
        d)
            opt="-ignore-cert"
            ;;
        s)
            sourceType="sap"
            ;;
        ?)
            echo "unkonw argument"
            exit 1
            ;;
    esac
done

echo "Installing Hybridbackup client ..."

pushd `dirname $0` > /dev/null

mkdir -p conf
mkdir -p logs
mkdir -p download
mkdir -p versions

# Config backint for SAP HANA backup
if [ "$sourceType"x = "sap"x ]
then
    echo "Setting up backint client ..."
    chmod 755 client/backint
    install_path=`pwd`
    cd /usr/sap/*/SYS/global/hdb/opt/
    if [ -L ids ]
    then
        echo "remove old link ids ..."
        rm -f ids
    fi
    if [ -L hdbbackint ]
    then
        echo "remove old link hdbbackint ..."
        rm -f hdbbackint
    fi
    ln -s ${install_path}/client/ids ids
    ln -s ${install_path}/client/backint hdbbackint
    cd ${install_path}
fi

# Config hbrclient & ids
if [ ! -d "client" ]; then
    echo "[ERROR] Cannot find client directory. Failed to install HBR client."
    exit 1
fi
pushd client > /dev/null

if [ ! -f "hbrclient" ]; then
    echo "[ERROR] Cannot find file hbrclient. Failed to install HBR client."
    exit 1
fi
chmod 755 hbrclient

if [ ! -f "ids" ]; then
    echo "[ERROR] Cannot find file ids. Failed to install HBR client."
    exit 1
fi
chmod 755 ids

# Cleanup existing hbrclient service
echo "Cleanup hbrclient service."
./hbrclient service uninstall

# Install hbrclient service
echo "Register hbrclient service"
./hbrclient service install
if [ $? -ne 0 ]; then
    echo "[ERROR] Failed to install hbrclient service. Failed to install HBR client."
    exit 1
fi

# Initialize hbrclient service config file
if [ "$clientMode"x = "--mode ApsaraStack"x ]; then
    if [ "$clientType"x = "local"x ]; then
        echo "Initialize HBR local client to ApsaraStack."
        ./hbrclient init local --mode ApsaraStack ${token} ${host} ${port} ${proxy} ${listeningPort} --useSSL
        if [ $? -ne 0 ]; then
            echo "[ERROR] Failed to initialize hbrclient service config. Failed to install HBR client."
            exit 1
        fi
    else
        echo "Initialize HBR ecs client to ApsaraStack."
        ./hbrclient init ecs --mode ApsaraStack ${host} ${port} ${listeningPort} --useSSL
        if [ $? -ne 0 ]; then
            echo "[ERROR] Failed to initialize hbrclient service config. Failed to install HBR client."
            exit 1
        fi
    fi
else
    if [ "$clientType"x = "local"x ]; then
        echo "Initialize HBR local client to public cloud."
        ./hbrclient init local ${token} ${networkType} ${proxy} ${userDefinedKey} ${listeningPort}
        if [ $? -ne 0 ]; then
            echo "[ERROR] Failed to initialize hbrclient service config. Failed to install HBR client."
            exit 1
        fi
    else
        echo "Initialize HBR ecs client to public cloud."
        ./hbrclient init ecs ${token} ${listeningPort}
        if [ $? -ne 0 ]; then
            echo "[ERROR] Failed to initialize hbrclient service config. Failed to install HBR client."
            exit 1
        fi
    fi
fi

# Start hbrclient service
echo "Start hbrclient service"
./hbrclient service start
if [ $? -ne 0 ]; then
    echo "[ERROR] Failed to start hbrclient service. Failed to install HBR client."
    exit 1
fi
popd > /dev/null

# Config updater
if [ ! -d "update" ]; then
    echo "[ERROR] Cannot find update directory. Failed to install HBR client."
    exit 1
fi
pushd update > /dev/null

if [ ! -f "updater" ]; then
    echo "[ERROR] Cannot find file updater. Failed to install HBR client."
    exit 1
fi
chmod 755 updater

# Cleanup existing hbrclientupdater service
echo "Cleanup hbrclientupdater service."
./updater -service uninstall

# Install & start hbrclientupdater service
echo "Register hbrclientupdater service."
./updater -service install
if [ $? -ne 0 ]; then
    echo "[ERROR] Failed to install hbrclientupdater service. Failed to install HBR client."
    exit 1
fi
echo "Start hbrclientupdater service."
./updater -service start
if [ $? -ne 0 ]; then
    echo "[ERROR] Failed to start hbrclientupdater service. Failed to install HBR client."
    exit 1
fi
popd > /dev/null

popd > /dev/null
echo "Install complete."