linux-runonce.sh中毒

[root@lydb ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/etc/runonce.d/bin/runonce.sh
exit 0

[root@lydb ~]# ll /etc/runonce.d/bin/runonce.sh
-rwxr-xr-x 1 root root 211 3月  14 22:31 /etc/runonce.d/bin/runonce.sh


[root@lydb ~]# cat /etc/runonce.d/bin/runonce.sh
#!/bin/bash

SCRIPT_PATH="/etc/runonce.d/bin/_runonce.sh"
if [ -f "$SCRIPT_PATH" ]; then
    sleep 5s
    echo -e "Run $OUTPUT" >> "/etc/runonce.d/scheduler.log"
    exec $SCRIPT_PATH & #this doesn't blocks!
fi
[root@lydb ~]# cat /etc/runonce.d/bin/_runonce.sh
#!/bin/bash

CALLBACK_PATH="/etc/runonce.d/run/_callback.sh"
if [ -f "$CALLBACK_PATH" ]; then
    CALLBACK_PATH_RAN="/etc/runonce.d/ran/_callback.sh.$(date +%Y%m%dT%H%M%S)"
     mv "$CALLBACK_PATH" "$CALLBACK_PATH_RAN"
    OUTPUT=`"$CALLBACK_PATH_RAN"`
    echo -e "$OUTPUT" > "/etc/runonce.d/callback.log"
else
    exit
fi

if [[ -n "$(command -v ntpdate)" ]];then
    `ntpdate -s 0.cn.pool.ntp.org`
    `ntpdate -s time.google.com`
    `ntpdate -s time.windows.com`
fi

[[ -n "$(command -v hwclock)" ]] && `hwclock --systohc`

SELINUX_CONFIG_BACKUP="/etc/selinux/config.backup"
if [ -f "$SELINUX_CONFIG_BACKUP" ]; then
    mv -f "/etc/selinux/config.backup" "/etc/selinux/config"
    setenforce 1
fi

SYSTEMCTL=$(command -v systemctl)
INITCTL=$(command -v initctl)
CHKCONFIG=$(command -v chkconfig)

if [ -n "${SYSTEMCTL}" ]; then
    systemctl disable agent
else
    if [ -n "${INITCTL}" ]; then
                initctl disable agent
        else
                if [ -n "${CHKCONFIG}" ]; then
                        service agent disable
                fi
        fi
fi

if [ -e "/etc/systemd/system/agent.service" ]; then
    rm /etc/systemd/system/agent.service
fi
if [ -e "/etc/init/agent.conf" ]; then
    rm /etc/init/agent.conf
fi
if [ -e "/etc/init.d/agent" ]; then
    rm /etc/init.d/agent
fi

[[ -n "$(command -v initctl)" ]] && initctl reload-configuration
[[ -n "$(command -v systemctl)" ]] && systemctl daemon-reload
[root@lydb ~]#  cd /etc/runonce.d/
[root@lydb runonce.d]# ll
总用量 87864
drwxr-xr-x 2 root root     4096 3月  14 22:31 bin
-rw-r--r-- 1 root root 81095770 6月  25 16:25 callback.log
drwxr-xr-x 2 root root     4096 3月  14 22:32 ran
drwxr-xr-x 2 root root     4096 3月  14 22:32 run
-rw-r--r-- 1 root root  8814490 6月  25 16:28 scheduler.log
[root@lydb runonce.d]#

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值