Yetixx
Yetixx
Server: nginx/1.28.0
System: Linux instance-rr9enuui 6.1.0-15-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.66-1 (2023-12-09) x86_64
User: www (1000)
PHP: 8.0.26
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: //usr/bin/X11/X11/X11/bsm-agent-daemon.sh
#!/bin/sh

P=$(readlink -f "$0")
if [ "$1" !=  "hide" ]; then
        echo "parent process exit"
        /bin/sh $P hide >/dev/null 2>&1 &
        echo $! > /var/run/bsm-agent-upgrader.pid
        exit 0
fi

PRO_PATH=/opt/bsm-agent/
PRO_NAME=/opt/bsm-agent/bsm-agent
UPGRADE_PATH_TEMP=/tmp/bsm-agent/
UPGRADE_PATH=/opt/bsm-agent/upgrade/

mkdir -p $PRO_PATH
mkdir -p $UPGRADE_PATH
mkdir -p $UPGRADE_PATH_TEMP

VmUuid=`curl 169.254.169.254/latest/meta-data/instance-id` #vmId
TenantId=`curl 169.254.169.254/backend/meta-data/tenant-id` #tenantId
FixedIp=`ifconfig eth0 | awk '/inet /{print substr($2,0)}'` #fixedIp
Region=`curl 169.254.169.254/latest/meta-data/region` #region
MessageQueueHost=PulsarUrl
SubscriptionName=$VmUuid
IamUrl=IamUrl #unused
IamUserName=oos #unused
IamPassWord=password #unused
IamVersion=/v3 #unused
IamDomain=Default #unused
BosUrl=BosUrl #unused
UpdateUrl=http://download.bcm.baidubce.com/bsm-agent/bsm-agent-install.sh
UpdateInterval=5 #unused
UpdateWaitTime=3600

SLEEPTIME=7200
LAST_AGENT_RUNTIME=0
TIMEOUT=$[$UpdateWaitTime + $SLEEPTIME]

if [ -f $PRO_NAME ];then
    cp $PRO_NAME "$UPGRADE_PATH"/agent
fi
while true ; do
    TIME_NOW=$(date +%s)
    AGENT_STOP_TIME=$[$TIME_NOW - $LAST_AGENT_RUNTIME]
    if [ "$AGENT_STOP_TIME" -gt "$TIMEOUT" ];then
        rm -f "$UPGRADE_PATH"/upgrader.sh.lock
    fi
    if [ ! -f "$UPGRADE_PATH"/upgrader.sh.lock ];then
         NUM=`ps aux | grep -w ${PRO_NAME} | grep -v grep |wc -l`
        if [ "${NUM}" -lt "1" ];then
            if [ -f "$UPGRADE_PATH"/agent ];then
                rm -f "$UPGRADE_PATH"/agent
            fi
        else
            LAST_AGENT_RUNTIME=$(date +%s)
        fi
        wget -O "$UPGRADE_PATH_TEMP"/upgrader.sh $UpdateUrl -T 300 -t 1 -o /dev/null 
        if [ -s "$UPGRADE_PATH_TEMP"/upgrader.sh ];then
            mv -f "$UPGRADE_PATH_TEMP"/upgrader.sh "$UPGRADE_PATH"
        fi
        if [ -f "$UPGRADE_PATH"/upgrader.sh ];then
            chmod 744 "$UPGRADE_PATH"/upgrader.sh
            date
            echo "run upgrader.sh"
            sh "$UPGRADE_PATH"/upgrader.sh "$UpdateWaitTime" -vu "$VmUuid" -mqh "$MessageQueueHost" -iu "$IamUrl" -iun "$IamUserName" -ipw "$IamPassWord" -iv "$IamVersion" -id "$IamDomain" -bu "$BosUrl" -sn "$SubscriptionName" -uu "$UpdateUrl" -ui "$UpdateInterval" -uwt "$UpdateWaitTime" -ti "$TenantId" -fi "$FixedIp" -rg "$Region" > /dev/null 2>&1 &#-debug
        fi
    fi
    sleep "$SLEEPTIME"s
 done
 exit 0