博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
arm 自动升级脚本
阅读量:4058 次
发布时间:2019-05-25

本文共 3350 字,大约阅读时间需要 11 分钟。

哈哈,试验成功了,效果还不错!!

#SubtitleServer autoupdate script.

#author:zhangshaoyan
#date:January 14,2016.
LocalAppFile=SubtitleServer_Local
LocalMD5File=${LocalAppFile}.md5
RemoteAppFile=SubtitleServer
RemoteMD5File=${RemoteAppFile}.md5
FTPServer=172.23.142.82
#download md5 file from server.
ftp -n <<EOF
open $FTPServer
user root root
binary
get $RemoteMD5File
close
bye
EOF
#check local md5 file.
if [ ! -f $LocalMD5File ];then
    echo "can't find $LocalMD5File !"
    exit -1
fi
#check download success or not.
if [ ! -f $RemoteMD5File ];then
    echo "Can't find $RemoteMD5File !"
    exit -1
fi
#extract two md5 values.
LocalMD5Value=$(cat $LocalMD5File | awk '{print $1}')
RemoteMD5Value=$(cat $RemoteMD5File | awk '{print $1}')
echo "LocalMD5:" $LocalMD5Value
echo "RemoteMD5:" $RemoteMD5Value
#compare two md5 values.
if [ ${LocalMD5Value} = ${RemoteMD5Value} ];then
    echo "No need to update,exit"
    exit 0
fi
echo "execute update process..."
#backup current version.
mv $LocalAppFile ${LocalAppFile}.backup
mv $LocalMD5File ${LocalMD5File}.backup
#download new version from ftp server.
ftp -n <<EOF
open $FTPServer
user root root
binary
get $RemoteAppFile
get $RemoteMD5File
close
bye
EOF
#add executive permission.
chmod +x $RemoteAppFile
#fix its name.
mv $RemoteAppFile $LocalAppFile
mv $RemoteMD5File $LocalMD5File
echo "update done!"
#this is the end of file.
下面是试验结果:

shell.albert@zhangshaoyan:~/project/NXPiMX53/SubtitleServer/update> ls

autoupdate.sh  SubtitleServer_Local  SubtitleServer_Local.md5
shell.albert@zhangshaoyan:~/project/NXPiMX53/SubtitleServer/update> ./autoupdate.sh
Connected to 172.23.142.82.
220 Operation successful
230 Operation successful
Remote system type is UNIX.
Using binary mode to transfer files.
200 Operation successful
local: SubtitleServer.md5 remote: SubtitleServer.md5
229 EPSV ok (|||57693|)
150 Opening BINARY connection for SubtitleServer.md5 (49 bytes)
100% |*************************************************************************************************|    49      736.17 KiB/s    00:00 ETA
226 Operation successful
49 bytes received in 00:00 (341.79 KiB/s)
Can't parse time `19700001032226'.
221 Operation successful
LocalMD5: 335c6c59831f093a276391d89f08126d
RemoteMD5: bd0940afc3bd94262d9f076d27d2ccd6
execute update process...
Connected to 172.23.142.82.
220 Operation successful
230 Operation successful
Remote system type is UNIX.
Using binary mode to transfer files.
200 Operation successful
local: SubtitleServer remote: SubtitleServer
229 EPSV ok (|||51800|)
150 Opening BINARY connection for SubtitleServer (1047787 bytes)
100% |*************************************************************************************************|  1023 KiB   11.21 MiB/s    00:00 ETA
226 Operation successful
1047787 bytes received in 00:00 (11.20 MiB/s)
Can't parse time `19700001025835'.
local: SubtitleServer.md5 remote: SubtitleServer.md5
229 EPSV ok (|||35470|)
150 Opening BINARY connection for SubtitleServer.md5 (49 bytes)
100% |*************************************************************************************************|    49        1.06 MiB/s    00:00 ETA
226 Operation successful
49 bytes received in 00:00 (455.72 KiB/s)
Can't parse time `19700001032226'.
221 Operation successful
update done!
shell.albert@zhangshaoyan:~/project/NXPiMX53/SubtitleServer/update> echo $?
0
shell.albert@zhangshaoyan:~/project/NXPiMX53/SubtitleServer/update>

转载地址:http://aczji.baihongyu.com/

你可能感兴趣的文章
【数据结构基础笔记】第一章绪论之算法及算法分析
查看>>
【数据结构基础笔记】第二章线性表之基本概念与类型定义
查看>>
【数据结构基础笔记】第二章线性表之顺序表
查看>>
C++报错:无法打开文件“路径\Debug\文件名.exe”
查看>>
【数据结构基础笔记】第二章线性表之单链表
查看>>
【积跬步以至千里】Excel行列互换
查看>>
【YOLO学习笔记】之YOLO初体验
查看>>
【YOLO学习笔记】之YOLO配置文件详解
查看>>
【YOLO学习笔记】之YOLO v1 论文笔记1(超详细:翻译+理解)
查看>>
【YOLO学习笔记】之YOLO v1 论文笔记2(超详细:翻译+理解)
查看>>
【YOLO学习笔记——数据集】之一YOLO数据集制作1(含LabelImg工具讲解)
查看>>
【积跬步以至千里】pdf转word后数字和英文格式别扭,无法修改
查看>>
【YOLO学习笔记——数据集】之一YOLO数据集制作2
查看>>
【深度学习小常识】CPU(中央处理器)和GPU(图像处理器)的区别
查看>>
【人工智能小常识】一篇文章搞懂人工智能、机器学习和深度学习
查看>>
【积跬步以至千里】如何查看浏览器保存的密码
查看>>
【opencv拓展】摄像头基本操作
查看>>
【数据结构周周练】001顺序表与链表(含上海大学832计算机组成原理与数据结构原题)
查看>>
C++获取数组长度(自写函数实现)
查看>>
C++报错:写入位置 0xCCCCCCCC 时发生访问冲突。
查看>>