Saturday, March 14, 2015

WINXP 常常不見了在system tray的icon

在taskman 內看到,但在systray 內鬼隱了。可看下去教學
http://winhlp.com/node/16#Main_problem_and_complete_solution

ps: winxp都不出了..

Saturday, February 28, 2015

Areca + Opensftp 在 Openwrt router 做Backup Server

Areca: http://sourceforge.net/projects/areca/?source=typ_redirect

Openwrt + Setup Openssh-sftp: http://jeffkwan.blogspot.hk/2014/12/openwrt.html

Areca 是一個功能頗全面的backup software ,不過要自訂很多選項,而且要建立batch file 同用schedule task。比較麻煩。不過好處是可以有不同類型的backup方式。又支援sftp.

Tutorial: http://www.areca-backup.org/tutorial1.php

不過發現原來要openwrt 比 areca sftp account access 要做多少少野,因為我個HD 是用ntfs

http://wiki.openwrt.org/doc/howto/writable_ntfs

寫左個Script 用來mount 個usb drive,要在root crontab 內加

root@OpenWrt:~# crontab -e

@reboot /path/to/mount.sh

root@OpenWrt:~# vi /path/to/mount.sh

#!/bin/bash

DEVICE=`fdisk -l | grep NTFS | cut -c6-9`

#check if NTFS drive available
if [[ $DEVICE != "" ]]; then

#check if it is mounted or not
if [[ "`mount | grep $DEVICE`" = "" ]]; then
/usr/bin/ntfs-3g /dev/$DEVICE /mnt/sdb -o rw,sync
else
echo NTFS Device: $DEVICE already mount
fi
else
echo NO NTFS Device found!!
fi

Sunday, February 15, 2015

Openwrt Buffalo WZR-HP-G300NH2 建立自訂鍵

想用Buffalo 前面那個鍵做其他功能
不過只找到下方那個鍵,找不到AOSS那個鍵的代號。(可能已經壞掉了?)

參考資料:

1. OpenWRT、dd-wrt自設定路由按鈕功能
First, Find out the button

http://wiki.openwrt.org/doc/howto/hardware.button

preliminary.steps

root@OpenWrt:~# mkdir -p /etc/hotplug.d/button

root@OpenWrt:~# vi /etc/hotplug.d/button/button

#!/bin/sh
logger the button was $BUTTON and the action was $ACTION

root@OpenWrt:~# logread

[...]

Feb 14 23:43:12 OpenWrt user.notice root: the button was BTN_3 and the action was pressed 上

Feb 14 23:43:13 OpenWrt user.notice root: the button was BTN_3 and the action was released 下

Feb 14 23:43:14 OpenWrt user.notice root: the button was BTN_3 and the action was pressed

Feb 14 23:43:14 OpenWrt user.notice root: the button was BTN_3 and the action was released

root@OpenWrt:/etc# wget --no-check-certificate -O /etc/hotplug.d/button/00-button https://dev.openwrt.org/export/3633
2/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button

--2015-02-14 23:45:56-- https://dev.openwrt.org/export/36332/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button

Resolving dev.openwrt.org... 2a00:1328:e000:452::26, 217.115.15.26

Connecting to dev.openwrt.org|2a00:1328:e000:452::26|:443... failed: Address family not supported by protocol.

Connecting to dev.openwrt.org|217.115.15.26|:443... connected.

WARNING: cannot verify dev.openwrt.org's certificate, issued by `/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA':

Self-signed certificate encountered.

HTTP request sent, awaiting response... 200 Ok

Length: 512 [text/plain]

Saving to: `/etc/hotplug.d/button/00-button'

2015-02-14 23:45:58 (14.9 MB/s) - `/etc/hotplug.d/button/00-button' saved [512/512]

這時你可以加添你想要的功能了。

我主要功能是用這個router BT download 到usb 內。當我推上這個鍵時會自動mount usb 及 start transmission. 而當我推下這個鍵時會自動停transmission 及umount usb.

