<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>swigger's BLOG</title>
	<atom:link href="http://www.swigger.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.swigger.net</link>
	<description>醉卧沙场君莫笑 古来征战几人回</description>
	<lastBuildDate>Tue, 24 Jan 2012 05:34:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>fix openwrt network script bug</title>
		<link>http://www.swigger.net/archives/336.html</link>
		<comments>http://www.swigger.net/archives/336.html#comments</comments>
		<pubDate>Mon, 23 Jan 2012 09:31:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=336</guid>
		<description><![CDATA[On my router there are some interfaces in /etc/config/network. The wan interface is configured as a PPPOE netowrk to connect my ISP. There is also a pptp-vpn connected named zvpn. I found it is very slow to run “/etc/init.d/network reload”, taking about 2 miniutes. If I comment out the zvpn interface, it runs fast. Obviously, [...]]]></description>
			<content:encoded><![CDATA[<p>On my router there are some interfaces in /etc/config/network. The wan interface is configured as a PPPOE netowrk to connect my ISP. There is also a pptp-vpn connected named zvpn. I found it is very slow to run “/etc/init.d/network reload”, taking about 2 miniutes. If I comment out the zvpn interface, it runs fast.</p>
<p>Obviously, the vpn connection depends on my main connection &#8212; the wan interface which works in PPPOE mode. So this should be the key point. I spent many hours before to find how to config the dependency, including asking this question in the openwrt forum, but with no luck.  Today I wrote some debug statements in the network scripts and almost brick my router to find what is wrong, finaly I got it.</p>
<p>I thought it is because the vpn interface is inited before wan, so I named my vpn interface as zvpn to make it as the last one,  but I&#8217;m wrong.  I don&#8217;t need to care its name.  The network scripts load each interface in the order of what it is in the configration file &#8212; /etc/config/network. However, there is a problem: the network scripts also unload each interface in this order.</p>
<p>We know, the unload order should be the reverse of the load order. This can be changed by patch /sbin/ifdown.</p>
<p>This is the patch:</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;"><span style="color: #888822;">--- /rom/sbin/ifdown        2012-01-21 22:21:29.000000000 +0800</span>
<span style="color: #888822;">+++ ifdown      2012-01-23 17:23:46.000000000 +0800</span>
<span style="color: #440088;">@@ -7,10 +7,17 @@</span>
 case &quot;$1&quot; in
        &quot;-a&quot;<span style="">&#41;</span>
                <span style="">&#91;</span> -e &quot;/tmp/resolv.conf.auto&quot; <span style="">&#93;</span> &amp;&amp; rm /tmp/resolv.conf.auto
<span style="color: #00b000;">+               TODO=</span>
                config_cb<span style="">&#40;</span><span style="">&#41;</span> <span style="">&#123;</span>
<span style="color: #991111;">-                       <span style="">&#91;</span> interface != &quot;$1&quot; -o -z &quot;$2&quot; <span style="">&#93;</span> || eval &quot;$0 -w $2&quot;</span>
<span style="color: #00b000;">+                       <span style="">&#91;</span> interface != &quot;$1&quot; -o -z &quot;$2&quot; <span style="">&#93;</span> || TODO=&quot;$2 $TODO&quot;</span>
                <span style="">&#125;</span>
                config_load network
<span style="color: #00b000;">+               for i in $TODO ; do</span>
<span style="color: #00b000;">+                       $0 -w $i</span>
<span style="color: #00b000;">+               done</span>
                exit <span style="">0</span>
        ;;
        &quot;-w&quot;<span style="">&#41;</span> shift ;;</pre></div></div>

<p>Openwrt has a recovery mode that helps me to unbrick my router after I made some bad modifications to the config files. To enter this mode, power off the router, hold reset button, power on, keep holding reset button until 192.168.1.1 replying ping requests. Then just telnet 192.168.1.1, mount -t jffs2 /dev/mtdblock3 /overlay/, and fix problems there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/336.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>install vmware tools on debian (guest) for newest kernel (3.1.0)</title>
		<link>http://www.swigger.net/archives/326.html</link>
		<comments>http://www.swigger.net/archives/326.html#comments</comments>
		<pubDate>Thu, 19 Jan 2012 10:13:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=326</guid>
		<description><![CDATA[vmware version: vmware workstation 8.0.1 build-528992 debian kernel: 3.1.0-1-486 vmware tools fails to install or run. solution: 1. apt-get install libglib2.0-0 2. patch /usr/lib/vmware-tools/modules/source/vmhgfs.tar unpack vmhgfs.tar, patch, repack. the patch: diff -ur vmhgfs-only-old/file.c vmhgfs-only/file.c --- vmhgfs-only-old/file.c 2011-11-14 11:41:31.000000000 +0800 +++ vmhgfs-only/file.c 2012-01-19 17:59:47.899616529 +0800 @@ -84,6 +84,8 @@ #if defined VMW_FSYNC_OLD struct dentry *dentry, #endif [...]]]></description>
			<content:encoded><![CDATA[<p>vmware version: vmware workstation 8.0.1 build-528992<br />
debian kernel: 3.1.0-1-486<br />
vmware tools fails to install or run.</p>
<p>solution:<br />
1. apt-get install libglib2.0-0<br />
2. patch /usr/lib/vmware-tools/modules/source/vmhgfs.tar<br />
unpack vmhgfs.tar, patch, repack.<br />
the patch:</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">diff -ur vmhgfs-only-old/file.c vmhgfs-only/file.c
<span style="color: #888822;">--- vmhgfs-only-old/file.c      2011-11-14 11:41:31.000000000 +0800</span>
<span style="color: #888822;">+++ vmhgfs-only/file.c  2012-01-19 17:59:47.899616529 +0800</span>
<span style="color: #440088;">@@ -84,6 +84,8 @@</span>
 #if defined VMW_FSYNC_OLD
                      struct dentry *dentry,
 #endif
<span style="color: #00b000;">+                                        loff_t start,</span>
<span style="color: #00b000;">+                                        loff_t end,</span>
                      int datasync<span style="">&#41;</span>;
 static int HgfsMmap<span style="">&#40;</span>struct file *file,
                     struct vm_area_struct *vma<span style="">&#41;</span>;
<span style="color: #440088;">@@ -990,6 +992,8 @@</span>
 #if defined VMW_FSYNC_OLD
           struct dentry *dentry,        // IN: Dentry for this file
 #endif
<span style="color: #00b000;">+                 loff_t start,</span>
<span style="color: #00b000;">+                 loff_t end,</span>
           int datasync<span style="">&#41;</span>                        // IN: fdatasync or fsync
 <span style="">&#123;</span>
    LOG<span style="">&#40;</span><span style="">6</span>, <span style="">&#40;</span>KERN_DEBUG &quot;VMware hgfs: HgfsFsync: was called\n&quot;<span style="">&#41;</span><span style="">&#41;</span>;
diff -ur vmhgfs-only-old/filesystem.c vmhgfs-only/filesystem.c
<span style="color: #888822;">--- vmhgfs-only-old/filesystem.c        2011-11-14 11:41:31.000000000 +0800</span>
<span style="color: #888822;">+++ vmhgfs-only/filesystem.c    2012-01-19 16:41:00.303867660 +0800</span>
<span style="color: #440088;">@@ -358,6 +358,8 @@</span>
    HgfsSuperInfo *si;
    HgfsMountInfo *mountInfo;
    struct dentry *rootDentry;
<span style="color: #00b000;">+   struct dentry *tmpDentry;</span>
<span style="color: #00b000;">+   struct inode *inode;</span>
&nbsp;
    ASSERT<span style="">&#40;</span>sb<span style="">&#41;</span>;
&nbsp;
<span style="color: #440088;">@@ -408,15 +410,15 @@</span>
     * and superblock. Then HgfsInstantiate will do the rest, issuing a getattr,
     * getting the inode, and instantiating the dentry with it.
     */
<span style="color: #991111;">-   rootDentry = compat_d_alloc_name<span style="">&#40;</span>NULL, &quot;/&quot;<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+   inode = new_inode<span style="">&#40;</span>sb<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+   tmpDentry = d_alloc_root<span style="">&#40;</span>inode<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+   rootDentry = compat_d_alloc_name<span style="">&#40;</span>tmpDentry, &quot;/&quot;<span style="">&#41;</span>;</span>
    if <span style="">&#40;</span>rootDentry == NULL<span style="">&#41;</span> <span style="">&#123;</span>
       LOG<span style="">&#40;</span><span style="">4</span>, <span style="">&#40;</span>KERN_WARNING &quot;VMware hgfs: HgfsReadSuper: Could not allocate &quot;
               &quot;root dentry\n&quot;<span style="">&#41;</span><span style="">&#41;</span>;
       result = -ENOMEM;
       goto exit;
    <span style="">&#125;</span>
<span style="color: #991111;">-   rootDentry-&gt;d_parent = rootDentry;</span>
<span style="color: #991111;">-   rootDentry-&gt;d_sb = sb;</span>
    result = HgfsInstantiate<span style="">&#40;</span>rootDentry, HGFS_ROOT_INO, NULL<span style="">&#41;</span>;
    if <span style="">&#40;</span>result<span style="">&#41;</span> <span style="">&#123;</span>
       LOG<span style="">&#40;</span><span style="">4</span>, <span style="">&#40;</span>KERN_WARNING &quot;VMware hgfs: HgfsReadSuper: Could not instantiate &quot;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/326.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>some notes for mac osx dev.</title>
		<link>http://www.swigger.net/archives/323.html</link>
		<comments>http://www.swigger.net/archives/323.html#comments</comments>
		<pubDate>Sun, 08 Jan 2012 08:06:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[开发]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=323</guid>
		<description><![CDATA[set install_name for dylib g++ -install_name xxx.o -o xxx.dylib view install_name: method1: otool -L xxx.dylib see the first row. change install_name install_name_tool -change old.dylib new.dylib xxx.dylib pack libs lipo -create a_32.dylib a_64.dylib -output a.dylib]]></description>
			<content:encoded><![CDATA[<p>set install_name for dylib<br />
g++ -install_name xxx.o -o xxx.dylib</p>
<p>view install_name:<br />
method1:   otool -L xxx.dylib         see the first row.</p>
<p>change install_name<br />
install_name_tool -change old.dylib  new.dylib  xxx.dylib</p>
<p>pack libs<br />
lipo -create a_32.dylib a_64.dylib -output  a.dylib</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/323.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>patch mindmanager to avoid fuzzy text.</title>
		<link>http://www.swigger.net/archives/321.html</link>
		<comments>http://www.swigger.net/archives/321.html#comments</comments>
		<pubDate>Wed, 28 Dec 2011 11:21:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[破解狂]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=321</guid>
		<description><![CDATA[mindmanager is a great tool, but it has a bug (or they the devlopers may think it&#8217;s a feature) not fixed for years. That is, the fuzzy text problem. Just search mindmanager fuzzy text , there are many results about this bug and some patches for the old versions of mindmanager. Just as what is [...]]]></description>
			<content:encoded><![CDATA[<p>mindmanager is a great tool, but it has a bug (or they the devlopers may think it&#8217;s a feature) not fixed for years. That is, the fuzzy text problem. Just search mindmanager fuzzy text , there are many results about this bug and some patches for the old versions of mindmanager. Just as what is said from http://forum.us.mindjet.com/viewtopic.php?f=16&#038;t=3060 ，disabling the call to GdipSetTextRenderingHint fixes this bug.</p>
<p>steps to make a patch<br />
1. open a debugger, ex: ollydbg, load mindmanager.<br />
2. break at GdipSetTextRenderingHint  (gdiplus.dll!_GdipSetTextRenderingHint@8)<br />
3. when it break down, track the call to it. It&#8217;s something like:</p>

<div class="wp_syntax"><div class="code"><pre class="outline" style="font-family:monospace;">00688A2D  call        00CC8792</pre></div></div>

<p>goto 00CC8792 , it is something like:</p>

<div class="wp_syntax"><div class="code"><pre class="outline" style="font-family:monospace;">00CC8792  jmp         dword ptr ds:[0E5A758h]</pre></div></div>

<p>change it to :<br />
retn 8<br />
code bytes: c2 08 00 90 90 90<br />
4. save the modification to mindmanager.exe<br />
5. done, enjoy clear text.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/321.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>patch openwrt to avoid “bad substitution”</title>
		<link>http://www.swigger.net/archives/316.html</link>
		<comments>http://www.swigger.net/archives/316.html#comments</comments>
		<pubDate>Sat, 12 Nov 2011 19:36:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=316</guid>
		<description><![CDATA[when editing some configration of openwrt , this error maybe occured: /sbin/ifup: eval: line 1: syntax error: bad substitution I found at least one reason of this error code, and fixed it. --- /rom/lib/network/config.sh +++ config.sh @@ -15,7 +15,7 @@ &#160; local fam for fam in ipv4 ipv6; do - if &#91; -d /proc/sys/net/$fam &#93;; [...]]]></description>
			<content:encoded><![CDATA[<p>when editing some configration of openwrt , this error maybe occured:<br />
/sbin/ifup: eval: line 1: syntax error: bad substitution</p>
<p>I found at least one reason of this error code, and fixed it.</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;"><span style="color: #888822;">--- /rom/lib/network/config.sh</span>
<span style="color: #888822;">+++ config.sh</span>
<span style="color: #440088;">@@ -15,7 +15,7 @@</span>
&nbsp;
        local fam
        for fam in ipv4 ipv6; do
<span style="color: #991111;">-               if <span style="">&#91;</span> -d /proc/sys/net/$fam <span style="">&#93;</span>; then</span>
<span style="color: #00b000;">+               if ls /proc/sys/net/$fam/*/$ifn <span style="">2</span>&gt;/dev/null ; then</span>
                        local key
                        for key in /proc/sys/net/$fam/*/$ifn/*; do
                                local val</pre></div></div>

<p>If there is no such file , $key is “/proc/sys/net/ipv4/*/eth1:1/*” before this modification, statements in then case are not executed after modification. so this code resolved the problem of reporting:<br />
/sbin/ifup: eval: line 1: syntax error: bad substitution</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/316.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Google&#8217;s IP Range</title>
		<link>http://www.swigger.net/archives/313.html</link>
		<comments>http://www.swigger.net/archives/313.html#comments</comments>
		<pubDate>Tue, 30 Aug 2011 14:18:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[软件使用]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=313</guid>
		<description><![CDATA[the following ip addresses belong to google. 64.233.160.0 &#8211; 64.233.191.255 66.102.0.0 &#8211; 66.102.15.255 66.249.64.0 &#8211; 66.249.95.255 72.14.192.0 &#8211; 72.14.255.255 74.125.0.0 &#8211; 74.125.255.255 209.85.128.0 &#8211; 209.85.255.255 216.239.32.0 &#8211; 216.239.63.255]]></description>
			<content:encoded><![CDATA[<p>the following ip addresses belong to google.</p>
<p>64.233.160.0 &#8211; 64.233.191.255<br />
66.102.0.0 &#8211; 66.102.15.255<br />
66.249.64.0 &#8211; 66.249.95.255<br />
72.14.192.0 &#8211; 72.14.255.255<br />
74.125.0.0 &#8211; 74.125.255.255<br />
209.85.128.0 &#8211; 209.85.255.255<br />
216.239.32.0 &#8211; 216.239.63.255 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/313.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>定制编译openwrt.</title>
		<link>http://www.swigger.net/archives/307.html</link>
		<comments>http://www.swigger.net/archives/307.html#comments</comments>
		<pubDate>Sat, 13 Aug 2011 18:32:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=307</guid>
		<description><![CDATA[配置完openwrt之后，觉得实在是还不够。想装个tcpdump，结果发现没有空间了。看样子得想办法省出点空间。 仔细看了看openwrt的文件系统结构，发现openwrt是把编译出来的一份只读系统打包了，装载在/rom下，然后，修改新加的内容，单独放在另一个可读写的地方，装载在/overlay上。/rom和/overlay的文件都不是全部，两者结合，才真正形成了一个复合的文件系统，加载于/。对系统文件进行替换后，由于/rom不可写，不要的那个文件并没有真正删除，其空间也就浪费了。这在小小的路由器上，是不可接受的。因此对系统的修改，比如我重新弄了个改完BUG后的dropbear，就实在是大大的浪费。 而且/rom里的文件，实际存储是压缩了的，文件压缩自然可省空间。因此有必要编译一份openwrt。过程： 1. host安装必要的组件: apt-get install gawk flex unzip git subversion 2. 下载源代码。 svn co svn://svn.openwrt.org/openwrt 。从此trunk目录就成了build_root目录。 3. 更新feeds. ./scripts/feeds update -a 4. 安装必须的组件 ./scripts/feeds install tcpdump psmisc 5. make menuconfig，设置一些组件。使得Target System为Atheros AR71xx/AR7240/AR913x/AR934x。Target Profile为TP-LINK TL-WR841ND v7。 6. 继续设置menuconfig里的组件。完了后make defconfig检查，确保得到以下结果： diff y kmod-ipt-nathelper-extra y kmod-mppe y kmod-pptp y pptp y uhttpd y tcpdump y psmisc [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.swigger.net/archives/300.html">配置完openwrt</a>之后，觉得实在是还不够。想装个tcpdump，结果发现没有空间了。看样子得想办法省出点空间。</p>
<p>仔细看了看openwrt的文件系统结构，发现openwrt是把编译出来的一份只读系统打包了，装载在/rom下，然后，修改新加的内容，单独放在另一个可读写的地方，装载在/overlay上。/rom和/overlay的文件都不是全部，两者结合，才真正形成了一个复合的文件系统，加载于/。对系统文件进行替换后，由于/rom不可写，不要的那个文件并没有真正删除，其空间也就浪费了。这在小小的路由器上，是不可接受的。因此对系统的修改，比如我重新弄了个改完BUG后的dropbear，就实在是大大的浪费。</p>
<p>而且/rom里的文件，实际存储是压缩了的，文件压缩自然可省空间。因此有必要编译一份openwrt。过程：<br />
1. host安装必要的组件: apt-get install gawk flex unzip git subversion<br />
2. 下载源代码。 svn co svn://svn.openwrt.org/openwrt 。从此trunk目录就成了build_root目录。<br />
3. 更新feeds.  ./scripts/feeds update -a<br />
4. 安装必须的组件 ./scripts/feeds install tcpdump psmisc<br />
5. make menuconfig，设置一些组件。使得Target System为Atheros AR71xx/AR7240/AR913x/AR934x。Target Profile为TP-LINK TL-WR841ND v7。<br />
6. 继续设置menuconfig里的组件。完了后make defconfig检查，确保得到以下结果：</p>

<div class="wp_syntax"><div class="code"><pre class="outline" style="font-family:monospace;">diff  y
kmod-ipt-nathelper-extra y
kmod-mppe y
kmod-pptp y
pptp y
uhttpd  y
tcpdump y
psmisc m</pre></div></div>

<p>注意psmisc用Module方式就可以了，因为里面有多个程序，我只需要最重要的pstree。<br />
7. make<br />
8.  <del datetime="2012-01-22T05:08:34+00:00">修改dropbear bug。见： <a href="http://www.swigger.net/archives/291.html">http://www.swigger.net/archives/291.html</a><br />
cd ./build_dir/target-mips_r2_uClibc-0.9.32/dropbear-0.53.1</del><br />
note @2012-01-22: this bug is fixed by dropbear.<br />
9. 修改config.sh ./package/base-files-network/files/lib/network/config.sh<br />
   见 <a href="http://www.swigger.net/archives/316.html">http://www.swigger.net/archives/316.html</a><br />
-               if [ -d /proc/sys/net/$fam ]; then<br />
+               if ls /proc/sys/net/$fam/*/$ifn 2>/dev/null ; then<br />
10. 修改package/base-files-network/files/sbin/ifdown . 见 <a href="http://www.swigger.net/archives/336.html">http://www.swigger.net/archives/336.html</a><br />
11. 修改 rcS</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;"><span style="color: #888822;">--- package/base-files/files/etc/init.d/rcS     <span style="">&#40;</span>revision 29839<span style="">&#41;</span></span>
<span style="color: #888822;">+++ package/base-files/files/etc/init.d/rcS     <span style="">&#40;</span>working copy<span style="">&#41;</span></span>
<span style="color: #440088;">@@ -4,15 +4,15 @@</span>
 run_scripts<span style="">&#40;</span><span style="">&#41;</span> <span style="">&#123;</span>
        for i in /etc/rc.d/$1*; do
                <span style="">&#91;</span> -x $i <span style="">&#93;</span> &amp;&amp; $i $2 <span style="">2</span>&gt;&amp;<span style="">1</span>
<span style="color: #991111;">-       done | $LOGGER</span>
<span style="color: #00b000;">+       done</span>
 <span style="">&#125;</span>
&nbsp;
 system_config<span style="">&#40;</span><span style="">&#41;</span> <span style="">&#123;</span>
        config_get_bool foreground $1 foreground <span style="">0</span>
 <span style="">&#125;</span>
&nbsp;
<span style="color: #991111;">-LOGGER=&quot;cat&quot;</span>
<span style="color: #991111;">-<span style="">&#91;</span> -x /usr/bin/logger <span style="">&#93;</span> &amp;&amp; LOGGER=&quot;logger -s -p 6 -t sysinit&quot;</span>
<span style="color: #00b000;">+#LOGGER=&quot;cat&quot;</span>
<span style="color: #00b000;">+#<span style="">&#91;</span> -x /usr/bin/logger <span style="">&#93;</span> &amp;&amp; LOGGER=&quot;logger -s -p 6 -t sysinit&quot;</span>
&nbsp;
 . /etc/functions.sh</pre></div></div>

<p>12. 来到build_root目录，执行：</p>

<div class="wp_syntax"><div class="code"><pre class="outline" style="font-family:monospace;">$ mkdir -p files/etc/config
$ mkdir files/etc/ppp
$ cp ./build_dir/target-mips_r2_uClibc-0.9.32/dropbear-0.53.1/ipkg-ar71xx/dropbear/etc/config/dropbear files/etc/config
$ vim files/etc/config/dropbear
+  option GatewayPorts 1
$ cp ./build_dir/target-mips_r2_uClibc-0.9.32/pptp-1.7.1/ipkg-ar71xx/pptp/etc/ppp/options.pptp files/etc/ppp/
$ vim files/etc/ppp/options.pptp
- defaultroute
$ cp build_dir/target-mips_r2_uClibc-0.9.32/root-ar71xx/etc/shells files/etc/
$ vim files/etc/shells
+ /bin/false
$ mkdir -p files/usr/bin
$ cp build_dir/target-mips_r2_uClibc-0.9.32/psmisc-22.13/ipkg-ar71xx/psmisc/usr/bin/pstree files/usr/bin/
$ ./staging_dir/toolchain-mips_r2_gcc-4.5-linaro_uClibc-0.9.32/bin/mips-openwrt-linux-strip files/usr/bin/pstree 
$ make</pre></div></div>

<p>13. 大功告成。使用 bin/ar71xx/openwrt-ar71xx-generic-tl-wr841nd-v7-squashfs-factory.bin 刷系统。<br />
刷完系统再改改配置文件。(/rom/etc/config下的总是会copy到/overlay/etc/config中，预置配置文件省不了空间）组件就不用装了。<br />
结果是嵌了tcpdump和其它我需要的几个组件，最后还剩下几百K的空间。总的来说成果很好。</p>

<div class="wp_syntax"><div class="code"><pre class="outline" style="font-family:monospace;">root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 1792      1792         0 100% /rom
tmpfs                    14780        84     14696   1% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock3             844        80       764   9% /overlay
overlayfs:/overlay         844        80       764   9% /
root@OpenWrt:~# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=14780k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
/dev/mtdblock3 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/307.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>simple shell script for help compiling progs for openwrt.</title>
		<link>http://www.swigger.net/archives/305.html</link>
		<comments>http://www.swigger.net/archives/305.html#comments</comments>
		<pubDate>Sat, 13 Aug 2011 09:53:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=305</guid>
		<description><![CDATA[#!/bin/bash export PATH=/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/bin/:$PATH gcc_cmd='mips-openwrt-linux-uclibc-gcc -I/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/usr/include -I/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/include -I/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/usr/include -I/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/include &#160; -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -msoft-float -ffunction-sections -fdata-sections &#160; -L/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/usr/lib -L/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/lib -L/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/usr/lib -L/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/lib -Wl,--gc-sections ' alias mgcc=$&#40;echo $gcc_cmd&#41; usage: $ source ./rt_gcc.sh $ mgcc -o hello hello.c]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>ow<span style="color: #000000; font-weight: bold;">/</span>openwrt<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>staging_dir<span style="color: #000000; font-weight: bold;">/</span>toolchain-mips_r2_gcc-linaro_uClibc-0.9.32<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>:<span style="color: #007800;">$PATH</span>
<span style="color: #007800;">gcc_cmd</span>=<span style="color: #ff0000;">'mips-openwrt-linux-uclibc-gcc
-I/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/usr/include
-I/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/include
-I/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/usr/include
-I/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/include
&nbsp;
-Os
-pipe
-mips32r2
-mtune=mips32r2
-fno-caller-saves
-fhonour-copts
-msoft-float
-ffunction-sections
-fdata-sections
&nbsp;
-L/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/usr/lib
-L/ow/openwrt/trunk/staging_dir/target-mips_r2_uClibc-0.9.32/lib
-L/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/usr/lib
-L/ow/openwrt/trunk/staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/lib
-Wl,--gc-sections
'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mgcc</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$gcc_cmd</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>usage:<br />
$ source ./rt_gcc.sh<br />
$ mgcc -o hello hello.c</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/305.html/feed</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>我的openwrt配置</title>
		<link>http://www.swigger.net/archives/300.html</link>
		<comments>http://www.swigger.net/archives/300.html#comments</comments>
		<pubDate>Fri, 12 Aug 2011 19:14:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=300</guid>
		<description><![CDATA[路由器: tp-link wr841n (v7) 优点：11n路由器，信号不错，价格便宜。 缺点：空间较小，只有4M。刷openwrt是没有图形配置界面了，只能手动ssh配置。 刷openwrt: http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-tl-wr841nd-v7-squashfs-factory.bin 配置记录： 1. 安装必要的工具diff,pstree，以方便改设置和检查。 # opkg update # rm -f /usr/bin/cmp # opkg install diffutils # opkg install psmisc 弄完后，把diff和pstree备份， # opkg remove psmisc diffutils 然后把备份还原。没有办法，路由器空间较少。 2. 安装拨vpn所需组件： # opkg install pptp mppe kmod-ipt-nathelper-extra 其中，前两个是保证路由器上能拔VPN（PPTP）。 最后一个是使接入的设备也能拨，这个说起来容易，但出事的时候很难知道是缺了哪个包。 仔细google来google去看了很多页面才偶然找到。 3. 配置网络 配置文件/etc/config/network 配置拔号： config interface wan option ifname eth1 option [...]]]></description>
			<content:encoded><![CDATA[<p>路由器: tp-link wr841n (v7)<br />
优点：11n路由器，信号不错，价格便宜。<br />
缺点：空间较小，只有4M。刷openwrt是没有图形配置界面了，只能手动ssh配置。</p>
<p>刷openwrt:</p>
<p>http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-tl-wr841nd-v7-squashfs-factory.bin</p>
<p>配置记录：<br />
<strong>1. 安装必要的工具diff,pstree，以方便改设置和检查。</strong><br />
# opkg update<br />
# rm -f  /usr/bin/cmp<br />
# opkg install diffutils<br />
# opkg install psmisc<br />
弄完后，把diff和pstree备份，<br />
# opkg remove psmisc diffutils<br />
然后把备份还原。没有办法，路由器空间较少。</p>
<p><strong>2. 安装拨vpn所需组件：</strong><br />
# opkg install pptp mppe kmod-ipt-nathelper-extra<br />
其中，前两个是保证路由器上能拔VPN（PPTP）。<br />
最后一个是使接入的设备也能拨，这个说起来容易，但出事的时候很难知道是缺了哪个包。<br />
仔细google来google去看了很多页面才偶然找到。</p>
<p><strong>3. 配置网络</strong><br />
配置文件/etc/config/network<br />
配置拔号：<br />
config interface wan<br />
option ifname   eth1<br />
option proto    pppoe<br />
option username xxxxx@163.xx<br />
option password PASSWORD<br />
option peerdns   1<br />
配置VPN：<br />
config interface vpn<br />
option ifname pptp-vpn<br />
option proto pptp<br />
option username the_username<br />
option password the_password<br />
option server 74.117.x.x<br />
option defaultroute 0<br />
编辑/etc/ppp/options.pptp  删除其中的 defaultroute</p>
<p><strong>4. 配置路由，使得不同的IP可以走VPN出口，也可以走默认的pppoe拔号出口。</strong><br />
修改 /etc/firewall<br />
config zone<br />
option name             wan<br />
list network            &#8216;wan&#8217;<br />
list network            &#8216;vpn&#8217;</p>
<p><strong>5. 配置dns, 使得*.google.com为某个固定IP，然后这个IP走VPN出口，防止google被河蟹。</strong><br />
编辑 /etc/dnsmasq.conf<br />
address=/.google.com/74.125.153.106<br />
编辑 /etc/config/network<br />
config route<br />
option interface vpn<br />
option target 8.8.0.0<br />
option netmask 255.255.0.0</p>
<p>config route<br />
option interface vpn<br />
option target 74.125.153.0<br />
option netmask 255.255.255.0<br />
由于google一个IP可以实现所有服务，因此这样配置是可以的。搜索，邮件啥的都不会有事。</p>
<p><strong>6. 加速app store下载：</strong><br />
在/etc/hosts中：<br />
203.69.113.238 itunes.apple.com<br />
203.69.113.137 ax.init.itunes.apple.com<br />
203.69.113.174 ax.su.itunes.apple.com</p>
<p>在 /etc/dnsmasq.conf 中：<br />
address=/.phobos.apple.com/203.69.113.128</p>
<p><strong>7. 使twitter和facebook的IP解析不被河蟹：</strong><br />
在/etc/dnsmasq.conf中：<br />
server=/.facebook.com/8.8.8.8<br />
server=/.twitter.com/8.8.8.8<br />
注意前面已经设置了8.8.*.*走VPN出口，不担心它本身被河蟹。<br />
暂时没时间进一步配置使它们解析后的地址走VPN了，反正已经不上了。<br />
不过用类似前面GOOGLE的方式可以做到，只是要多写一些IP地址。</p>
<p><strong>8. 增加一个普通用户，配置外部网SSH连接：</strong><br />
add @ /etc/shells<br />
/bin/false<br />
add @ /etc/passwd:<br />
test1:*:1001:1001:test1:/home/test1:/bin/false<br />
add @ /etc/group:<br />
test1:x:1001:</p>
<p>#mkdir -p /home/test1/.ssh<br />
#chown test1.test1 /home/test1<br />
#chown test1.test1 /home/test1/.ssh<br />
#chmod 0700 /home/test1<br />
#chmod 0700 /home/test1/.ssh<br />
#cp some-id-file.pub /home/test1/.ssh/authorized_keys<br />
#chown test1.test1 /home/test1/.ssh/authorized_keys<br />
#chmod  0600  /home/test1/.ssh/authorized_keys</p>
<p>add @ /etc/firewall<br />
config redirect<br />
option src              wan<br />
option src_dport        220<br />
option dest             lan<br />
option dest_port        22<br />
option proto            tcp</p>
<p><strong>9. 安装简单http服务器，使得可以看一些基本信息，并承载proxy.pac</strong><br />
#opkg install uhttpd<br />
#/etc/init.d/uhttpd start<br />
#cd /www<br />
/www# ln -s /var/dhcp.leases dhcp.leases.txt<br />
/www# vim proxy.pac</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/300.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>a simple script to prevent bricking for openwrt</title>
		<link>http://www.swigger.net/archives/297.html</link>
		<comments>http://www.swigger.net/archives/297.html#comments</comments>
		<pubDate>Fri, 12 Aug 2011 12:49:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=297</guid>
		<description><![CDATA[root@OpenWrt:~# cat /etc/init.d/unbrick #!/bin/sh /etc/rc.common &#160; START=20 &#160; bakcat() { for i in $* ; do echo &#34;################file seperator for $i##################&#34; cat $i echo done } &#160; revert() { echo revert config... bakcat /etc/config/* &#62;/root/cfgbak.all 2&#62;&#38;1 cp -R /root/cfgbak/* /etc/config/ } &#160; start() { count=$(cat /root/count_file) if [ $count -eq 0 ] ; then revert [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="outline" style="font-family:monospace;">root@OpenWrt:~# cat /etc/init.d/unbrick 
#!/bin/sh /etc/rc.common
&nbsp;
START=20
&nbsp;
bakcat() {
	for i in $* ; do
		echo &quot;################file seperator for $i##################&quot;
		cat $i
		echo
	done
}
&nbsp;
revert() {
	echo revert config...
	bakcat /etc/config/* &gt;/root/cfgbak.all 2&gt;&amp;1
	cp -R /root/cfgbak/* /etc/config/
}
&nbsp;
start() {
	count=$(cat /root/count_file)
	if [ $count -eq 0 ] ; then
		revert
	fi
	count=$((count-1))
	echo $count &gt; /root/count_file
}
&nbsp;
root@OpenWrt:~# /etc/init.d/unbrick enable
root@OpenWrt:~# echo 3 &gt;  /root/count_file 
root@OpenWrt:~# mkdir /root/cfgbak</pre></div></div>

<p>before modifying files in /etc/config, put an usable copy in /root/cfgbak.<br />
if the script can run perfectly, echo 3 > /root/count_file after every reboot.<br />
disable this script if the config files are valid and need no more change.<br />
if any config file is wrong, reboot 3 times to unblick.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/297.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

