魔豆love移植

其中love.sh代码如下:

#!/bin/sh 

if [ ! -f "$app_conf" ]; then
    echo url=http://modou.ydjiao.com/api.php > $app_conf
    echo interval=15s >> $app_conf
fi

url=http://modou.ydjiao.com/api.php
interval=15s
sn=`sn_get snmac`
mac=`ifconfig|grep ra0|awk '{print $5}'`
vcode=0

. $app_conf #这句是如何运行的,作用应该是发送当前的用户信息,

printf '%15s %s
' url $url
printf '%15s %s
' sn $sn
printf '%15s %s
' mac $mac


old_msg=''
while true
do
    msg_url="${url}?sn=$sn&mac=$mac&vcode=$vcode"
    printf '%15s %s
' msg_url "$msg_url"
    #wget -q "$msg_url" -O $tmp_file
    wget -O $tmp_file -q "$msg_url"
    cmd_type=`head -n 1 $tmp_file` #text/image msgbox
    cmd_time=`head -n 2 $tmp_file|tail -n 1` #第二行
    cmd_text=`sed '1,2d' $tmp_file` 
    if [ "$cmd_text" = "$old_msg" ]; then #消息内容,包括绑定码,文字,图片
        echo skip same msg: cmd_time=$cmd_time
        sleep $interval
        continue;
    fi
    old_msg=$cmd_text
    echo cmd_type=$cmd_type, cmd_time=$cmd_time

    ps | grep -v grep | grep "$tmp_custom_conf" | awk '{print $1}'|xargs kill >/dev/null 2>&1 #杀死显示文字进程,custom /tmp/love-custom.conf进程
    ps | grep -v grep | grep "$tmp_image" | awk '{print $1}'|xargs kill >/dev/null 2>&1 #杀死imageview /tmp/love-image.png 320 240

    if [ "$cmd_type" = 'msgbox' ]; then
        echo msgbox="$cmd_text"; #打印出内容
        echo $cmd_text > $tmp_custom_conf; #保存内容
        /bin/blwakeup
        #/bin/custom $tmp_custom_conf &
        custom $tmp_custom_conf & #显示文字
        echo /bin/custom $tmp_custom_conf; #显示
    elif [ "$cmd_type" = 'image' ]; then
        img=`echo -e "$cmd_text"|head -n 1`; #获取图片的网址(第一行),同时也赋值给img
        img_size=`echo -e "$cmd_text"|tail -n 1`; #获取图片尺寸(第二行),同时也赋值给img_size
        wget -q "$img" -O $tmp_image #下载图片
        ls -l $tmp_image #查看自定目录文件的属性
        /bin/blwakeup
        #/bin/imageview $tmp_image $img_size &
        imageview $tmp_image $img_size &
        #echo /bin/imageview $tmp_image $img_size
        echo imageview $tmp_image $img_size
    elif [ "$cmd_type" = 'vcode' ]; then #第一次运行
        vcode=$cmd_text
        echo vcode=$vcode >> $app_conf #保存需解绑的信息
        continue;
    fi
    sleep $interval
done

源码下载:

http://pan.baidu.com/s/1jGMrtie

相关链接:

http://bbs.modouwifi.cn/thread-27285-1-1.html

原文地址:https://www.cnblogs.com/smbx-ztbz/p/4771851.html