root@OpenWrt:~# uci add system button
root@OpenWrt:~# uci set system.@button[-1].button=BTN_3
root@OpenWrt:~# uci set system.@button[-1].action=pressed
root@OpenWrt:~# uci set system.@button[-1].handler='mount /dev/sda1 /mnt/usb;sleep 5; /etc/init.d/transmission start'

root@OpenWrt:~# uci add system button
root@OpenWrt:~# uci set system.@button[-1].button=BTN_3
root@OpenWrt:~# uci set system.@button[-1].action=released
root@OpenWrt:~# uci set system.@button[-1].handler='/etc/init.d/transmission stop;sleep 5; umount /dev/sda1
'



另一方面transmission 的startup script 都要改少少野,因為要check 下是否mount 好個usb 先BT,若果mount 唔好,應該要fail 左個startup script 先啱。

Saturday, February 07, 2015

Openwrt in Buffalo WZR-HP-G300NH2 問題

安裝了Openwrt 大約三個多月,有一天突然上不到網。發現Openwrt 不能於WAN 卡攞ip, 其他內聯網機也取不到ip ,所以上不到網也連不到其他機。

  1. 每部機硬入IP 可以連上network, 重裝後wan 卡可攞external IP 但仍未可以 Lan 用dhcp

Updated at 15/3/2015

  1. 雖然唔知乜問題,重openwrt 裝後,今次不用extroot就好正常。可能是usb 同hardware 唔夾所致。

於TP-Link WDR3600 安裝OpenWRT

TP-Link Webpage http://www.tp-link.tw/products/details/?model=TL-WDR3600

OpenWRT TPLink WDR3600 http://wiki.openwrt.org/toh/tp-link/tl-wdr3600

最重要呢個video

http://youtu.be/qMWxLyFOXN4

只要download 左個file, 用網頁內的firmwire upload 上去即可。

比起要用tftp method .. TP-Link這個方法簡直方便到無論

 

FailSafe Mode in Buffalo WZR-HP-G300NH2

Reading
Failsafe: http://wiki.openwrt.org/doc/howto/generic.failsafe

Note: There is a reset button at the bottom of the router. You can use a pen to prick that button.

