Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, April 18, 2022

Adguard Home @ Oracle Cloud free tier

其實好耐之前玩過一次,不過今次轉去 Oracle Cloud,唔駛用自己電費。

最簡單咁起個 Ubuntu Instance,再跟住 github 度做就得。

 我開得 post 都梗係唔會咁簡單。話說 check 過晒啲 setting,又 ssh 入到個 instance,個 service 又行緊叫你入 http://ip:3000/ 入去做 setup,但梗係唔知點解入唔到去。俾我發現原來 Ubuntu 自己本身啲 firewall 未開番 ingress rules.

要喺 /etc/iptables/rules.v4 度加入下邊三行:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 53 -j ACCEPT
-A INPUT -p udp --dport 53 -j ACCEPT

 之後,refresh 一下個 firewall rules ,跟住你就會順利入到個介面。

再之就喺自己啲  devices 度指去你個 instance 個 IP Address,完成。

 


Sunday, January 16, 2022

HP LaserJet P1006 之重新 - Network Shared Printing

話說家中有部陳年的 HP LaserJet P1006。呢部嘢十分騎呢,我都唔係好知 printing o既 protocol,以我有限o既知識o既理解就係,呢部煩嘢係將要 print o既嘢,全部轉成 image 先再 print 出嚟,估計都係啲史前o既產物。

轉入正題,話說近來我安裝o左 unRAID,突然靈機一觸,既然個 server 長著,係唔係又好似之前 DSM o既實驗咁,host 個 printer server 令部陳年 laser printer 可以變成 network printer 呢。

上網 search 咗一下,有一個 docker 叫 CUPS,用嚟做 printer server。咁我就拿拿林就安裝,揀好型號再裝好 driver,到裝好之後就試 print test print。事情就當然無咁順利喇。部 printer 一啲反應都無。click 落去 log,就有一堆 error:

