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

 

 

 

 

Saturday, February 07, 2015

Openwrt in Buffalo WZR-HP-G300NH2 問題

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

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

於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
然后就行了。

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 uhci

root@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 done.

安裝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 configuration

http://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

#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 #1: 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/clearos_guides/optimizing_performance_for_proxy_and_content_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 #1: 安裝OpenDNS

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

Test #2: 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
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)

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) 要在/etc/init.d/transmission 的startup script 內加 [...] start() { #新加入的 sysctl -w net.core.rmem_max=4194304 sysctl -w net.core.wmem_max=1048576 #新加入的要在start tranmission 前run config_load 'transmission' config_foreach start_instance 'transmission' } [...] 有時transmission 自動死機 root@OpenWrt:/etc# vi /root/checktransmission.sh !/bin/sh if [ -f /mnt/usb/USB_DISK_NOT_PRESENT ]; then echo [Panic!] exit as no usb mount!! exit fi VAR=`ps | grep transmission | grep -v grep` if [ -z "$VAR" ]; then #if no transmission found -> start transmission /etc/init.d/transmission start fi

Install minidlna

opkg install minidlna
opkg install luci-app-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 即可成屋同一個網絡了。

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





Monday, July 14, 2014

Scribus 內使用中文字型 Winxp+Scribus

爬文看過這裏

  1. http://blog.sinses.tn.edu.tw/index.php?op=ViewArticle&articleId=7606&blogId=169
  2. http://www.openfoundry.org/tw/foss-programs/8160--scribus-1-


中文字型只可以選 SimHei, 其他PMingLiu 用不到。不知何解。

結論:
用Scribus 用來做一本約百多頁的雜誌(內部用),發現基本功能不錯,只不過中文對位有很大改善的空間,若想左右對齊是做不到的,很多是右手邊會對不好。

而另外一個問題是若文章夾雜中英文,因文字框內若選一個字型,若選英文會出不到中文,但選中文SimHei英文字會不好看,所以要很麻煩每一個中文或英文轉字型。

若文章中有一個字符出不到,若出PDF會有Error.

Tuesday, June 24, 2014

Delete Cache in Samsung Galaxy S Advance

Software mathod



Hard Ware Method

How to Boot Into Samsung Galaxy S Advance Recovery Mode

 入左Recovery mode 之後
用Volumn 上下,選wipe cache partition 按power 確定
之後選reboot 即可
 
[Guide] Rebooting into Recovery Mode for the Galaxy S2, S3, and Tab2


Tuesday, May 28, 2013

[Excel] VBA Marco - Resizing all image in worksheet

想將網上一張表格抄在Excel 內用,而這張資料表有很多圖片。貼在Excel Worksheet 內全部放大了。

在MSDN內有一個簡單Marco已經解決了問題。
http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/dffae7ac-ea89-45b7-b42e-e70152516325