Friday, March 16, 2012

打开openwrt路由器的wan端口

打开openwrt路由器的wan端口以后,不需要接入路由器的内网就可以执行管理操作。

在 /etc/config/firewall 里加了两条规则而已:

#Allow ssh on wan
config rule
option 'target' 'ACCEPT'
option 'src' 'wan'
option 'proto' 'tcp'
option 'dest_port' '22'

#Allow web UI on wan
config rule
option 'target' 'ACCEPT'
option 'src' 'wan'
option 'proto' 'tcp'
option 'dest_port' '80'

这事情不是我做的,所以也备忘一下。


升级openwrt路由器

这是我的路由器的wiki,忘了从哪里转到这里来的,备忘一下。

Linksys WRT54G, WRT54GL and WRT54GS


Upgrading OpenWrt

Using mtd OR sysupgrade

If you have already installed OpenWrt and like to reflash for e.g. upgrading to a new OpenWrt version. It is important that you put the firmware image into the ramdisk (/tmp) before you start flashing.
cd /tmp/
wget http://downloads.openwrt.org/backfire/10.03.1/brcm47xx/openwrt-brcm47xx-squashfs.trx # The file must be the trx file.
mtd write /tmp/openwrt-brcm47xx-squashfs.trx linux && reboot
OR
cd /tmp/
wget http://downloads.openwrt.org/backfire/10.03.1/brcm47xx/openwrt-brcm47xx-squashfs.trx # The file must be the trx file.
sysupgrade /tmp/openwrt-brcm47xx-squashfs.trx
Feel free to explore the rest of sysupgrade options by typing 'sysupgrade' in the terminal.


Thursday, March 15, 2012

[ 更新 ] 定时重起OpenWrt路由器

有个路由器老是上不了网,每次要跑过去断电重起,很麻烦。
大侠已经刷把它刷成了OpenWrt Backfire 10.03。这就好办了。

先想用pc从lan登入上去,还不知道怎么设置?据说有安全问题。

看到路由器的admin页面上有schedule功能,就像让他定时重起。
现在设置好了,还不知道效果怎么样,明天再来看log。

我是第一次设置crontab,惭愧惭愧。这就整理一下:


1,配置工具
/usr/bin/crontab   # 是1个指向busybox的链接,又是busybox,真是好东西。
lrwxrwxrwx    1 root     root           17 Apr  6  2010 crontab -> ../../bin/busybox

2,配置文件
/etc/crontabs/root
30 5 * * * /sbin/reboot  # 每天5点30分重起。最好带上路径 
30 5 * * * root reboot   # 这里不需要写用户
否则报错:Mar 16 05:30:01 opr cron.err crond[1080]: USER root pid 2230 cmd root reboot

3,启动脚本
/etc/init.d/cron
-rwxr-xr-x    1 root     root          342 Apr  6  2010 cron

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50
start () {
        loglevel=$(/sbin/uci get "system.@system[0].cronloglevel" 2>/dev/null)
        [ -z "$(ls /etc/crontabs/)" ] && exit 1
        mkdir -p /var/spool/cron
        ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
        crond -c /etc/crontabs -l ${loglevel:-5}
}
stop() {
        killall -9 crond
}
cron # 显示帮助


4,开机运行

/etc/rc.d/S50cron  # 在rc.d下创建symbol link指向启动
lrwxrwxrwx    1 root     root           14 Mar 16 09:08 S50cron -> ../init.d/cron

root@opr:/etc/rc.d# ls
K50dropbear           S05netconfig          S59luci_dhcp_migrate
K90network            S10boot               S60dnsmasq
K95luci_fixtime       S40network            S95done
K98boot               S45firewall           S96led
K99umount             S50cron               S97watchdog
S02nvram              S50dropbear           S99sysctl
S05luci_fixtime       S50uhttpd


5,真正的服务程序在这里

/usr/sbin/crond  # 又是1个链接,指向busybox
lrwxrwxrwx    1 root     root           17 Apr  6  2010 crond -> ../../bin/busybox

参考资料:Scheduling Jobs With cron on OpenWrt


Monday, March 12, 2012

ubuntu下“Stopping System V runlevel compatibility”异常的又一解决方案

某天,在virtualbox下启动ubuntu11.10 64bit时,收到消息“Stopping System V runlevel compatibility”,还告诉我[ok]。然后,启动进度就停在那里了。在网上,类似的现象也不少,主要的焦点集中在显卡驱动上。

