HanG321 Blog
Be Shine, Be Smile, Be Wild
  • Home
  • Blog
    • 好文閱讀 readings
    • 生活記事 diary
    • 時事評論 commentary
    • 科技資訊 technology
    • 電腦編程 programming
    • 金融財經 finance
    • 音樂電影 music/movie
  • About
Debian Chroot on DSM

Debian Chroot on DSM

August 16, 2014|chroot, Debian, DSM, XPEnology|科技資訊

Use Debian chroot instead of ipkg (optware) on DSM 5.0. Here is a installation notes of XPEnology on HP N36L

Prerequisite:

add custom source:  Package Centre > Settings > Package Sources

Name: SynoCommunity
Location:  https://synocommunity.com/packages 

Readme:

https://github.com/SynoCommunity/spksrc/blob/develop/spk/debian-chroot/src/app/help/enu/index.html

Installation:

– required python on SynoCommunity, DSM default python not OK.

– select Debian Chroot and click install

– after installation completed, ssh to DSM as root

Shell
1
2
3
root@diskstation> /var/packages/debian-chroot/scripts/start-stop-status chroot
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
root@diskstation:/#

– now under chroot

Shell
1
2
3
4
5
6
7
8
9
##backup and update source list. e.g. from France to Australia
##see https://www.debian.org/mirror/list
sed -i.`date +%Y%m%d` 's/fr.debian.org/au.debian.org/g' /etc/apt/sources.list
aptitude update
aptitude upgrade
aptitude install locales
dpkg-reconfigure locales
dpkg-reconfigure tzdata
aptitude install less vim curl rsync screen openssh-server

– enable home for users: Control Panel > User > Advance, “Enable user home services”, Apply.
ls -al /var/services/homes  symbolic link updated and pointed correctly

– some additional directories want to be mount by startup script

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# diff -u /var/packages/debian-chroot/scripts/start-stop-status
--- start-stop-status.org
+++ start-stop-status
@@ -20,6 +20,16 @@
         grep -q "${CHROOTTARGET}/dev " /proc/mounts || mount -o bind /dev ${CHROOTTARGET}/dev
         grep -q "${CHROOTTARGET}/dev/pts " /proc/mounts || mount -o bind /dev/pts ${CHROOTTARGET}/dev/pts
 
+        grep -q "${CHROOTTARGET}/home " `realpath /var/services/homes` || mount -o bind `realpath /var/services/homes` ${CHROOTTARGET}/home
+
+        [ ! -d ${CHROOTTARGET}/volume2 ] && mkdir -p ${CHROOTTARGET}/volume2
+        grep -q "${CHROOTTARGET}/volume2 " /volume2 || mount -o bind /volume2 ${CHROOTTARGET}/volume2
+
         # Start all services
         ${INSTALL_DIR}/app/start.py
     fi
@@ -35,6 +45,11 @@
     umount ${CHROOTTARGET}/dev
     umount ${CHROOTTARGET}/sys
     umount ${CHROOTTARGET}/proc
+
+    umount ${CHROOTTARGET}/home
+    umount ${CHROOTTARGET}/volume2
}
 
daemon_status ()

– setup users on debian domain

Shell
1
2
3
4
5
6
## find user id
id -u username
id -g username
 
## Debian domain. XXXX YYYY is the id value
adduser username -uid XXXX --gid YYYY --home /home/username

– change Port form 22 to 2222, so Synology still using default port 22, Debian domain will use 2222 port

Shell
1
2
cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config.`date +%Y%m%d`
vim /etc/ssh/sshd_config

–  (optional) create share folder via UI, e.g. “bridge”. Later use for packages manually install and share across Debian and Synology (e.g. maven)

Shell
1
2
# on both Debian domain and Synology domain, create symbolic link to both
ln -s /volume2/bridge /usr/local/bridge

– config profile

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#on Debian domain
#file name is unimportant, only required as *.sh. number for ordering only.
vim /etc/profile.d/S20_java.sh
  # copy-and-paste from Synology /etc/profile
  PATH=$PATH:/volume2/@appstore/JavaManager/Java/bin # Synology Java Manager Package
  PATH=$PATH:/volume2/@appstore/JavaManager/Java/jre/bin # Synology Java Manager Package
  JAVA_HOME=/volume2/@appstore/JavaManager/Java/jre # Synology Java Manager Package
  CLASSPATH=.:/volume2/@appstore/JavaManager/Java/jre/lib # Synology Java Manager Package
  LANG=en_US.utf8 # Synology Java Manager Package
  export CLASSPATH PATH JAVA_HOME LANG # Synology Java Manager Package
  #EOF
 
