Banana Pi 測試 – Gentoo Linux 更新系統

同步套件資訊
# emerge –sync

檢查需要更新的套件
[ebuild   R    ]:代表已安裝
[ebuild  N     ]:尚未安裝
[ebuild     U  ] :可以升級的套件
# emerge -pv world

These are the packages that would be merged, in order:

Calculating dependencies… done!
[ebuild   R    ] app-arch/xz-utils-5.0.5-r1  USE=”nls threads -static-libs” 1,276 kB
[ebuild   R    ] app-arch/bzip2-1.0.6-r6  USE=”-static -static-libs” 764 kB
[ebuild   R    ] sys-devel/gnuconfig-20140212  44 kB
[ebuild   R    ] sys-apps/which-2.20-r1  133 kB
[ebuild   R    ] sys-apps/baselayout-2.2  USE=”-build” 40 kB
[ebuild   R    ] sys-devel/patch-2.6.1  USE=”-static {-test}” 248 kB
[ebuild   R    ] virtual/os-headers-0  0 kB
[ebuild     U  ] sys-apps/file-5.21 [5.19] USE=”zlib -python -static-libs” PYTHON_TARGETS=”python2_7 python3_3 -python3_4 (-python3_2%)” 715 kB
[ebuild   R    ] sys-apps/net-tools-1.60_p20130513023548  USE=”nls -old-output (-selinux) -static” 196 kB
[ebuild   R    ] sys-apps/coreutils-8.21  USE=”acl nls -caps -gmp (-selinux) -static -vanilla -xattr” 5,281 kB
[ebuild   R    ] virtual/modutils-0  0 kB
[ebuild   R    ] virtual/libc-0  0 kB
[ebuild   R    ] app-shells/bash-4.2_p53  USE=”net nls (readline) (-afs) -bashlogger -examples -mem-scramble -plugins -vanilla” 6,977 kB
[ebuild   R    ] sys-apps/less-458  USE=”pcre unicode” 500 kB
[ebuild   R    ] sys-apps/sed-4.2.1-r1  USE=”acl nls (-selinux) -static” 879 kB
[ebuild   R    ] virtual/man-0-r1  0 kB
[ebuild   R    ] sys-devel/binutils-2.24-r3  USE=”cxx nls zlib (-multislot) -multitarget -static-libs {-test} -vanilla” 22,202 kB
[ebuild     U  ] sys-process/psmisc-22.21 [22.20] USE=”ipv6 nls -X (-selinux)” 442 kB
[ebuild   R    ] sys-apps/gawk-4.0.2  USE=”nls readline” 1,589 kB
[ebuild   R    ] app-arch/tar-1.27.1-r2  USE=”acl nls -minimal (-selinux) -static -xattr” 2,513 kB
[ebuild   R    ] sys-devel/make-4.0-r1  USE=”nls -guile -static” 1,311 kB
[ebuild   R    ] sys-apps/findutils-4.4.2-r1  USE=”nls (-selinux) -static” 2,100 kB
[ebuild   R    ] app-arch/gzip-1.5  USE=”nls -pic -static” 705 kB
[ebuild   R    ] virtual/pager-0  0 kB
[ebuild   R    ] sys-apps/diffutils-3.3  USE=”nls -static” 1,170 kB
[ebuild   R    ] sys-apps/mlocate-0.26-r1  USE=”nls (-selinux)” 0 kB
[ebuild   R    ] sys-devel/gcc-4.8.3:4.8  USE=”cxx fortran nls nptl openmp (-altivec) -awt -doc (-fixed-point) -gcj -go -graphite (-hardened) (-libssp) -mudflap (-multilib) (-multislot) -nopie -nossp -objc -objc++ -objc-gc -regression-test (-sanitize) -vanilla” 84,146 kB
[ebuild   R    ] sys-apps/man-pages-3.72  USE=”nls” LINGUAS=”-da -de -fr -it -ja -nl -pl -ro -ru -zh_CN” 1,251 kB
[ebuild  N     ] dev-libs/libevent-2.0.21-r1  USE=”ssl threads -static-libs {-test}” 831 kB
[ebuild   R    ] sys-apps/busybox-1.21.0  USE=”ipv6 pam static -livecd -make-symlinks -math -mdev -savedconfig (-selinux) -sep-usr -syslog -systemd” 2,150 kB
[ebuild   R    ] sys-apps/kbd-1.15.5-r1  USE=”nls pam” 1,691 kB
[ebuild   R    ] virtual/shadow-0  0 kB
[ebuild     U  ] net-misc/iputils-20121221-r1 [20121221] USE=”filecaps%* ipv6 ssl -SECURITY_HAZARD -caps -doc -gnutls -idn -static” 175 kB
[ebuild   R    ] virtual/ssh-0  USE=”-minimal” 0 kB
[ebuild   R    ] virtual/package-manager-0  0 kB
[ebuild   R    ] app-editors/vim-7.4.273  USE=”acl nls -X -cscope -debug -gpm -lua (-luajit) -minimal -perl -python (-racket) -ruby (-selinux) -tcl -vim-pager” PYTHON_SINGLE_TARGET=”python2_7 -python3_3 -python3_4″ PYTHON_TARGETS=”python2_7 python3_3 -python3_4″ 10,108 kB
[ebuild   R    ] virtual/editor-0  0 kB
[ebuild   R    ] net-dns/bind-tools-9.9.5  USE=”ipv6 readline ssl -doc -gost -gssapi -idn -urandom -xml” 0 kB
[ebuild   R    ] app-admin/sudo-1.8.11_p1  USE=”nls pam sendmail -ldap -offensive (-selinux) -skey” 2,346 kB
[ebuild   R    ] sys-apps/util-linux-2.24.1-r3  USE=”cramfs ncurses nls pam suid unicode -bash-completion -caps -cytune -fdformat -python (-selinux) -slang -static-libs {-test} -tty-helpers -udev” PYTHON_SINGLE_TARGET=”python2_7 -python3_3 -python3_4 (-python3_2%)” PYTHON_TARGETS=”python2_7 python3_3 -python3_4 (-python3_2%)” 3,461 kB
[ebuild   R    ] net-misc/rsync-3.0.9-r3  USE=”acl iconv ipv6 -static -xattr” 775 kB
[ebuild   R    ] sys-apps/grep-2.16  USE=”nls pcre -static” 1,182 kB
[ebuild   R    ] sys-process/procps-3.3.9  USE=”ncurses nls unicode -static-libs {-test}” 548 kB
[ebuild     U  ] net-misc/wget-1.16 [1.14] USE=”ipv6 nls pcre ssl zlib -debug -gnutls -idn -ntlm -static {-test%} -uuid” 1,658 kB
[ebuild     U  ] net-misc/ntp-4.2.8-r1 [4.2.6_p5-r10] USE=”ipv6 ssl -caps -debug -openntpd (-parse-clocks) -samba (-selinux) -snmp -vim-syntax -zeroconf” 6,638 kB
[ebuild   R    ] sys-process/vixie-cron-4.1-r14  USE=”pam -debug (-selinux)” 0 kB
[ebuild   R    ] sys-fs/e2fsprogs-1.42.10  USE=”nls -static-libs” 5,983 kB
[ebuild   R    ] sys-apps/openrc-0.12.4  USE=”ncurses netifrc pam unicode -debug -newnet (-prefix) (-selinux) -static-libs -tools” 129 kB
[ebuild   R    ] virtual/service-manager-0  USE=”(-prefix)” 0 kB
[ebuild   R    ] virtual/dev-manager-0  0 kB

