#!/bin/sh
# Stop all init scripts in /etc/init.d
# executing them in reversed numerical order.
#
ledtest  12 0
sleep 1
ledtest  12 1
# exec power on for timer
/etc/tos/scripts/powertimer
/etc/init.d/msg stop
/etc/init.d/redis stop
/etc/init.d/syscontrol stop

# stop for application
for item in $(ls -r /etc/sc.d/*)
do
    shell_name=$(basename $item)
    shell_script=/etc/init.d/$shell_name
    [ ! -x $shell_script ] && continue
    $shell_script stop >/dev/null 2>&1
done

df -T | grep /mnt/md[0-9]$ | while read line
do
    fs=`echo $line | awk '{print $2}'`
    mntpath=`echo $line | awk '{print $7}'`
    if [ "$fs" = "btrfs" ]; then
        btrfs filesystem sync $mntpath
    fi
done

exit 0