E [15/Jan/2022:13:19:16 -0600] [Client 307] Returning IPP client-error-document-format-not-supported for CUPS-Add-Modify-Printer (ipp://localhost/printers/HP_LaserJet_P1006) from localhost.
E [15/Jan/2022:13:19:49 -0600] [Client 313] Returning IPP client-error-document-format-not-supported for CUPS-Add-Modify-Printer (ipp://localhost/printers/HP_LaserJet_P1006) from localhost.
E [15/Jan/2022:13:19:59 -0600] [Client 318] Returning IPP client-error-document-format-not-supported for CUPS-Add-Modify-Printer (ipp://localhost/printers/HP_LaserJet_P1006) from localhost.
W [15/Jan/2022:13:25:19 -0600] CreateProfile failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files
W [15/Jan/2022:13:25:19 -0600] CreateProfile failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files
W [15/Jan/2022:13:25:19 -0600] CreateDevice failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files

上網一查,發現部 printer 除咗要裝 driver 之外,仲要裝一個HPLIP o既 Plug-in 佢先可以 printer 到嘢。估計都係因為佢奇奇怪怪o既打印方法。我遇到兩個問題,就係唔知點 download 同唔知點 run。

https://developers.hp.com/hp-linux-imaging-and-printing/plugins

睇完一大輪,HP 淨係叫人喺 CLI 度打 HP-setup 或者 HP-plugin,我心諗,屌,我喺 docker 度裝 CUPS,咩都無裝又點會行到呢兩個 command 呀師傅。

搞咗一大輪,沮喪到就嚟放棄之際,我就喺 terminal 度手痕打 HP-plugin 試下。嘩,屌,真係有反應o架喎。唔好問我點解得,我都唔知點解,佢可能原生就有娤咗 HP 個 printing package。但入到去有三個 options, d 就係 download,p 就俾條 path, q 就 exit。揀 'd' 佢又話 download 唔到喎。咁我咪 wget 個 plug-in 囉,可以去呢個網址度睇下:

https://developers.hp.com/hp-linux-imaging-and-printing/plugins

一個係 .run 尾,一個係 .asc 尾,兩個都要 download,因為佢要計一下個 plug-in 係唔係原裝無俾人 alert 過。跟住再 hp-plugin 入去,今次揀 p 去 specify 頭先 download 咗返嚟個 path。仆你街,佢又話咩 Gnu command not found。上網搵一輪之後原來又要裝個咩 gnupg o既 package。由於 CUPS 係 debian 底o既 docker。所以可以用 apt install gnupg 呢個 command 去 download 同 install 所需 package. 之後再行 hp-plugin,入到去再 specify 條 path 就真係大功告成。我估唔到真係會得咗。

最開心係 iPhone 都睇到個 printer 可以喺部陳年 printer 度打印。又學多樣嘢。

學黃子華話齋,唔搵錢嗰啲,係技能定無能呢? 

https://developers.hp.com/sites/default/files/hplip-3.18.12-plugin.run
https://developers.hp.com/sites/default/files/hplip-3.18.12-plugin.run.asc

Thursday, January 02, 2020

Synology DSM DS Photo 中討厭的 thumbnails 與 rsync

新年放假,又係時間 backup 下啲相。我啲相分別抄一份去 NAS 入邊一個 HDD,仲會抄多個 copy 去一個 offline HDD。

一直都相安無事。但話說今早行 rsync 嗰時,發覺佢不斷抄緊啲 '@eaDir',其實佢應該係 DS Photo 入邊啲 thumbnails。由於有勁多相片,thumbnails 數量亦不少,容量事少,耗時事大。所以我就諗方法 rsync 嗰時同時 exclude 嗰啲無用o既資料唔抄過去。

首先,我地可以用呢句去找出所有 '@eaDir' move 去另一個地方,確定無用就可以 delete:

find /volumeUSB1/usbshare/photo/ -type d -name "@eaDir" -exec mv {} /mnt/cache/destination

or

find /volumeUSB2/usbshare/photo/ -type d -name "@eaDir" -print0 | xargs -0 rm -rf


然後做 rsync 嗰時,我地就可以行:

rsync -avr --progress --stats --exclude '*@SynoResource' --exclude '@eaDir'
 --exclude '*.vsmeta' --exclude '.DS_Store' /volume1/photo/ /volumeUSB2/usbshare/photo/
 
 
又學到嘢了。 

Tuesday, May 28, 2019

Synology DSM 救 data (xpenology/黑群)

話說自己衰多手走去 upgrade 去 DSM 6.2.2。jun's loader 1.03b 原本係無問題,理論上係上到 DSM6.2.2,起碼有人係用 ESXi 係行到o既。但如果你諗住喺 HP Gen8 Microserver baremetal 咁裝呢,唔好意思,as of today,實測佢只係 support 到 DSM6.2,最多俾你裝埋update 2 都無事。

如果你多手 upgrade 去 DSM6.2.1 or DSM6.2.2。咁你成功 upgrade 完之後,恭喜你,你部 xpenlogy DSM 係會喺你個 network 度消失。估計原因係佢 upgrade 咗之後,會改埋個 loader 入邊一啲 setting,導致到認唔會 native onboard 嗰兩個 NIC,即係上唔到網。。。聽聞話自己裝張 Intel o既 network card 就可以避開呢個 bug,小弟未有實測,但可能會試,睇下 ebay 搵唔搵到張平卡。

呢個 5/27 o既 long weekend  就只喺在救 server。。。呢次都唔算好大鑊,只係好煩。因為自己又進而衰多手 wipe 咗個 system partition,就算俾你插翻入去 NAS 都唔可能即刻認到 data partition。但起碼我知係無炒到o既,只係要花時間。真係遇難題又令自己進步。

https://michaelheap.com/mount-synology-hdd-linux

嗱,以防個網址有日瓜咗,小弟再 repeat 一次同加少少自己o既解釋。情況係咁o既,你 DSM 個 data partition,就算俾你用 ubuntu boot 起求其一部機然後諗住用嗰 USB dock 去撈 data,係唔得的。因為佢係 set 咗做 RAID,而佢即係行緊 ext4 都唔可以直 read。你係要用 mdadm 去 mount 起個 RAID volume 先,然後先可以用 mount 嚟 mount 成 ext4 先抄得翻啲 data 出嚟。

$ sudo mount /dev/sdb2 /volume1/test
mount: /media/test: unknown filesystem type 'linux_raid_member'. 
你會見到佢鬧咩'linux raid member',即係我先前講唔可以直 mount。

$ sudo mdadm --assemble --run /dev/md0 /dev/sdb2
mdadm: /dev/sdb2 is busy - skipping

嗱,呢個就係話你聽其實已經 mdadm 咗。

ls /dev/md

呢個就係睇下 md 咗咩鬼嘢。

$ sudo mdadm --stop /dev/md127
$ sudo mdadm --assemble --run /dev/md0 /dev/sdb2
 

$ sudo mount -t ext4 /dev/md0 /volume1/test

搞完呢一大輪嘢你就可以 copy 翻啲  data 出嚟。起碼無 data loss,只係人生無咗啲時間。如果個 HDD 唔係行  ext4 而係行 btrfs,咁我都唔知可以點救,因為我暫時未親身實證 linux 可以 mount 得起。

Tuesday, March 06, 2018

exfat support in DSM

Install exFAT support package (tested with XPEnobot 5.2 DS3615x, Jun's loader v1.01 DSM 6.0.2 DS3615x):
1. Enabled root user via ssh:
sudo su -
synouser --setpw root your_new_root_password
2. Login as root user via ssh:
ssh root@nas_ip_address
3. Download and install the exfat-fuse package as the following code:
It seems DSM 5.0 is 32bit linux, and DSM 6.0 is 64bit version, please download different packages.
DSM 5.0
wget -P /tmp/ http://mirrors.kernel.org/ubuntu/pool/universe/f/fuse-exfat/exfat-fuse_1.2.3-1_i386.deb
dpkg -x /tmp/exfat-fuse_1.2.3-1_i386.deb /tmp/exfat-fuse/
cp /tmp/exfat-fuse/sbin/mount.exfat-fuse /usr/bin/
DSM 6.0
wget -P /tmp/ http://mirrors.kernel.org/ubuntu/pool/universe/f/fuse-exfat/exfat-fuse_1.2.3-1_amd64.deb
dpkg -x /tmp/exfat-fuse_1.2.3-1_amd64.deb /tmp/exfat-fuse/
cp /tmp/exfat-fuse/sbin/mount.exfat-fuse /usr/bin/
4. Create a Shared Folder in Control Panal, e.g. usbexfat in Volume1
5. Plug the usb device with exFAT format, and in ssh:
fdisk -l
find out the exFAT device like this:
DSM 5.0
Device     Boot Start     End Sectors  Size Id Type
/dev/sdu1         256 7823654 7823399  3.7G  7 HPFS/NTFS
DSM 6.0
Device     Boot Start     End Sectors  Size Id Type
/dev/sdu1         256 7823654 7823399  3.7G  7 HPFS/NTFS/exFAT
6. Mount the exFAT partition:
mount.exfat-fuse /dev/sdu1 /volume1/usbexfat -o nonempty
7. Then can read & write the exFAT partition in Shared Folder usbexfat.
8. Unmount the exFAT partition:
umount /volume1/usbexfat
9. Eject the usb device in Control Panel or ssh:
eject -F /dev/sdu1

Thursday, November 30, 2017

rsync backup 補完

因為 cp 或者 mv 無進度顯示,所以都唔知佢究竟抄咗咩 file 同抄到咩樣,所以又用翻 rsync,但一般 rsync 都係 show 下抄緊咩 file,原來佢仲有 argument 可以 show 埋個進度。

rsync -av --progress --stats /volume2/video /volume4/

--progress 就會 show 個進度,仲有速度睇。
--stats 最後會有個 statistics show 翻俾你睇。

起初以為 rsync 會慢過 cp,但睇翻個速度其實有 8xMB/s to 9xMB/s 都算對版。

用翻 rsync o既原因係 cp有時真係會有嘢抄漏咗,係唔知咩原因導致電腦佢 skip 一啲 folders 或者 files。

Sunday, September 21, 2014

rsync for backup

rsync -avrtzu /cygdrive/d/CCNA 192.168.2.6::backup 

說明:將本機(WinXp)D:\CCNA資料夾內的資料全部上傳到Win2008Server上的backup標籤內。
/cygdrive/c--代表C槽
/cygdrive/d--代表D槽。依此類推

*執行的時候發現找不到指令,請到環境變數內Path 將 C:\Program Files (x86)\cwRsync\bin 加入

有關rsync指令說明如下:
-a, --archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose  increase verbosity
-r, --recursive  recurse into directories
-t, --times  preserve modification times
-z, --compress  compress file data during the transfer
-u, --update  skip files that are newer on the receiver

Wednesday, April 23, 2014

Changing default photo directory of Photo Station in Synology

to mount the folder use the following command:
mount -o bind /volume2/ePhoto2T /volume1/photo

After you have checked and tested, you can add this to the startup. Type:
vi /etc/rc.local
(My rc.local didn't exist, but vi creates it anyway)

Press a to edit and add the same line again (a on mac)
mount -o bind /volume2/ePhoto2T /volume1/photo

Sunday, November 11, 2012

Remember SAMBA password under Windows 7

"Control Panel\User Accounts and Family Safety\Credential Manager"

1) First I selected the link that reads: "Add A Windows Credential". This link brings you to a page with 3 form fields. "Right-clicking" in the "Internet or Network Address" form-field I then "Pasted" the address that I had copied previously. I then finished this step by typing the "User name" and "Password" that I use to access my network drive into their respective form fields and then clicking the "OK" button.

2) Secondly, I selected the link that reads: "Add A Generic Credential". This link takes you to a similar form as before, and therefore repeat the same process as in step 1.

Monday, July 09, 2012

OpenWRT and PPTP VPN


opkg update
opkg install pptpd
opkg install kmod-mppe

edit /etc/ppp/options.pptpd
====================
speed 115200
stimeout 10
localip 192.168.1.1
remoteip 192.168.1.200-230
====================


edit /etc/pptpd.conf
====================

lock
debug
name vpn1 #control the usrs allowed
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe
#require-mppe-128
ms-dns 192.168.1.1
proxyarp

====================



edit /etc/ppp.chap-secrets
for login and pw

/etc/config/firewall
======================

#modify
config 'defaults'
option 'syn_flood' '1'
option 'input' 'ACCEPT'
option 'output' 'ACCEPT'
option 'drop_invalid' '1'
option 'forward' 'ACCEPT'


config 'zone'
option 'name' 'wan'
option 'network' 'wan'
option 'input' 'ACCEPT'
option 'output' 'ACCEPT'
option 'forward' 'REJECT'
option 'masq' '1'
option 'mtu_fix' '1'

#add

config 'rule'
option '_name' 'pptpvpn'
option 'src' 'wan'
option 'proto' 'tcpudp'
option 'dest_port' '1723'
option 'target' 'ACCEPT'


======================

/etc/init.d/pptpd start
/etc/init.d/pptpd stop
/etc/init.d/pptpd restart
killall pptp