Preparation:
1. Set your PC ip to 192.168.1.2. Netmask: 255.255.255.0 Gateway: 192.168.1.1
2. Install telnet in your PC (if you don't have, try putty)
1. Remove the power cable.
2. Wait 30 secs and connect the power again.
3. When the red light in the front panel start to blink, prick the reset button
4. The red light will blink more faster, telnet in your router 192.168.1.1

root@openwrt:~# mount_root
root@openwrt:~# first_boot
root@openwrt:~# mtd -r erase rootfs_data

Monday, December 29, 2014

OpenWrt 筆記

Important note before installation

Officeal Failsafe: http://wiki.openwrt.org/doc/howto/generic.failsafe

My Failsafe Note: http://jeffkwan.blogspot.hk/2015/02/failsafe-mode-in-buffalo-wzr-hp-g300nh2.html

1. Secure Your Router

Read This: http://wiki.openwrt.org/doc/howto/secure.access

Create a non-privileged user in OpenWrt

root@openwrt:~# opkg update

root@openwrt:~# opkg install shadow-useradd

root@openwrt:~# useradd nicolaus

root@openwrt:~# passwd nicolaus

root@openwrt:~# mkdir /home/nicolaus

root@openwrt:~# vi /etc/passwd

nicolaus:x:1000:1000:nicolaus:/home/nicolaus:/bin/ash

root@openwrt:~# opkg install sudo

root@openwrt:~# visudo

請依照你喜好更改config。

Install sftp function - add to dropbear

http://wiki.openwrt.org/doc/howto/sftp.server

root@openwrt:~# opkg install openssh-sftp-server

然后就行了。

Install Bash and Screen

TP-Link WR703N OpenWrt post installation tips

root@openwrt:~# opkg update
root@openwrt:~# opkg install bash

root@openwrt:~# vi /etc/passwd

# Then edit /etc/passwd and change the root user line to this:
root:x:0:0:root:/root:/bin/bash

root@openwrt:~# echo ". $HOME/.bashrc" > /root/.bash_profile

Then you can either use your own .bashrc or download the one that I use (I got it from Arch wiki a few years ago) and put it in your root directory like this (if you would like to use your own .bashrc, make sure to put it in /root as well):

root@openwrt:~# wget -P /root/ http://cmikavac.net/download/.bashrc

Now log out, and log in again and you should have a brand new prompt.

Now it is time to install screen (GNU Screen)

root@openwrt:~# opkg update && opkg install screen

Download Useful tools

root@openwrt:~# opkg install vim fdisk e2fsprogs

買了張32g usb , 要加大router 容量以供proxy 使用

Prepare your USB

http://wiki.openwrt.org/doc/howto/usb.essentials

雖然插了USB 這時候還未認到. 要加入USB mod
USB 1.x and 2.x

root@openwrt:~# opkg update

root@openwrt:~# opkg install kmod-usb-storage

root@openwrt:~# opkg install kmod-usb-uhci

root@openwrt:~# insmod usbcore

root@openwrt:~# insmod uhciroot@openwrt:~# opkg install kmod-usb2

root@openwrt:~# insmod ehci-hcd

root@openwrt:~# opkg install block-mount

root@openwrt:~# opkg install kmod-fs-ext4

root@openwrt:~# opkg install libext2fs

我試左好耐都認唔到個USB ,原來係未有認到個format, 所以要format左 USB 先認到。

root@openwrt:~# mkfs.ext4 /dev/sda1

root@openwrt:~# mount /dev/sda1 /mnt

http://wiki.openwrt.org/doc/howto/extroot?s[]=rootfs

跟住移個root

root@openwrt:~# mkdir -p /tmp/cproot

root@openwrt:~# mount --bind / /tmp/cproot

root@openwrt:~# tar -C /tmp/cproot -cvf - . | tar -C /mnt -x

root@openwrt:~# umount /tmp/cproot

root@openwrt:~# vi /etc/config/fstab

[...]
config mount
    option target   /
    option device   /dev/sda1
    option fstype   ext4
    option options  rw,sync
    option enabled  1
    option enabled_fsck     0
[...]

root@openwrt:~# reboot

我用的方法是Pivot-root

後來發現如果用這個方法,我的Buffalo 會很容易死機,但另一部TP-Link 反而沒有問題。所以請有心理預備。

安裝Proxy server

呢個係筆記,當然試完之試,第一次我你用squid + Dansguardian + openDNS 不過反應唔係太好,Squid 功能大之餘,不過因為用usb read write cache file, 速度其慢,故要改做no cache mode 先快一點。因為上網速度的樽頸己去左寫落usb 到。
Dansgardian 有content filter 殺手之稱,不過不用左,可能我setup 唔全面,好多圖比佢去左,變得好怪。
OpenDNS 原理係好,不過太慢,可能我要clone 左佢個dns database 落嚟自己個openwrt 先可行。

Test #1: Squid

Transparent Proxy using Squid

OpenWRT Squid transparent configurationhttp://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html

要建立對應folder

root@openwrt:~# mkdir /var/squid/cache

root@openwrt:~# mkdir /var/squid/logs

root@openwrt:~# chown -R nobody:nogroup /var/squid

root@openwrt:~# vi /etc/squid/squid.conf

More useful information

Accesslog problem: http://www.linuxquestions.org/questions/linux-server-73/squid-2-7-not-writing-to-access-log-919523/
setup squid boot script into /etc/init.d: https://gist.github.com/frank4565/7166629

remember the don't set it transparent

root@openwrt:~# /etc/init.d/squid enable

root@openwrt:~# /etc/init.d/squid start

done

Test #2: Install dansguardian

root@openwrt:~# opkg install dansguardian

setup dansguardian at /var/dansguardian/
setup iprule to redirect to Web -> Dans -> Squid -> Internet
vi /etc/config/firewall

redirect ip from port 80 to 8080
Improve performance of Dansguardian & Squid

http://www.clearcenter.com/support/documentation/clearosguides/optimizingperformanceforproxyandcontent_filter

  • 發現增加了DansGuardian 的conf performance 不是增加太多,原來是router 本身的Hard ware 同 usb 的read write speed 太慢,故以關掉caching 反而可以提速。

如果用 DansGuardian+Squid 在squid.conf 內的 http_port 就要唔用transparent. 若果不用Dansguardian 就要加返,如果唔係會出Error

[...]
2014/12/13 15:22:43| clientTryParseRequest: FD 12 (192.168.xx.xxx:33076) Invalid Request
[...]

Test #3: 安裝OpenDNS

https://forum.openwrt.org/viewtopic.php?id=31208

Test #4: Privoxy

http://blog.vanutsteen.nl/2014/01/05/installing-privoxy-with-adblock-filters-on-openwrt/

root@openwrt:~# opkg update

root@openwrt:~# opkg install privoxy

root@openwrt:~# vi /etc/privoxy/config

[...]
    listen-address  192.168.11.1:8118
    accept-intercepted-requests 1
    permit-access  192.168.11.0/24
[...]

root@openwrt:~# /etc/init.d/privoxy enable

root@openwrt:~# /etc/init.d/privoxy start

root@openwrt:~# vi /etc/config/firewall

[...]
#transpart proxy for privoxy

config redirect
    option proto 'tcp'
    option target 'DNAT'
    option dest 'lan'
    option name 'transparent-proxy for HTTP'
    option src 'lan'
    option dest_port '8118'
    option src_dport '80'
    option dest_ip '192.168.11.1'
    option src_dip '!192.168.11.1'
[...]

Install samba

http://upsangel.com/dd-wrt/samba-easy-share-usb-storage/

root@openwrt:~# opkg update

root@openwrt:~# opkg install luci-app-samba

root@openwrt:~# opkg install samba36-server

root@openwrt:~# vi /etc/config/firewall

(follow http://wiki.openwrt.org/doc/howto/cifs.server)

[...]
config 'rule'
    option 'src' 'lan'
    option 'proto' 'udp'
    option 'dest_port' '137-138'
    option 'target' 'ACCEPT'

config 'rule'
    option 'src' 'lan'
    option 'proto' 'tcp'
    option 'dest_port' '139'
    option 'target' 'ACCEPT'

config 'rule'
    option 'src' 'lan'
    option 'proto' 'tcp'
    option 'dest_port' '445'
    option 'target' 'ACCEPT'
[...]

root@openwrt:~# vi /etc/config/samba

# change workgroups

# enable start up when reboot

root@openwrt:~# /etc/init.d/samba enable

root@openwrt:~# /etc/init.d/firewall restart

root@openwrt:~# /etc/init.d/samba start

Install Bittorrent Client - Transmission

http://wiki.openwrt.org/doc/uci/transmission

root@openwrt:~# opkg update

root@openwrt:~# opkg install transmission-daemon

root@openwrt:~# opkg install transmission-cli

root@openwrt:~# opkg install transmission-web

root@openwrt:~# opkg install transmission-remote

root@openwrt:~# opkg install luci-app-transmission

Got some problem in error log

root@openwrt:~# logread

[...]
Dec 13 23:34:04 OpenWrt daemon.err transmission-daemon[17437]: UDP Failed to set receive buffer: requested 4194304, got 327680 (tr-udp.c:77)
Dec 13 23:34:04 OpenWrt daemon.err transmission-daemon[17437]: UDP Failed to set send buffer: requested 1048576, got 327680 (tr-udp.c:88)
[...]

add value as log suggested
root@openwrt:~# vi /etc/sysctl.con

[...]
#for bittorrent
    net.core.rmem_max = 4194304
    net.core.wmem_max = 1048576

不過在 /etc/sysctl.conf加都冇用,因為openwrt 每次reboot 都overwrite (see https://forum.transmissionbt.com/viewtopic.php?f=2&t=11566)
而另一問題是start transmission 先知原來未mount 過usb ,所以想check 下mount 好未先start。
1. 首先未mount usb 前在/mnt/usb touch 個file 叫 USBDISKNOT_PRESENT
2. 若果usb 成功mount 左咁就見唔在呢個file
3. 所以在transmission startup 前check 下見唔見到呢個file 即可
也是在transmission startup script 加

要在/etc/init.d/transmission 的startup script 內加

root@openwrt:~# vi /etc/init.d/transmission

[...]
start() {
sysctl -w net.core.rmem max=4194304
sysctl -w net.core.wmem max=1048576if [ -f /mnt/usb/USB_DISK_NOT_PRESENT ]; then
echo [Panic!] exit as no usb mount!!
exit
fi
  config load 'transmission'
  config foreach start_instance 'transmission'
}
[...]

Install minidlna

root@openwrt:~# opkg install minidlna
root@openwrt:~# opkg install luci-app-minidlna

無用到,發現這個minidlna 不太支援 mp4,太多片看不到。

在Samsung Galaxy S Advance 安裝CM11

部手機太慢了,而且已很久沒有update, 想舊機再番新。


1. 於http://forum.xda-developers.com/showthread.php?t=2578599
2. 下載Roms and Gapps 並儲存於SD 卡root 內
3. Reboot in Recovery Mode http://www.theandroidsoul.com/samsung-galaxy-s-advance-recovery-mode/ 要volume up + power + home 按至綠公仔出先得
4. Wipe data /factory reset  - volume 上下, power 決定
5. 安裝 cm.zip 同 gapps. Gapps 要在http://wiki.cyanogenmod.org/w/Google_Apps 下載
6. Reboot

Remarks.
Google Play要安裝新版本,可自行google 一下



Saturday, November 29, 2014

BB100 + BBTV + Router + Magic TV

剛剛轉了用BB100 ,送一了個BBTV 放在廳中看電視,另師傅拉一條線入書房連router 上網用。

知道港視開張了,而家中的Magic TV 3300D 開始支援港視,所以就想一想如何實現Magic TV 上網大計。


想過不同方法:
1. 用BBTV + Router (openwrt) 做WDS 而用WDS連入Magic TV同電視 (不過WDS要夾,openwrt 最好同openwrt 先得,BBTV 冇試過)
2. 買過新的Magic TV USB 原來唔係隻隻夾。http://www.hkepc.com/forum/viewthread.php?tid=1907801 (最貴)
3. 將原來的Router (openwrt) 做Client Mode 拉Cable 。(試過,不過上唔到網)
4. 看這篇文http://www.hkepc.com/forum/viewthread.php?tid=1772408,想過可能要用舊Router 轉做Switch 在BBTV 前做分線。(我家中有共有兩個舊Router) How to Reuse your old Wi-Fi route as a Network Switch?

最後我想過一個問題,HKBB 有一條線入家中的BBTV 機頂盒,而那條Lan 線最尾是開义的,當時我想莫非BBTV這麼強,需要雙Cable 來支援。

原來不是的,原來BBTV 偷線用,將一條Cable 又做入屋又做入房。 原來一條Lan Cable 有8條線,基本上用4條就夠,所以將其中4條由機房入BBTV 而將同一條線的其餘4條做由BBTV到機房。所以條線轉做兩頭蛇。http://computer.discuss.com.hk/viewthread.php?tid=10538565


最後發現原來可以將個Router 放在 BBTV 後面 之後再接返入到應該插BBTV Lan位條線插入Router Lan 位即可。 http://computer.discuss.com.hk/viewthread.php?tid=9074643

而將原本在書房那一個轉做Lan-to-Lan http://kb.linksys.com/Linksys/GetArticle.aspx?docid=785463d9ecaf4cac84aed245b08d615f_3733.xml
再Diable BBTV 本身個Wi-Fi 即可成屋同一個網絡了。

而家先真正開始家中網管時代。