您当前位置: 首页 »

shell

分类目录归档: shell

【chrome、webrtc】python-boto代理设置

webrtc最近半年的时间里又改代码框架,又改下载脚本!真***法科!

 

目前除了使用到python-curl、git、还用到了一个叫做python-boto的玩意,用来从aws上下东西的。不理解为啥不用自家的云。。。。

现在拿webrtc的代码,除了需要配置git、python-curl的代理,还需要配python-boto的代理。

python-boto的代理配置方式如下:

1,在某个目录中创建一个.cfg后缀的文件

2,然后填入内容如:

  1. [Boto]
    proxy=127.0.0.1
    proxy_port = 10808

3,命令行中输入!

  1. NO_AUTH_BOTO_CONFIG=C:\work\depot_tools\boto.cfg

2017-05-08 | | shell, windows-shell, 编码技巧, 音视频_图像相关, 音视频容器, 音视频编解码

【chrome、webrtc】python-boto代理设置已关闭评论

【MacOSX、iOS、跨平台编译】在跨平台编译时MacOSX Serria/XCode是我遇到bug最多的平台

最近被安排来搞定android、ios、mac、windows下的webrtc、ffmpeg和x264的编译问题。

除了由于webrtc配置工程的问题在windows下我自己的搭建环境无法使用,最终求助于之前使用的虚拟机环境以外,android下的webrtc都比较顺利,同样也是编译anroid环境的和windows环境的ffmpeg,相对来说也是比较顺畅(虽然还是出现了一些坎坷)。

但在Mac环境下编译webrtc、ffmpeg和x264就没有那么幸运了。简直就是人间地狱,首先说明一下,这个Mac机原先是有其他开发者在上面编译成功过这三个工程的,到我之后就开始出现了一大堆问题(当然也有可能我用的是用户新帐号的缘故)。

 

人间地狱的开始

  • 先说一说编译webrtc遇到的坑爹问题。由于webrtc编译环境我们只输出静态库,并不输出一个framework或者app,所以并不需要关心太多app层面的问题(如证书相关)。虽知道在webrtc的gyp检查项目中会对证书冲突做检查,由于机器中存在多个证书,导致gyp阶段无法生成正确的编译配置参数。导致折腾了一周,最后才发现和证书有关。虽然这个问题和gyp有一定的关系,但也只是我对mac上编译和交叉编译的被坑的起点。

 

  • 接着是x264和ffmpeg编译时,由于给我的工程之前都是能够成功编译的,现如今拿过来,除了Mac平台可以通过以外,真机和模拟器都不行。折腾来折腾去几天,最后发现是clang去找依赖的时候找错了,找了mac的依赖环境,而不是去找iphoneos的依赖,然后怎么调都没用。很是坑爹,就拿网上的现成脚本来跑也是不行。

最后去查config.log,发现一堆错误,其中ffmpeg的错误还有一个叫做gas-preprocessor.pl的执行错误,由于是通过git直接从网上拿下来的脚本,在没有任何修改的情况下,通过sftp发到mac里面,给了执行权限之后通过命令行直接执行一点问题都没有,但通过configure执行时就一直报没有权限的错,怎么也想不明白;后来试着用curl拿文件,居然通了。当时我就估计如果不是字符集的问题,就是权限标记位的问题。

接着再继续修改关于依赖的问题,仅仅一个交叉编译工具clang,居然在不同的工程里面对同一个路径参数能够出现多种不同的行为,后来还特意看了一下clang是不是GNU开源社区的代码,通过–version看到的内容如下:

Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

可见这个坑是苹果自己的。可能是由于命令行的长度的不同,导致解析命令行的bug?或者其他什么坑爹问题?反正我是不知道了,近几年开始苹果的产品也不见得有多少优势了,正在被一点点拉小差距。如果不是为了混口饭吃,苹果的任何产品我真的不想去碰!

2017-03-20 | | linux-shell, shell, unix编程环境学习, 图像处理, 音视频_图像相关, 音视频编解码