Total: 50 packages (5 upgrades, 1 new, 44 reinstalls), Size of downloads: 172,141 kB[@more@]上面的資訊實在太複雜了,稍微精簡一下
# emerge -pv world | grep ‘[ebuild     U  ]’ | awk ‘{print $4}’
sys-apps/file-5.21
sys-process/psmisc-22.21
net-misc/iputils-20121221-r1
net-misc/wget-1.16
net-misc/ntp-4.2.8-r1

更新個別套件,以 wget 為例
系統安裝版本 1.14,新的版本是 1.16
# emerge -pv wget

These are the packages that would be merged, in order:

Calculating dependencies… done!
[ebuild     U  ] net-misc/wget-1.16 [1.14] USE=”ipv6 nls pcre ssl zlib -debug -gnutls -idn -ntlm -static {-test%} -uuid” 1,658 kB

Total: 1 package (1 upgrade), Size of downloads: 1,658 kB

進行更新
# emerge -u wget

更新整個系統
# emerge -u world

Banana Pi – Gentoo Linux 套件管理

Portage 是 Gentoo Linux 在套件管理的特色,感覺很像 BSD 中的 Ports Tree,透過 Portage 可以讓 Gentoo Linux 使用者可以取得套件名稱。 Portage 是指 ebuilds 的集合,檔案中包含 Portage 維護軟體所需的資訊(安裝,搜尋,查詢,…)。這些 ebuilds 預設存放在 /usr/portage 目錄之中,因此定期更新系統上的 ebuilds 是非常重要的。