# enable color for ls and PS1
vim /etc/profile.d/S01_allusers.sh
  export LS_OPTIONS='--color=auto'
  eval "`dircolors`"
  alias ls='ls $LS_OPTIONS'
  alias ll='ls $LS_OPTIONS -la'
  alias l='ls $LS_OPTIONS -lA'
 
  if [ "$BASH" ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
    if [ -f ~/.bashrc ]; then
      . ~/.bashrc
    fi
  fi
  #EOF
 
source /etc/profile && source /root/.profile
# verify
java -version

– ~/.profile  , different PS1 for both Synology and Debian ssh login

.profile
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
  . "$HOME/.bashrc"
    fi
fi
 
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
 
if [ ! -r /etc/debian_chroot ]; then
  PS1='\u@\h \W \$ '
fi

– (optional) on Synology domain, edit /etc/profile as well:  PS1='\u@\h \W \$ '

Final

– ssh username@diskstation   for original synology ash shell. Or
– ssh -p 2222 username@diskstation  for debian bash shell

reference
  • https://wiki.debian.org/chroot
  • https://sites.google.com/a/courville.org/courville/home/synology-debian-chroot
  • https://juju.net.nz/michaelh/notes/ds123.html

MySql 中文亂碼 utf8 latin1

August 14, 2014|生活記事, 科技資訊

話說2008 年搬家既時候, 由LifeType upgrade 去WordPress, 因為MySQL database default latin1 既關係, 有很多comment 亂碼. 當時只有文章有backup, comment 已經 dump 左落.sql file, 唔識搞.

最近Google 其他野冇意間見到有關encoding, 終於救返了.

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

e.g. backup.sql 有鬼畫符的文字:è€è±†ä½ åƒåŠ é›»ç®—ç›ƒå‘€????

1. create database / tables, default collation  utf8_generic_ci

2. import data

Shell
1
$ mysql -u user -ppassword < backup.sql

3. export again as latin1

Shell
1
$ mysqldump -u user -ppassword -B dbName --tables plog_articles_comments --default-character-set=latin1 > comments-latin1.sql

4. replace all “latin1” to “utf8”

Shell
1
2
cp  comments-latin1.sql  comments-utf8.sql
sed -i -e "s/latin1/utf8/g" comments-utf8.sql

5. final import back

Shell
1
$ mysql -u user -ppassword --default-character-set=utf8 < comments-utf8.sql

 

 

Captain America | Divergent

Captain America | Divergent

August 11, 2014|生活記事

Captain America: The Winter Solider

好好睇, 唔止CG effect, 成個story line 都係完整. Captain America 始終唔似Iron man, 比較近一般人. 嗯, 原來有第一集, 未睇添.

 

Divergent

睇到有5 factions 坐係個hall 既時候, 第一個反應係想起鹿頂記既神龍教+笑傲江湖五嶽劍派.
之後都係一般劇情, training, fall in love, conspiracy…
4 個test 又有D 似matrix “this is not real” 同inception.
Anyway 都係一部值得睇既movie.

 

...10...14151617...40...

 

如果你喜歡我的文章,請幫忙按 1-10次 LikeButton 化讚為賞,非常感謝!越喜歡當然可以越按越多 😛

搜尋 Search

簡介 Bio

香港人,現居南十字星空下。

為人貪心,科技、生活、財經、散文 皆有興趣,周身刀冇張利。

思想矛盾,喜歡現在work-life balance 既生活又懷念a city never sleep。

 

每月送我一杯咖啡支持我: liker.land/hang321




分類 Categories

  • 好文閱讀
  • 時事評論
  • 未分類
  • 生活記事
  • 科技資訊
  • 金融財經
  • 電腦編程
  • 音樂電影

文章存檔 Archives




熱門文章 Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8) June 8, 2015
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題…. October 28, 2004
  • assembly
    assembly February 11, 2006
  • 新工作
    新工作 January 6, 2009
  • 嫁人要嫁工程師
    嫁人要嫁工程師 April 27, 2006

標籤雲 Tag Cloud

CentOS Character chroot Cluster crash cryptography DD-WRT debug Domino DSM Dual Core DWA email ESXi GCP git google HylaFax IE Java Javascript JRE LikeCoin Linux log LotusScript mint MX MySQL nginx PKI PowerShell Qwiklabs srt telent VMware vpn vSphere WinXP wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

June 2025
M T W T F S S
  « Feb    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

Copyright © 2004-2021 hang321.net. All Rights Reserved