【MacOSX、iOS、跨平台编译】在跨平台编译时MacOSX Serria/XCode是我遇到bug最多的平台已关闭评论

【mysql、innodb】mysql启动失败,出现crash

不知道什么时候,vps上面的mysql不启动了,后来果断来了个apt-get upgrade。还是无解,发现mysql.err为空。怎么弄头看不明白。

后来查看/var/log/syslog,发现如下记录:

May 28 07:36:53 emhct mysqld: 160528 7:36:53 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. P$
May 28 07:36:53 emhct mysqld: 160528 7:36:53 [Note] /usr/sbin/mysqld (mysqld 5.5.49-0+deb7u1) starting as process 2208 …
May 28 07:36:53 emhct mysqld: 160528 7:36:53 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future$
May 28 07:36:53 emhct mysqld: 160528 7:36:53 [Note] Plugin ‘FEDERATED’ is disabled.
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: The InnoDB memory heap is disabled
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Mutexes and rw_locks use GCC atomic builtins
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Compressed tables use zlib 1.2.7
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Using Linux native AIO
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Initializing buffer pool, size = 128.0M
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Completed initialization of buffer pool
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: highest supported file format is Barracuda.
May 28 07:36:53 emhct mysqld: InnoDB: The log sequence number in ibdata files does not match
May 28 07:36:53 emhct mysqld: InnoDB: the log sequence number in the ib_logfiles!
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Database was not shut down normally!
May 28 07:36:53 emhct mysqld: InnoDB: Starting crash recovery.
May 28 07:36:53 emhct mysqld: InnoDB: Reading tablespace information from the .ibd files…
May 28 07:36:53 emhct mysqld: InnoDB: Restoring possible half-written data pages from the doublewrite
May 28 07:36:53 emhct mysqld: InnoDB: buffer…
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: ERROR: We were only able to scan the log up to
May 28 07:36:53 emhct mysqld: InnoDB: 16701665280, but a checkpoint was at 16701665306.
May 28 07:36:53 emhct mysqld: InnoDB: It is possible that the database is now corrupt!
May 28 07:36:53 emhct mysqld: 160528 7:36:53 InnoDB: Assertion failure in thread 3064944864 in file fut0lst.ic line 83
May 28 07:36:53 emhct mysqld: InnoDB: Failing assertion: addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA

 

mysql居然crash了,后来网上了一下,发现好像是innodb顺坏了,简单扫描了mysql官方文档,看的云里雾里。

最终,把mysql数据库存放目录下的ibdata1、ib_*文件删除后,mysql正常启动。

2016-05-28 | | linux-shell, mysql备忘录, shell, vps总结

【mysql、innodb】mysql启动失败,出现crash已关闭评论

[win]用脚本定时检查a和b进程是否存在

一下是一段脚本用于检查某个进程是否存在

@echo off 
:star
ping 127.1 -n 5 >nul 2>nul
tasklist|findstr /i "a.exe" > nul
if errorlevel 1 ( echo "[%date% %time%] a.exe **没有找到**"
) else ( echo "[%date% %time%] a.exe ==正在运行==" )
tasklist|findstr /i "b.exe" > nul
if errorlevel 1 ( echo "[%date% %time%] b.exe **没有找到**"
) else ( echo "[%date% %time%] b.exe ==正在运行==")
echo -------------------------------------
goto star
2014-11-13 | | windows-shell

[win]用脚本定时检查a和b进程是否存在已关闭评论

【debian7】自动备份目录shell脚本

这个脚本的原型来自之前提到的db备份脚本,但做了一些改动略有不同。

这次的脚本支持逗号分隔的kv输入,具体输入文本格式如下

+------------------+--------------+----------------+
| folder full path | separator(,) | folder descript|
+------------------+--------------+----------------+
| /var/aaaaa/      |    ,         | aaaa11111      |
+------------------+--------------+----------------+

发送到邮箱的标题命名:web_bak_${folder descript}_${data}