emerge 是 Portage 的一個文字介面前端的管理式。
[@more@]
1. 同步套件庫  –sync
# emerge –sync

2. 搜尋套件 –search
# emerge –search bind-tools
# emerge -s bind-tools
Searching…
[ Results for search key : bind-tools ]
[ Applications found : 1 ]

*  net-dns/bind-tools
      Latest version available: 9.9.5
      Latest version installed: [ Not Installed ]
      Size of files: 7,548 kB
      Homepage:      http://www.isc.org/software/bind
      Description:   bind tools: dig, nslookup, host, nsupdate, dnssec-keygen
      License:       ISC BSD BSD-2 HPND JNIC RSA openssl

3. 搜尋描述的內容  –searchdesc
# emerge –searchdesc firefox
# emerge -S firefox
Searching…
[ Results for search key : firefox ]
[ Applications found : 3 ]

*  www-client/firefox
      Latest version available: 24.3.0
      Latest version installed: [ Not Installed ]
      Size of files: 116,599 kB
      Homepage:      http://www.mozilla.com/firefox
      Description:   Firefox Web Browser
      License:       MPL-2.0 GPL-2 LGPL-2.1

*  www-client/firefox-bin [ Masked ]
      Latest version available: 34.0.5
      Latest version installed: [ Not Installed ]
      Size of files: 0 kB
      Homepage:      http://www.mozilla.com/firefox
      Description:   Firefox Web Browser
      License:       MPL-2.0 GPL-2 LGPL-2.1

*  www-client/vimprobable2 [ Masked ]
      Latest version available: 9999
      Latest version installed: [ Not Installed ]
      Size of files: 0 kB
      Homepage:      http://www.vimprobable.org/
      Description:   A minimal web browser that behaves like the Vimperator plugin for Firefox
      License:       MIT

Calculating dependencies… done!

4. 安裝套件
# emerge bind-tools

安裝套件時指定編譯的參數
# USE=’sasl’ emerge postfix

# export USE=’sasl’
# emerge postfix

# emerge -k bind-tools
>>> Verifying ebuild manifests

>>> Emerging (1 of 1) net-dns/bind-tools-9.9.5
>>> Downloading ‘http://distfiles.gentoo.org/distfiles/bind-9.9.5.tar.gz’
–2014-12-30 20:46:22–  http://distfiles.gentoo.org/distfiles/bind-9.9.5.tar.gz
Resolving distfiles.gentoo.org… 64.50.233.100, 64.50.236.52, 137.226.34.42, …
Connecting to distfiles.gentoo.org|64.50.233.100|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 7729695 (7.4M) [application/x-gzip]
Saving to: ‘/usr/portage/distfiles/bind-9.9.5.tar.gz’