也有人提示说,进到tty1下,执行startx。
我试了一下,进了tty1。还好ubuntu还活着,可能还有救。
继续startx。not enough space?可能是磁盘满了?
果然是。想看看小方块里是什么内容,装1个zhcon都没有成功。
于是用vboxmanage,把10G虚拟磁盘扩展到20G。
vboxmanager modifyhd "g:\virtualbox vms\ubuntu 11.10 64bit\ubuntu 11.10 64.bit.vdi" --resize 20000
然后,重启ubuntu,进入恢复模式,回收了176M空间。
靠着这些空间,勉强进入图形界面,装了1个gparted,创建了1个分区。
接下来就简单了,创建目录/ext,把/ext目录mount到新的分区上,把一些大目录转移到新的分区下,为这些转移的目录创建link。
最终sda1分区空出了50%的空间,

现在,问题的原因都清楚了。当机之前,我为了建立android环境,安装了大量的程序,如java,eclipse,android等。消耗光了磁盘空间。

在处理过程中,还是在下面几个环节上浪费了不少时间:
1,依据网上的文章,判断是升级后显卡兼容问题,甚至怀疑是greeter的问题。然后又是改配置文件,又是升级系统。
2,以为virtualbox会为我自动扩展磁盘空间,就在建立虚拟机时低调地创建了1个小磁盘。
3,扩大虚拟磁盘后,还是天真地以为virtualbox会为我自动扩张分区。

另外还有一些问题:
1,是否应该创建1个虚拟磁盘挂接上去更加灵活点?以后还可以给其他ubuntu共享?
2,除了link还有其他方法转移大目录吗?
   有的文章建议,再创建1个大硬盘,把mbr和整个硬盘复制过去。然后让virtualbox挂接新建的大硬盘。
3,复制home目录时,把里面的文件都改为root/root属性。应该有办法带着own/group属性复制吧?



Monday, March 5, 2012

introduce to widgetsoid shown in notification area,

In stock ICS rom, its power control widget is much less flexible than it in CM.
Its buttons are static, I cannot add any else.
It occupy a row in home screen, I cannot toggle it anywhere.

I found widgetsoid in XDA froum,which satisfy my 2 requirements above.
http://forum.xda-developers.com/showthread.php?p=23274576

widgetsoid's website:
http://jaumard.android.free.fr/widgetsoid/index.php?lang=en_EN




There are 2 points worthy recording:
1,How hide widget in home screen,show it in notification area?
     widgetsoid will show on home screen in default condition.
     when a widget created, it is first thing is to check "notification" and "widget invisible" in "Advance" pane, then add buttons to widget. otherwise the check box "widget invisible" will be disable.

2, How do you make USB debug toggle to work ?
  the adb is necessary。its detail is shown following。
  I will verify it later when my adb env is ready.

ref:How hide widget in home screen?(http://www.droidforums.net/forum/droid-applications/139613-widgetsoid-3-2-4-widget-notification-only.html)
You have to redo the widget from scratch. If you try to restore it won't work. Long press on the home screen/create your widget/then select yes to the question about changing global settings/select the notifications tab and there should be an option to make it invisible.

I haven't used it in a while, but going from memory that should be right ( or close to it).

ref: How do you make USB debug toggle to work ?(http://jaumard.android.free.fr/widgetsoid/help_widgetsoid.php?lang=en_EN)
Just put the Widgetsoid apk on /system/app folder
This only works with ADB connected to the phone (doesn't work if you use root explorer or other apps like this) :
1, Remount /system as read/write
2, adb push Widgetsoid.apk /system/app/Widgetsoid.apk
3, Remount /system as read-only。

Thursday, March 1, 2012

在galaxy nexus设置openvpn,附加提问

看了openvpn installer的说明:安装openvpn的条件如下:
1,root
2,busybox
3,tun.ko
然后才是installer上场。

我用的是stock rom,已经root。

用busybox free安装了busybox。
安装路径采用默认设置:/system/xbin
想不到这个设置为以后省了不少麻烦。

接下来要装tun.ko.
先用exploer找了一下,没有发现。
在maket里找到1个工具tun.ko installer,这是1个vpn公司的产品,用来帮助客户在网站上找到和机器匹配的tun.ko安装。可惜我的机器没有配型成功。
还有人说是要编译源代码,这个东东我不会。

在xda上找到[Q] OpenVPN Support "tun.ko"
进一步的出处在http://android.modaco.com/topic/349642-tunko-for-openvpn/
原来是:If you're using stock kernel, the tun module is already compiled in. 
You don't need one.

最后跑一下installer就搞定了。可以参考如下配置:
Install OpenVPN Installer from Market and install to:
binaries: /system/xbin
route/ifconfig: /system/xbin/bb、

下面的操作可以省略,xbin下已经有了这2个工具了,
Create /system/xbin/bb with Root Explorer or from shell
Create link to busybox for ifconfig and route
ln -s /system/xbin/busybox /system/xbin/bb/route
ln -s /system/xbin/busybox /system/xbin/bb/ifconfig