具体shell代码如下:

#!/bin/bash
 
#need 2 var
if (($# != 2)); then
        echo "need input [Web Site Name Full Path in File] [mode]"
        echo "mode -> 0, <Web Site Name Full Path in File> read!"
        echo "mode -> 1, do Web Site bak!"
        exit;
fi
 
if (($2 < 0 && $2 > 1)); then
        echo "err mode!"
        exit
fi
 
#filter some lines:
# 1. pure tab line
# 2. pure \r\n
# 3. pure space line
WebSiteFullPathInFilePath=$1
sed /^[[:space:]]*$/d $WebSiteFullPathInFilePath > $WebSiteFullPathInFilePath".tmp"
 
#################################################### 
#pre-info
#
# +----------+--------------+-------------+
# | fullpath | separator(,) | description |
# +----------+--------------+-------------+
#
####################################################
loop_count=0
bak_WebSiteFullPathInFilePath_target=1
bak_WebSiteDescriptionFilePath_target=1
echo "WebSiteFullPathInFilePath: "$WebSiteFullPathInFilePath" <<<>>>  WebSiteFullPathInFilePath_tmp: "$WebSiteFullPathInFilePath".tmp"
echo ============ output all web site info $(date +"%Y%m%d")  ==================
while read -r line
do
	#echo $line
	stringlen=${#line}
	keyend=$(expr index $line ',')
	key=${line:0:$keyend-1}
	value=${line:$keyend:$stringlen-$keyend}

	#echo "stringlen: "$stringlen" keyend: "$keyend" key: "$key" value: "$value

	bak_WebSiteFullPathInFilePath_target[loop_count]=$key
	bak_WebSiteDescriptionFilePath_target[loop_count]=$value
        ((loop_count++))
done < $WebSiteFullPathInFilePath".tmp"

i=0
for ((;i<$loop_count && $loop_count>0;i++))
do
 echo "website name: "${bak_WebSiteDescriptionFilePath_target[$i]}
 echo -e "\twebsite full path: "${bak_WebSiteFullPathInFilePath_target[$i]}"\n"
done
echo "total - "$i
echo ============ end ==================

if (($2 == 0)); then
        echo "test over"
        exit;
fi

if (($i<=0)); then
 echo "don't have website full path!"
 exit
fi

#do work
i=0
for ((;i<$loop_count && $loop_count>0;i++))
do
        WebSiteFullPath=${bak_WebSiteFullPathInFilePath_target[$i]}
	WebSiteDescription=${bak_WebSiteDescriptionFilePath_target[$i]}
        BakName_tmp=website_bak_${WebSiteDescription}_$(date +"%Y%m%d")

	#mkdir
	mkdir /tmp/website_bak
	mkdir /tmp/website_bak/${WebSiteDescription}

        #del bak file before 3 days
        rm -rf /tmp/website_bak/${WebSiteDescription}/website_bak_${WebSiteDescription}_$(date -d -3day +"%Y%m%d").tar.gz

        #compact file
        tar zcf /tmp/website_bak/${WebSiteDescription}/$BakName_tmp.tar.gz $WebSiteFullPath

        #Send mail
        mutt -s $BakName_tmp "email@163.com" -a /tmp/website_bak/${WebSiteDescription}/$BakName_tmp.tar.gz < /var/auto_script/emptytext.txt
done

同样作为定时任务,将命令执行放在crontab中

2014-08-24 | | linux-shell

【debian7】自动备份目录shell脚本已关闭评论

【debian7】创建自动任务

在创建自动任务之前需要安装的安装包:
cron

使用crontab来对当前用户的定时任务进行编辑
crontab -u //设定某个用户的cron服务,一般root用户在执行这个命令的时候需要此参数
crontab -l //列出当前(某个)用户cron服务的详细内容
crontab -r //删除当前(某个)用户的cron服务
crontab -e //编辑当前(某个)用户的cron服务

这里使用root创建的用户,所以直接在root用户下,执行crontab -e编辑好以后然后退出编辑器即可。
如果不放心还可以执行以下/etc/init.d/cron restart

编辑好以后的脚本如下

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
25 22 * * 4 /var/auto_script/db_bak/dbbak.sh /var/auto_script/db_bak/dbname.txt 1 >> /var/auto_script/db_bak/autoworker_log.txt

其中的25代表时间的25分钟
22代表时间的22点
4代表每周星期4
/var/auto_script/db_bak/dbbak.sh /var/auto_script/db_bak/dbname.txt 1 >> /var/auto_script/db_bak/autoworker_log.txt 则是命令行

对于cron自身的配置来说,他的配置放在/etc/crontab,内容如下:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
51 * * * * root cd / && run-parts --report /etc/cron.hourly
40 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
48 5 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
28 2 23 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

对于cron的配置来说,尽量不要去修改,网上有些文章说,如果要执行周期性任务,可以到/etc/cron.*目录下保存脚本,我这边看到的是,大部分都是系统类任务;最好不要去这样做。混淆了脚本的分类很麻烦

2014-05-30 | | linux-shell

【debian7】创建自动任务已关闭评论

【debian7】按需备份数据(mysql),并将备份好的文件通过邮件发送到指定邮箱

首先需要安装这几个包:
mutt、uuencode、sendmail

脚本如下:

#!/bin/bash

#need 2 var
if (($# != 2)); then
        echo "need input [DBNamefile] [mode]"
        echo "mode -> 0, test DBNamefile read!"
        echo "mode -> 1, do DB bak!"
        exit;
fi

if (($2 < 0 && $2 > 1)); then
        echo "err mode!"
        exit
fi

#filter some lines:
# 1. pure tab line
# 2. pure \r\n
# 3. pure space line
DBNameFilePath=$1
sed /^[[:space:]]*$/d $DBNameFilePath > $DBNameFilePath".tmp"

#pre-info
loop_count=0
bak_DBName_target=1
echo "DBNameFilePath: "$DBNameFilePath" <<<>>>  DBNameFilePath_tmp: "$DBNameFilePath".tmp"
echo ============ output all db Name $(date +"%Y%m%d")  ==================
while read -r line
do
    #echo $line
        bak_DBName_target[loop_count]=$line
        ((loop_count++))
done < $DBNameFilePath".tmp"

i=0
for ((;i<$loop_count && $loop_count>0;i++))
do
 echo ${bak_DBName_target[$i]}
done
echo "total - "$i
echo ============ end ==================

if (($2 == 0)); then
        echo "test over"
        exit;
fi

if (($i<=0)); then
 echo "empty db name!"
 exit
fi

#do work
i=0
for ((;i<$loop_count && $loop_count>0;i++))
do
        DBName_Tmp=${bak_DBName_target[$i]}
        DataBakName_tmp=Data_bak_${DBName_Tmp}_$(date +"%Y%m%d")

        #del db before 3 days
        rm -rf /home/backup/Data_$(date -d -3day +"%Y%m%d").tar.gz

        #expory mysql db
        mysqldump -u root -ppassword $DBName_Tmp > /tmp/mysql_db_bak/$DataBakName_tmp.sql

        #compact db file
        tar zcf /tmp/mysql_db_bak/$DataBakName_tmp.tar.gz /tmp/mysql_db_bak/$DataBakName_tmp.sql

        #del temporary sql
        rm -rf /tmp/mysql_db_bak/$DataBakName_tmp.sql

        #Send mail
        mutt -s $DataBakName_tmp "email@163.com" -a /tmp/mysql_db_bak/$DataBakName_tmp.tar.gz < mailbody.txt
done

上面脚本的用法是:

./a.sh 1.txt 0

1.txt是保存要备份数据库名称的文件。

2014-05-30 | | linux-shell

【debian7】按需备份数据(mysql),并将备份好的文件通过邮件发送到指定邮箱已关闭评论