100%[======================================>] 7,729,695   1.89MB/s   in 3.9s

2014-12-30 20:46:27 (1.89 MB/s) – ‘/usr/portage/distfiles/bind-9.9.5.tar.gz’ saved [7729695/7729695]
中略……..
   usr/bin/dig
   usr/bin/host
   usr/bin/nslookup
   usr/bin/nsupdate
   usr/bin/dnssec-keygen
ecompressdir: bzip2 -9 /usr/share/doc
ecompressdir: bzip2 -9 /usr/share/man

>>> Installing (1 of 1) net-dns/bind-tools-9.9.5

>>> Recording net-dns/bind-tools in “world” favorites file…
>>> Auto-cleaning packages…

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

5. 檢查套件相依性 –pretend
# emerge –pretend vixie-cron
# emerge -p vixie-cron
# emerge -pv vixie-cron

These are the packages that would be merged, in order:

Calculating dependencies… done!
[ebuild  N     ] sys-process/cronbase-0.3.3
[ebuild  N     ] sys-process/vixie-cron-4.1-r14  USE=”pam -debug (-selinux)”

6. 移除套件 –unmerge
# emerge –unmerge wget
# emerge -C wget

7. 檢查系統需要更新的件
# emerge -pv world

8. 更新套件 –update
# emerge –update wget
# emerge -u wget

在部分套件升級完畢,需要執行 etc-update 才能正常使用。執行 etc-update 之後出現的選項:
-1:不使用新的設定檔取代舊的設定檔
-3 :使用新的設定檔取代舊的設定檔(會詢問)
-5 :使用新的設定檔取代舊的設定檔(不會詢問)

10. 更新整個系統
# emerge –update world
# emerge -u world

Banana Pi 測試 – Gentoo Linux 網路設定

Banana Pi 上預設 Gentoo Linux 是採用 DHCP 自動取得 IP
# cat /etc/conf.d/net
#For DHCP
config_eth0=”dhcp”
dns_domain_lo=”lemaker”
nis_domain_lo=”lemaker”

固定 IP 的設定方式
[@more@]參考網頁:
Gentoo Forums :: 觀看文章 – Switching to a static IP (within your network)

1. 先備份原檔
# cp /etc/conf.d/net /etc/conf.d/net.$(date +%F)

2. 修改設定檔 /etc/conf.d/net
# vim /etc/conf.d/net
#For Static IP
config_eth0=( “192.168.1.44 netmask 255.255.255.0” )
routes_eth0=( “default gw 192.168.1.254” )
dns_servers_eth0=( “168.95.1.1 140.111.66.1” )

3. 重新開機或啟動網路
# /etc/init.d/net.eth0 restart

以 Xshell 進行 SSH 連線

1. 執行桌面上的 Xshell 5 圖示

2.   如果有使用過之前的版本,可以選擇匯入之前的記錄
[@more@]
3.  Xshell 執行畫面
3.

4.  選擇 工作階段的 新增

5.  輸入要連線的主機資訊,並按 確定

6. 選好要連線的主機,並按 連線

7. 選擇 接受及存檔(S) 金鑰

8.  輸入帳號,並按 確定

9.  輸入密碼,並按 確定

10.  已經登入成功!

比較特別的是,Xshell 是以類似標籤的方式,來區隔每一個連線,連線數量大時,會比較不佔工作列空間,切換也比較方便!
更多的 Xshell 特色,請參考:http://www.netsarang.com/products/xsh_screenshot.html
下圖取自官網

Xshell 可以在家裡及學校免費使用的 SSH Client

Xshell 是由 NetSarang 公司所開發的軟體,可以支援 SSH, SFTP, TELNET, RLOGIN and SERIAL 等連線,功能非常強大,個人在家裡及學校可以免費使用。

NetSarang Xshell 官方網站:
http://www.netsarang.com/products/xsh_overview.html
NetSarang Xshell 下載網頁:
http://www.netsarang.com/download/down_xsh.html

