逍遥游

curl 不单单是下载工具,还可以上传,支持众多协议.
我有一个摄像头接在ar9331 上面,跑mjpeg-stream,主要是拍照,监控淋花的情况,每天拍一张都两张照片,为什么不用现成的摄像头呢? 其实也可以,不过了,一来做来玩玩,另外一个可以把多年照片存起来,这个还是有点意思.

不说废话

在公司内网开内一个ftp服务器, 要端口映射到外网,这里面有点技巧,
ftp现在都是加密的,要不然就太不安全. 必须ssh.

内网ftp服务器vsftpd的设置

/etc/vsftpd.conf 关键地方我用中文标记

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=Yes 关闭ipv6 后必须打开这个
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
listen_ipv6=No 必须关闭ipv6 ,否则最后传不到实际外网的ip地址
#
# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in your local time zone. The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/xxxxx.pem
rsa_private_key_file=/etc/ssl/private/xxxx.key
ssl_enable=Yes
force_local_data_ssl=Yes
force_local_logins_ssl=Yes
ssl_tlsv1=Yes

#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
utf8_filesystem=YES

userlist_enable=Yes
userlist_deny=No
userlist_file=/etc/vsftpd.user_list
allow_writeable_chroot=Yes

pasv_enable=Yes
listen_port=??? //看需要
pasv_max_port=???? //看需要
pasv_min_port=???? //看需要
pasv_addr_resolve=Yes // 必须用这个 , 否则下面要填实际ip,但是动态ip怎么可能有ip , 这是pasv 模式下,回传给客户段的ip地址,
pasv_address=abc.com // 可以填域名,必须有上面那个yes

然后把端口映射一下.

然后利用curl 上传,curl 是支持加密ftp的.

1
curl -k --ftp-ssl --ftp-ssl-reqd --ftp-create-dirs -T xxx.jpg -u user:password ftp://abcd.com:1000/

-k 是忽略证书检查, 是ftp:// 不是ftps.

用时间作为文件夹和文件名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

folder=$(date "+%Y%m%d")
filename=$(date "+%Y%m%d%H%M%S.jpg")
#echo $filename $folder

if test -e /mnt/sda1/$folder
then
echo "folder exits"
else
mkdir /mnt/sda1/$folder
fi

wget --o /mnt/sda1/$folder/$filename http://localhost:8080/?action=snapshot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

# check ip change and update it



ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"



ipaddr=$(ifconfig pppoe-wan | awk '/inet /{print $2}' |grep -o "$ip_regex" )

old_ipaddr=$(ping -c 1 kang.ddns.info|head -1 | grep -o "$ip_regex")





if [ "$ipaddr" != "$old_ipaddr" ];then


# 发邮件
echo "Subject:$ipaddr" | ssmtp -v robot12123@334343.net

# 更新
wget -q -O /tmp/ddns --no-check-certificate 'https://nic.changeip.com/nic/update?u=XXX&p=XXX&hotname=kk'



fi

wr842n 缩水很严重, 把ram拆下来改成64MB , flash 改成25Q128 16m 版本, 当然,芯片要用编程序写入breed, 然后再焊上去, 结果写入固件后不断重启, 查来查去 ,原来没有烧入art 文件

art 是无线部分的特性参数的文件,网上做breed的大神有, 我是下载来的,我提供一份把,这里

原链接在这里

在breed 中更新qca9533的art文件后,正常启动.

固件?
固件就是opwnwrt 官网固件,我写入是18.XX版本, 我是用来做MTQQ server 的, 所以其他功能没有测试.

ssmtp 是一个简单发邮件工具,

配置/etc/ssmtp/ssmtp.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#

# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=robot123456@kaudioxxyyzz.net

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=smtp.kaudioxxyyzz.net

# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
rewriteDomain=kaudioxxyyzz.net

# The full hostname
hostname=kaudioxxyyzz.net

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
#UseTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/etc/ssl/certs/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES



AuthUser=robot1234576@kaudioxxyyzz.net
AuthPass=pw

/etc/ssmtp/revaliases

1
2
3
4
5
6
7
8
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

root:robot1111111@kaudiofdsafasd.net:smtp.kaudioafsdfasdf.net

原文章在

不过我尝试安装openwrt 路由器上

首先openwrt 的路由器空间必须大,我是安装在u盘上的,可能要10M左右空间 ,python安装也占不少空间.

