#!/bin/sh
directory="/app/config/ems"
URL_INFO_EMS="http://qa.frps.lnxall.com:5011/jqye/Downloads/for_zhouyibo/new_version/ems_ctrl_6.491.0000_arm_cortex-a7_neon-vfpv4.ipk"
URL_INFO_ENER="http://qa.frps.lnxall.com:5011/jqye/Downloads/for_zhouyibo/new_version/energy_assign_6.277.0000_arm_cortex-a7_neon-vfpv4.ipk"
URL_INFO_MULTI="http://qa.frps.lnxall.com:5011/jqye/Downloads/for_zhouyibo/new_version/multi_meters_6.277.0000_arm_cortex-a7_neon-vfpv4.ipk"

if [ -d "$directory" ]; then
    cd "$directory"
    for file in ems*; do
        if [ -f "$file" ]; then
            rm "$file"
            echo "File $file deleted."
        fi
    done
else
    echo "Directory $directory does not exist."
fi

wget $URL_INFO_EMS -P /tmp/.
wget $URL_INFO_ENER -P /tmp/.
wget $URL_INFO_MULTI -P /tmp/.

opkg install --force-reinstall /tmp/ems_ctrl_6.491.0000_arm_cortex-a7_neon-vfpv4.ipk
opkg install --force-reinstall /tmp/energy_assign_6.277.0000_arm_cortex-a7_neon-vfpv4.ipk
opkg install --force-reinstall /tmp/multi_meters_6.277.0000_arm_cortex-a7_neon-vfpv4.ipk

sleep 5

echo "success"