要下載之前,請先到下載網頁填入一些個人資料,網站會寄一封軟體下載點的 mail,提供下載。

[@more@]1. 按 mail 中的下載連結來下載 Xshell

2. 在下載下來的程式按二下,開始安裝

3.  選擇 執行

4.  安裝畫面

5.  選擇 下一步

6. 選擇 免費為家庭/學校選擇 下一步

7. 選擇 我接受授權合約的條款(A),然後選擇 下一步

8. 軟體安裝位置,選擇 下一步

9. 選擇 下一步

10. 選擇 安裝

11.  安裝過程

12. 選擇 完成

13. 桌面上會出現一個 Xshell 5 的圖示

Arch Linux- 提示可以更新的套件

列出可以更新的套件
# pacman -Quq                                                   
dbus
libdbus
linux-firmware
linux-sun7i
openresolv
uboot-cubieboard2[@more@]改採信件通知管理者
# vim /usr/local/bin/check-update
#!/bin/bash
/usr/bin/pacman -Quq  > /tmp/$(date +%F)
if [ -s /tmp/$(date +%F) ] ;then
   /usr/bin/mail -s “Arch Linux Updates Available” xxxx@gmail.com < /tmp/$(date +%F)
   rm -rf /tmp/$(date +%F)
else
   rm -rf /tmp/$(date +%F)
fi

更改檔案執行權限
# chmod 700 /usr/local/bin/check-update

加入到 crontab
# crontab -l
0 0,12 * * * /usr/bin/pacman -Syy > /dev/null 2>&1
0 1,13 * * * /usr/local/bin/check-update

清除佇列 Queue 中的信件

# mailq
-Queue ID- –Size– —-Arrival Time—- -Sender/Recipient——-
B1C9B217921A*     458 Sun Jan 25 01:17:14  root@PC111.test.ilc.edu.tw
                                         tester@gmail.com

C1BC72179219*   98915 Sun Jan 25 01:06:44  root@PC111.test.ilc.edu.tw
                                         tester@gmail.com

— 97 Kbytes in 2 Requests.

有二封寄不出的信

查看一下紀錄
# grep C1BC72179219 /var/log/maillog
Jan 25 01:06:44 PC111 postfix/cleanup[31640]: C1BC72179219: message-id=<20150124170644.ABA122018DD0@PC111.test.ilc.edu.tw>
Jan 25 01:06:44 PC111 postfix/qmgr[30282]: C1BC72179219: from=<root@PC111.test.ilc.edu.tw>, size=98915, nrcpt=1 (queue active)

清除佇列 queue
# postsuper -d ALL
postsuper: Deleted: 2 messages

CentOS 7 – 使用 Google Mail 來寄信

1. 先停止 postfix 服務
# systemctl stop postfix
# systemctl disable postfix
rm ‘/etc/systemd/system/multi-user.target.wants/postfix.service'[@more@]2. 安裝 ssmtp 套件
# yum install ssmtp –enablerepo=epel

3. 備份原設定檔 /etc/ssmtp/ssmtp.conf
# cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.$(date +%F)

4. 修改設定檔

CentOS 7 – 提示可以更新的套件

1. 可以使用 yum info updates 指令來查詢可以可升級的套件
# yum info updates | grep Name | awk ‘{print $3}’
jasper-libs
或是
[@more@]2. 使用 yum-cron
# yum install yum-cron

3. 修改設定檔
# vim /etc/yum/yum-cron.conf
# Whether a message should be emitted when updates are available,
# were downloaded, or applied.
update_messages = yes

# Whether updates should be downloaded when they are available.
download_updates = no

# Whether updates should be applied when they are available.  Note
# that download_updates must also be yes for the update to be applied.
apply_updates = no

4. 啟動 yum-cron 服務
# systemctl start yum-cron

5. 設定開機時啟動 yum-cron 服務
# systemctl enable yum-cron