程序中用到阿里云的库, aliyunsdkcore 和aliyunsdkalidns , 之前有人用pip 安装,但是openwrt 上不能, 所以下载其源码,然后解压后, 把里面核心代码复制到 /usr/lib/python2.7/XXXX (后面路径不记得) ,我看见别人自己提取相关几个文件,放在当前目录也可以.

update_ip.py 这个基本上来自前面那个文章,只不过我因为跑在openwrt上, 所以我改了获取ip的方式,改有get_ip这个脚本获取.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
# coding= utf-8

import subprocess
import os
import json
#from urllib2 import urlopen
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkalidns.request.v20150109 import DescribeDomainRecordsRequest
from aliyunsdkalidns.request.v20150109 import UpdateDomainRecordRequest

class DnsHandler:
# 从阿里云开发者后台获取Access_Key_Id和Access_Key_Secret
access_key_id = ""
access_key_secret = ""
region_id = "cn-hangzhou"


# 填入自己的域名
domain_name = ""
# 填入二级域名的RR值
rr_keyword = ""

# 解析记录类型,一般为A记录
record_type = "A"

# 用于储存解析记录的文件名
file_name = ".ip_addr"

client = None
record = None
current_ip = ''

# 初始化,获取client实例
def __init__(self):
self.client = AcsClient(
self.access_key_id,
self.access_key_secret,
self.region_id
)
self.record = self.get_record()
self.current_ip = self.get_current_ip()

# 如果公网IP发生变化,则自动修改阿里云解析记录
def reset(self):
if self.current_ip <> self.get_record_value():
# print self.current_ip
print self.update_record(self.current_ip)
self.get_record()

# 获取阿里云域名解析完整记录,并使用文件缓存
def get_record(self):
if os.path.isfile(self.file_name) :
file_handler = open(self.file_name, 'r')
r = file_handler.read()
file_handler.close()
else :
request = DescribeDomainRecordsRequest.DescribeDomainRecordsRequest()
request.set_PageSize(10)
request.set_action_name("DescribeDomainRecords")
request.set_DomainName(self.domain_name)
request.set_RRKeyWord(self.rr_keyword)
request.set_TypeKeyWord(self.record_type)
r = self.client.do_action_with_exception(request)
file_handler = open(self.file_name, 'w')
file_handler.write(r)
file_handler.close()
return json.loads(r)

# 获取阿里云域名解析记录ID
def get_record_id(self) :
return self.record["DomainRecords"]["Record"][0]["RecordId"]

# 获取当前域名解析记录
def get_record_value(self) :
return self.record["DomainRecords"]["Record"][0]["Value"]

# 修改阿里云解析记录
def update_record(self, value):
request = UpdateDomainRecordRequest.UpdateDomainRecordRequest()
request.set_action_name("UpdateDomainRecord")
request.set_RecordId(self.get_record_id())
request.set_Type(self.record_type)
request.set_RR(self.rr_keyword)
request.set_Value(value)
return self.client.do_action_with_exception(request)

# 获取当前公网IP
def get_current_ip(self):
#ip,retcode=os.system('./get_ip')
out_bytes=subprocess.check_output('/root/get_ip')
out_text= out_bytes.decode('utf8')
out_text=out_text.replace("\n","")
#print out_text
#out_text.replace("\n","").replace("\r","")
return out_text
# //json.load(urlopen('http://jsonip.com'))['ip'


# 实例化类并启动更新程序
dns = DnsHandler()
dns.reset()
1
2
3
4
5
6
7
8
9

#!/bin/sh
# check ip change and update it

ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"

ipaddr=$(ifconfig pppoe-wan | awk '/inet /{print $2}' |grep -o "$ip_regex" )

echo $ipaddr

然后加到cron 里面
*/15 * * * * python /root/update_ip.py

1.拆开接上串口,见以前的图,打开串口,重启rg100a,按回车,让其不要启动linux,在cfe控制界面停下来。
2.接上网络,登录192.168.1.1.

3,输入下面中的其中一个用户密码登录进去。

USER=telecomadmin pass=telecomadmin 2:user=telecomadmin pass=nE7jA%5m 3:user=bjcnchgw pass=8mCnC@bj

  1. 上次文件,更新系统。在串口哪里,可以看到更新过程,然后自动重启。

rg100_comm

R206,R207,R208,R209各焊上4.7K贴片电阻。成功超频400MHZ