kernelmon



/usr/local/sbin/にkernelmonというループで監視しているシェルを見つけた。

root@LS-VLF00:~# file /usr/local/sbin/kernelmon
/usr/local/sbin/kernelmon: symbolic link to `kernelmon.sh'
root@LS-VLF00:~# cat /usr/local/sbin/kernelmon
#!/bin/sh

PIDFILE=/var/run/kernelmon.pid

PIDFileCheck()
{
if [ -f $PIDFILE ]; then
echo "$0 already running." >&2
exit 1
fi

echo $$ > $PIDFILE
trap "rm $PIDFILE" EXIT
}

PIDFileCheck
touch /var/run/active_kernelmon

while :
do
LINE=$(cat /proc/buffalo/kernevnt)
/usr/local/bin/kernelmon_exec.sh $LINE
done

kernelmon_exec.shの中で呼んでいるシェルを調べる。

root@LS-VLF00:~# cat /usr/local/bin/kernelmon_exec.sh | grep \.sh
#!/bin/sh
[ -f /usr/local/lib/libbuffalo.sh ] && . /usr/local/lib/libbuffalo.sh
[ -f /usr/local/lib/libsys.sh ] && . /usr/local/lib/libsys.sh
[ -f /usr/local/lib/libmd.sh ] && . /usr/local/lib/libmd.sh
[ -f /usr/local/lib/libdisk.sh ] && . /usr/local/lib/libdisk.sh
# /usr/local/bin/led_control.sh func blink_off
# /usr/local/bin/led_control.sh func on
# /usr/local/bin/led_control.sh func off
/usr/local/bin/agingtest_sub.sh $KEY $2 $3 $4
/usr/local/bin/agingtest_sub.sh $KEY $2 $3 $4 $5
/usr/local/bin/hdd_normal.sh /dev/disk${DISK_NUM} /mnt/disk${DISK_NUM} xfs
flashupdate)
/etc/init.d/networking.sh updatedhcp eth1 &
/etc/init.d/networking.sh updatedhcp eth0 &
/etc/init.d/pwrmgr.sh start
# because no need to care active/shutdown signal.
/etc/init.d/pmcd.sh stop
/etc/init.d/pwrmgr.sh stop
# because no need to care active/shutdown signal.
/etc/init.d/pmcd.sh stop
/etc/init.d/pwrmgr.sh stop
# start shutdown process.
echo "##### shutdown start" > /dev/console
/usr/local/bin/shutdown.sh normal
echo "##### shutdown delayed cause present status is not a normal" > /dev/console
/etc/init.d/pmcd.sh start
/etc/init.d/pmcd.sh start
PSW_pushed)
/etc/init.d/pwrmgr.sh start
/etc/init.d/SleepCtrl.sh stop
echo "##### shutdown start" > /dev/console
[ ${SW_STAT} -eq 1 ] && /usr/local/bin/shutdown.sh normal
echo "##### shutdown delayed cause present status is not a normal" > /dev/console
PSW_short_pushed)
[ -e ${SLEEP_LOCK} ] && /etc/init.d/SleepCtrl.sh stop
INITSW_pushed)
/usr/local/bin/initsw.sh &
FUNCSW_pushed)
# micon interrupts routine is located on /usr/local/bin/funcsw.sh
# /usr/local/sbin/pcless_fw_update.sh start &
/usr/local/bin/fw_deployment.sh
func_sw_pushed ${KEY}
FUNCSW_long_pushed)
# micon interrupts routine is located on /usr/local/bin/funcsw.sh
func_sw_pushed ${KEY}
/usr/local/bin/led_control.sh func on
/usr/local/bin/service_control.sh share stop
/usr/local/bin/service_control.sh media stop
/usr/local/bin/led_control.sh func off
/usr/local/bin/service_control.sh share start
/usr/local/bin/service_control.sh media start
/usr/local/bin/led_control.sh info blink_off
/usr/local/bin/led_control.sh info off
/usr/local/bin/shutdown.sh normal
# echo sense lcd switch pushed
# echo rear init switch pushed
# echo fonrt init switch pushed
/usr/local/bin/initsw.sh
/usr/local/bin/funcsw.sh
/usr/local/bin/ups_shutdown.sh
/usr/local/bin/lcd_error_man.sh rtc_error on diag_on buzzer_on
/etc/init.d/networking.sh restart
root@LS-VLF00:~#

これらも一緒に移動させる。

root@LS-VLF00:~# tar cvf /tmp/sh.tar usr/local/sbin/kernelmon usr/local/sbin/kernelmon.sh usr/local/bin/agingtest_sub.sh usr/local/bin/kernelmon_exec.sh usr/local/bin/fw_deployment.sh usr/local/bin/funcsw.sh usr/local/bin/hdd_normal.sh usr/local/bin/initsw.sh usr/local/bin/lcd_error_man.sh usr/local/bin/led_control.sh usr/local/bin/service_control.sh usr/local/bin/shutdown.sh usr/local/bin/ups_shutdown.sh usr/local/lib/libbuffalo.sh usr/local/lib/libsys.sh usr/local/lib/libmd.sh usr/local/lib/libdisk.sh etc/init.d/networking.sh etc/init.d/SleepCtrl.sh etc/init.d/pwrmgr.sh etc/init.d/pmcd.sh

実行すると足りないファイルがわかる。

root@ubuntu1:/home/awi# /usr/local/sbin/kernelmon &
[1] 917
root@ubuntu1:/home/awi# .: 13: Can't open /etc/default/buffalo
.: 13: Can't open /etc/default/buffalo

これも必要。

root@LS-VLF00:~# file /etc/default/buffalo
/etc/default/buffalo: ASCII text
root@LS-VLF00:~# cat /etc/default/buffalo
# DEFAULT PARAMETERS
DEFAULT_IP=192.168.11.150
ENETNAME=eth0
ENETNAME2=eth1
root@LS-VLF00:~#

追加する。

root@ubuntu1:/home/awi# vi /etc/default/buffalo

root@ubuntu1:/home/awi# /usr/local/sbin/kernelmon &
[1] 937
root@ubuntu1:/home/awi# [: 133: -ge: unexpected operator
[: 133: -ge: unexpected operator
[: 138: -ge: unexpected operator
.: 17: Can't open /etc/nas_feature
[: 133: -ge: unexpected operator
[: 133: -ge: unexpected operator
[: 138: -ge: unexpected operator
.: 17: Can't open /etc/nas_feature
[: 133: -ge: unexpected operator
[: 133: -ge: unexpected operator
[: 138: -ge: unexpected operator
.: 17: Can't open /etc/nas_feature

/usr/local/bin/kernelmon_exec.sh: 23: cannot create /dev/console: No such device
[: 133: -ge: unexpected operator
[: 138: -ge: unexpected operator
/usr/local/bin/kernelmon_exec.sh: 23: cannot create /dev/console: No such device
/etc/init.d/pmcd.sh: 31: killall: not found
.: 7: Can't open /usr/local/lib/libsys

etc/nas_featureとusr/local/lib/libsys ももってくる。
/etc/init.d/logtagもないとエラーが出るので同様に。