關於debian 8 時間伺服器設定的問題 [論壇 - 新手村]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊

« 1 (2)


回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2010/9/16 14:08
所屬群組:
已註冊使用者
等級: 25
HP : 0 / 619
MP : 274 / 22665
EXP: 76
離線
好吧,我放棄了,我原本只是想要把debian.pool.ntp.org換成這個time.stdtime.gov.tw,
並且要能夠確認 debian 8 gnome\設定值\日期與時刻\"自動調整日期與時刻"有抓到time.stdtime.gov.tw。看樣子只好使用 日期與時刻 不曉得到底對應到哪裡的系統預設值了。

2015/5/9 23:53
----------------
個人網路文字作品集:
MacOSX10.5.8 安裝、設定、使用,個人經驗分享,正體中文版;以Windows思維用Linux,GNOME桌面篇;PDF
http://www.scribd.com/ianian1979
全字庫注音輸入法表格檔2019 (搭配CNS11643中文全字庫規格的Unicode格式傳統注音輸入法對照表)
https://sites.google.com/site/ianho7979/InputMethodTables
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
IanHo 寫到:
好吧,我放棄了,我原本只是想要把debian.pool.ntp.org換成這個time.stdtime.gov.tw,
並且要能夠確認 debian 8 gnome\設定值\日期與時刻\"自動調整日期與時刻"有抓到time.stdtime.gov.tw。看樣子只好使用 日期與時刻 不曉得到底對應到哪裡的系統預設值了。



執行


$ systemctl status systemd-timesyncd



顯示


● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled)
Active: active (running) since Sat 2015-05-09 16:51:22 UTC; 10min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 1962 (systemd-timesyn)
Status: "Using Time Server 120.119.28.1:123 (0.debian.pool.ntp.org)."
CGroup: /system.slice/systemd-timesyncd.service
└─1962 /lib/systemd/systemd-timesyncd



執行


$ type type /lib/systemd/systemd-timesyncd



顯示


/lib/systemd/systemd-timesyncd is /lib/systemd/systemd-timesyncd



執行


$ ldd /lib/systemd/systemd-timesyncd



顯示


linux-gate.so.1 (0xb7777000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb7724000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb757a000)
libresolv.so.2 => /lib/i386-linux-gnu/i686/cmov/libresolv.so.2 (0xb7562000)
libcap.so.2 => /lib/i386-linux-gnu/libcap.so.2 (0xb755c000)
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb7516000)
/lib/ld-linux.so.2 (0xb777a000)
libattr.so.1 => /lib/i386-linux-gnu/libattr.so.1 (0xb7510000)



執行


$ strings /lib/systemd/systemd-timesyncd | grep debian



顯示



0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org




先安裝套件「dpkg-dev」


$ sudo apt-get install dpkg-dev



下載「systemd」的 source package


$ apt-get source systemd



觀看下載了哪些檔


$ ls -1



顯示


systemd-215
systemd_215-17.debian.tar.xz
systemd_215-17.dsc
systemd_215.orig.tar.xz



查詢「0.debian.pool.ntp.org」在哪個檔


$ grep '0.debian.pool.ntp.org' systemd-215 -R



顯示


systemd-215/debian/rules: --with-ntp-servers="0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org" \


2015/5/10 1:08
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2010/9/16 14:08
所屬群組:
已註冊使用者
等級: 25
HP : 0 / 619
MP : 274 / 22665
EXP: 76
離線
嘗試閱讀,以上這一大串的意思是否表示?

debian 8 gnome\設定值\日期與時刻\"自動調整日期與時刻"所對應的
時間伺服器位址, "寫死" 在 /lib/systemd/systemd-timesyncd 這個位元檔內???
那麼在系統安裝預設值的前提下(不裝額外NTP套件),
看樣子還真的沒得改了,time.stdtime.gov.tw 無望了~~~

那麼 debian installer 的 "設置時鐘"的步驟的欄位,還真的是擺好看的,
讓我改心酸的。

2015/5/10 1:21
----------------
個人網路文字作品集:
MacOSX10.5.8 安裝、設定、使用,個人經驗分享,正體中文版;以Windows思維用Linux,GNOME桌面篇;PDF
http://www.scribd.com/ianian1979
全字庫注音輸入法表格檔2019 (搭配CNS11643中文全字庫規格的Unicode格式傳統注音輸入法對照表)
https://sites.google.com/site/ianho7979/InputMethodTables
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
IanHo 寫到:
嘗試閱讀,以上這一大串的意思是否表示?

debian 8 gnome\設定值\日期與時刻\"自動調整日期與時刻"所對應的
時間伺服器位址, "寫死" 在 /lib/systemd/systemd-timesyncd 這個位元檔內???
那麼在系統安裝預設值的前提下(不裝額外NTP套件),
看樣子還真的沒得改了,time.stdtime.gov.tw 無望了~~~

那麼 debian installer 的 "設置時鐘"的步驟的欄位,還真的是擺好看的,
讓我改心酸的。



剛剛上面的測試,是在livecd開機的模式下測試的,基本上應該一樣。

我剛剛重新裝好了 debian 8 gnome

用下面的指令來測試

設定是在「/etc/systemd/timesyncd.conf」這個檔沒錯 。

不過我安裝過程,「設定時鐘」那部份,一下就跳過了,沒讓我手動設定。我在找時間重裝一次看看好了


$ strings /lib/system/systemd-timesyncd | grep timesyncd.conf



顯示


/etc/systemd/timesyncd.conf




然後以下是操作的實務,可以看到設定「/etc/systemd/timesyncd.conf 」的影響。


$ sudo echo 'Servers=time.stdtime.gov.tw' >> /etc/systemd/timesyncd.conf



啟動ntp(這個動作會影響「設定值/日期與時刻/自動調整日期與時刻」的「開」與「關」)


$ sudo timedatectl set-ntp true

# timedatectl set-ntp false # 若要關閉則是這一行



觀看狀態


$ timedatectl



顯示



Local time: 日 2015-05-10 02:05:58 CST
Universal time: 六 2015-05-09 18:05:58 UTC
RTC time: 六 2015-05-09 18:05:58
Time zone: Asia/Taipei (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a



觀看「systemd-timesyncd.service 」的狀態


$ systemctl status systemd-timesyncd



顯示 (注意那一行「Status: "Using Time Server 118.163.81.61:123 (time.stdtime.gov.tw)."」,就可以看到剛剛的設定「/etc/systemd/timesyncd.conf 」是有影響的)


● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled)
Active: active (running) since 日 2015-05-10 01:58:53 CST; 2min 52s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 1794 (systemd-timesyn)
Status: "Using Time Server 118.163.81.61:123 (time.stdtime.gov.tw)."
CGroup: /system.slice/systemd-timesyncd.service
└─1794 /lib/systemd/systemd-timesyncd

5月 10 01:58:58 debian systemd-timesyncd[1794]: Using NTP server 118.163.81...
5月 10 01:58:58 debian systemd-timesyncd[1794]: interval/delta/delay/jitter...
5月 10 02:00:02 debian systemd-timesyncd[1794]: interval/delta/delay/jitter...
Hint: Some lines were ellipsized, use -l to show in full.



若沒有上面的反應

可以執行下面的指令

關閉「systemd-timesyncd.service」


$ sudo systemctl stop systemd-timesyncd



啟動「systemd-timesyncd.service」


$ sudo systemctl start systemd-timesyncd



或是執行下面的指令,重起「systemd-timesyncd.service」


$ sudo systemctl restart systemd-timesyncd




## 更多參考資料

* http://www.freedesktop.org/software/systemd/man/timesyncd.conf.html
* Ubuntu Wiki / Systemd For Upstart Users
* 淺析 Linux 初始化 init 系統,第 1 部分: sysvinit
* 淺析 Linux 初始化 init 系統,第 2 部分: UpStart
* 淺析 Linux 初始化 init 系統,第 3 部分: Systemd


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

另外也可下載「systemd」 的「source package」來看,這個技巧請參考「這篇」的說明

安裝「dpkg-dev」這個套件


$ sudo apt-get install dpkg-dev



下載「systemd」的「source package」並解開


$ apt-get source systemd



查詢「timesyncd.conf」


$ grep timesyncd.conf systemd-215/ -R



顯示



...略...

systemd-215/src/timesync/timesyncd.conf.in:# See timesyncd.conf(5) for details
systemd-215/src/timesync/timesyncd.c: static const char fn[] = "/etc/systemd/timesyncd.conf";


2015/5/10 2:15
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
IanHo 寫到:
嘗試閱讀,以上這一大串的意思是否表示?

debian 8 gnome\設定值\日期與時刻\"自動調整日期與時刻"所對應的
時間伺服器位址, "寫死" 在 /lib/systemd/systemd-timesyncd 這個位元檔內???
那麼在系統安裝預設值的前提下(不裝額外NTP套件),
看樣子還真的沒得改了,time.stdtime.gov.tw 無望了~~~

那麼 debian installer 的 "設置時鐘"的步驟的欄位,還真的是擺好看的,
讓我改心酸的。



Debian installer「設置時鐘」,那一個流程的原始碼,可以用下面的指令clone下來


git clone git://anonscm.debian.org/d-i/clock-setup.git



主要看幾個檔


$ less clock-setup/debian/clock-setup.postinst
$ less clock-setup/debian/clock-setup.templates # <--這個要了解 debconf
$ less clock-setup/finish-install.d/10clock-setup




上面三個檔,可以在安裝的時候,在下面幾個地方找到

以下是觀看流程,

在安裝的時候,有些流程的右下方,有個「Go Back」按鈕,
按下「Go Back」這個按鈕,就會進到一個安裝流程的選單,
在最下方,有一個「Execute a shell」的選項。
執行後,會跟你確認,
按下「continue」按鈕,就會開啟「ash」。

上面這個流程,在「Install」或「Graphical install」都是一致的。

這時候你就可以執行指令,觀看目前系統的檔案了。

下面三個檔案,可以對照上面的三個檔案


$ more /var/lib/dpkg/info/clock-setup.postinst
$ nano /var/lib/cdebconf/templates.dat # [<ctrl> + w] 輸入「clock-setup」查詢
$ more /usr/lib/finish-install.d/10clock-setup



原始碼初步看起來,應該是安裝的當下設定時鐘,
若是要透過ntp校時,當下允許使用者,設定不同的ntp server來校時。
並沒有把使用者輸入的ntp server,寫到安裝後的系統。
不過我也沒完全看懂程式碼,只有稍微瀏覽一下,還沒了解debconf提供的function,
所以上面只是純屬猜測,
還是要依據程式碼寫的流程為準。

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

另外要研究「debian-installer」。

目前看到有幾個路徑



/var/lib/cdebconf
/var/lib/dpkg
/usr/lib/finish-install.d/
/lib/debian-installer
/lib/debian-installer-startup.d
/lib/debian-installer.d
/usr/share
/cdrom
...



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


「clock-setup/debian/clock-setup.templates」這個檔,
我本來以為會在「/var/lib/dpkg/info/clock-setup.templates」找到,
後來有個靈感,才在「/var/lib/cdebconf/templates.dat」找到。

關於「*.templates」,可以在安裝好後的「deb-based」系統,在「/var/lib/dpkg/info/」可以找到。
可以執行下面的指令,實驗看看。

$ ls /var/lib/dpkg/info/*.templates



可以參考的例子「/var/lib/dpkg/info/phpmyadmin.templates」
當你執行「sudo dpkg-reconfigure phpmyadmin」,
就可以看到一些對話框界面,裡面的文字,可以在「/var/lib/dpkg/info/phpmyadmin.templates」找到。
例如:「Web server to reconfigure automatically」


$ grep 'Web server to reconfigure automatically' /var/lib/dpkg/info/phpmyadmin.templates



會顯示


Description: Web server to reconfigure automatically:



「sudo dpkg-reconfigure phpmyadmin」的討論,可以參考「這篇」和「這篇」。

另外你也可以把「phpmyadmin」這個套件下載,解開來,就可以看到templates檔。
以下是參考步驟,這個技巧紀錄在「這裡


$ apt-get download phpmyadmin
$ dpkg -e phpmyadmin_4%3a4.0.10-1_all.deb
$ tree DEBIAN


就可以看到


DEBIAN
├── conffiles
├── config
├── control
├── md5sums
├── postinst
├── postrm
├── prerm
└── templates

0 directories, 8 files



執行下面的指令,可以對照「/var/lib/dpkg/info/」



$ tree /var/lib/dpkg/info/ -P 'phpmyadmin*'



顯示


/var/lib/dpkg/info/
├── phpmyadmin.conffiles
├── phpmyadmin.config
├── phpmyadmin.list
├── phpmyadmin.md5sums
├── phpmyadmin.postinst
├── phpmyadmin.postrm
├── phpmyadmin.prerm
└── phpmyadmin.templates

0 directories, 8 files




「DEBIAN/templates」對應到「/var/lib/dpkg/info/phpmyadmin.templates」

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

## 下載debian-installer的原始碼

則是可以參考「這一頁」,把debian-installer的原始碼,整個下載下來。

事先安裝幾個RCS套件


$ sudo apt-get install mr subversion git



執行下面的指令,下載debian-installer的原始碼


svn co svn://anonscm.debian.org/svn/d-i/trunk debian-installer
cd debian-installer
scripts/git-setup
mr -p checkout




就會看到「debian-installer/packages/clock-setup」

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

## 更多參考

* Debian Installer internals
* The Debconf Programmer's Tutorial
* Debian Wiki / debconf
* Debian Wiki / DebianInstaller

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

2015/5/11 3:15
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2010/9/16 14:08
所屬群組:
已註冊使用者
等級: 25
HP : 0 / 619
MP : 274 / 22665
EXP: 76
離線
samwhelp真是神人,我引言備查,這資料重要。
看來重點是:
----
原始碼初步看起來,應該是安裝的當下設定時鐘,
若是要透過ntp校時,當下允許使用者,設定不同的ntp server來校時。
並沒有把使用者輸入的ntp server,寫到安裝後的系統。
----
所以 系統安裝當下的 設置時鐘, 跟系統安裝完畢之後的NTP是兩回事了???

然後,若要更改安裝完之後圖形桌面預設值環境既有的NTP,
把 /etc/systemd/timesyncd.conf 裏頭的井字號拿掉,
然後改成:
0.time.stdtime.gov.tw
再去 gnome 設定值 日期與時刻 把 自動調整改為開 就好了???

Debian系統安裝流程的文字語意不是非常完整,
天知道它真的"只有"設定安裝流程之中的NTP而已,
而不會連帶設定到安裝完之後的圖形桌面環境。



samwhelp 寫到:

主要看幾個檔


$ less clock-setup/debian/clock-setup.postinst
$ less clock-setup/debian/clock-setup.templates # <--這個要了解 debconf
$ less clock-setup/finish-install.d/10clock-setup




上面三個檔,可以在安裝的時候,在下面幾個地方找到

以下是觀看流程,

在安裝的時候,有些流程的右下方,有個「Go Back」按鈕,
按下「Go Back」這個按鈕,就會進到一個安裝流程的選單,
在最下方,有一個「Execute a shell」的選項。
執行後,會跟你確認,
按下「continue」按鈕,就會開啟「ash」。

上面這個流程,在「Install」或「Graphical install」都是一致的。

這時候你就可以執行指令,觀看目前系統的檔案了。

下面三個檔案,可以對照上面的三個檔案


$ more /var/lib/dpkg/info/clock-setup.postinst
$ nano /var/lib/cdebconf/templates.dat # [<ctrl> + w] 輸入「clock-setup」查詢
$ more /usr/lib/finish-install.d/10clock-setup



原始碼初步看起來,應該是安裝的當下設定時鐘,
若是要透過ntp校時,當下允許使用者,設定不同的ntp server來校時。
並沒有把使用者輸入的ntp server,寫到安裝後的系統。
不過我也沒完全看懂程式碼,只有稍微瀏覽一下,還沒了解debconf提供的function,
所以上面只是純屬猜測,
還是要依據程式碼寫的流程為準。

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

另外要研究「debian-installer」。

目前看到有幾個路徑



/var/lib/cdebconf
/var/lib/dpkg
/usr/lib/finish-install.d/
/lib/debian-installer
/lib/debian-installer-startup.d
/lib/debian-installer.d
/usr/share
/cdrom
...



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


「clock-setup/debian/clock-setup.templates」這個檔,
我本來以為會在「/var/lib/dpkg/info/clock-setup.templates」找到,
後來有個靈感,才在「/var/lib/cdebconf/templates.dat」找到。

關於「*.templates」,可以在安裝好後的「deb-based」系統,在「/var/lib/dpkg/info/」可以找到。
可以執行下面的指令,實驗看看。

$ ls /var/lib/dpkg/info/*.templates



可以參考的例子「/var/lib/dpkg/info/phpmyadmin.templates」
當你執行「sudo dpkg-reconfigure phpmyadmin」,
就可以看到一些對話框界面,裡面的文字,可以在「/var/lib/dpkg/info/phpmyadmin.templates」找到。
例如:「Web server to reconfigure automatically」


$ grep 'Web server to reconfigure automatically' /var/lib/dpkg/info/phpmyadmin.templates



會顯示


Description: Web server to reconfigure automatically:



「sudo dpkg-reconfigure phpmyadmin」的討論,可以參考「這篇」和「這篇」。

另外你也可以把「phpmyadmin」這個套件下載,解開來,就可以看到templates檔。
以下是參考步驟,這個技巧紀錄在「這裡


$ apt-get download phpmyadmin
$ dpkg -e phpmyadmin_4%3a4.0.10-1_all.deb
$ tree DEBIAN


就可以看到


DEBIAN
├── conffiles
├── config
├── control
├── md5sums
├── postinst
├── postrm
├── prerm
└── templates

0 directories, 8 files



執行下面的指令,可以對照「/var/lib/dpkg/info/」



$ tree /var/lib/dpkg/info/ -P 'phpmyadmin*'



顯示


/var/lib/dpkg/info/
├── phpmyadmin.conffiles
├── phpmyadmin.config
├── phpmyadmin.list
├── phpmyadmin.md5sums
├── phpmyadmin.postinst
├── phpmyadmin.postrm
├── phpmyadmin.prerm
└── phpmyadmin.templates

0 directories, 8 files




「DEBIAN/templates」對應到「/var/lib/dpkg/info/phpmyadmin.templates」

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

## 下載debian-installer的原始碼

則是可以參考「這一頁」,把debian-installer的原始碼,整個下載下來。

事先安裝幾個RCS套件


$ sudo apt-get install mr subversion git



執行下面的指令,下載debian-installer的原始碼


svn co svn://anonscm.debian.org/svn/d-i/trunk debian-installer
cd debian-installer
scripts/git-setup
mr -p checkout




就會看到「debian-installer/packages/clock-setup」

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

## 更多參考

* Debian Installer internals
* The Debconf Programmer's Tutorial
* Debian Wiki / debconf
* Debian Wiki / DebianInstaller

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

2015/5/11 12:02
----------------
個人網路文字作品集:
MacOSX10.5.8 安裝、設定、使用,個人經驗分享,正體中文版;以Windows思維用Linux,GNOME桌面篇;PDF
http://www.scribd.com/ianian1979
全字庫注音輸入法表格檔2019 (搭配CNS11643中文全字庫規格的Unicode格式傳統注音輸入法對照表)
https://sites.google.com/site/ianho7979/InputMethodTables
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
補充一下

「clock-setup.templates」的翻譯檔在「clock-setup/debian/po/zh_TW.po」,您可以參考裡面的內容

剛好最近都在碰套件管理相關的部份,還有對systemd好奇。
也跟我想要了解和探索的議題有關 ,藉由你的問的案例做練習。
所以也要感謝你給我的這個契機去做練習,呵呵...
我認為只要去了解原理,就比較容易找到脈落,去解決摟,
所以我一直把焦點放在去學習一些原理,這探索的過程還蠻有趣的,跟大家一起分享。



IanHo 寫到:
samwhelp真是神人,我引言備查,這資料重要。
看來重點是:
----
原始碼初步看起來,應該是安裝的當下設定時鐘,
若是要透過ntp校時,當下允許使用者,設定不同的ntp server來校時。
並沒有把使用者輸入的ntp server,寫到安裝後的系統。
----
所以 系統安裝當下的 設置時鐘, 跟系統安裝完畢之後的NTP是兩回事了???

然後,若要更改安裝完之後圖形桌面預設值環境既有的NTP,
把 /etc/systemd/timesyncd.conf 裏頭的井字號拿掉,
然後改成:
0.time.stdtime.gov.tw
再去 gnome 設定值 日期與時刻 把 自動調整改為開 就好了???

Debian系統安裝流程的文字語意不是非常完整,
天知道它真的"只有"設定安裝流程之中的NTP而已,
而不會連帶設定到安裝完之後的圖形桌面環境。



samwhelp 寫到:

主要看幾個檔


$ less clock-setup/debian/clock-setup.postinst
$ less clock-setup/debian/clock-setup.templates # <--這個要了解 debconf
$ less clock-setup/finish-install.d/10clock-setup




上面三個檔,可以在安裝的時候,在下面幾個地方找到

以下是觀看流程,

在安裝的時候,有些流程的右下方,有個「Go Back」按鈕,
按下「Go Back」這個按鈕,就會進到一個安裝流程的選單,
在最下方,有一個「Execute a shell」的選項。
執行後,會跟你確認,
按下「continue」按鈕,就會開啟「ash」。

上面這個流程,在「Install」或「Graphical install」都是一致的。

這時候你就可以執行指令,觀看目前系統的檔案了。

下面三個檔案,可以對照上面的三個檔案


$ more /var/lib/dpkg/info/clock-setup.postinst
$ nano /var/lib/cdebconf/templates.dat # [<ctrl> + w] 輸入「clock-setup」查詢
$ more /usr/lib/finish-install.d/10clock-setup



原始碼初步看起來,應該是安裝的當下設定時鐘,
若是要透過ntp校時,當下允許使用者,設定不同的ntp server來校時。
並沒有把使用者輸入的ntp server,寫到安裝後的系統。
不過我也沒完全看懂程式碼,只有稍微瀏覽一下,還沒了解debconf提供的function,
所以上面只是純屬猜測,
還是要依據程式碼寫的流程為準。

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

另外要研究「debian-installer」。

目前看到有幾個路徑



/var/lib/cdebconf
/var/lib/dpkg
/usr/lib/finish-install.d/
/lib/debian-installer
/lib/debian-installer-startup.d
/lib/debian-installer.d
/usr/share
/cdrom
...



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


「clock-setup/debian/clock-setup.templates」這個檔,
我本來以為會在「/var/lib/dpkg/info/clock-setup.templates」找到,
後來有個靈感,才在「/var/lib/cdebconf/templates.dat」找到。

關於「*.templates」,可以在安裝好後的「deb-based」系統,在「/var/lib/dpkg/info/」可以找到。
可以執行下面的指令,實驗看看。

$ ls /var/lib/dpkg/info/*.templates



可以參考的例子「/var/lib/dpkg/info/phpmyadmin.templates」
當你執行「sudo dpkg-reconfigure phpmyadmin」,
就可以看到一些對話框界面,裡面的文字,可以在「/var/lib/dpkg/info/phpmyadmin.templates」找到。
例如:「Web server to reconfigure automatically」


$ grep 'Web server to reconfigure automatically' /var/lib/dpkg/info/phpmyadmin.templates



會顯示


Description: Web server to reconfigure automatically:



「sudo dpkg-reconfigure phpmyadmin」的討論,可以參考「這篇」和「這篇」。

另外你也可以把「phpmyadmin」這個套件下載,解開來,就可以看到templates檔。
以下是參考步驟,這個技巧紀錄在「這裡


$ apt-get download phpmyadmin
$ dpkg -e phpmyadmin_4%3a4.0.10-1_all.deb
$ tree DEBIAN


就可以看到


DEBIAN
├── conffiles
├── config
├── control
├── md5sums
├── postinst
├── postrm
├── prerm
└── templates

0 directories, 8 files



執行下面的指令,可以對照「/var/lib/dpkg/info/」



$ tree /var/lib/dpkg/info/ -P 'phpmyadmin*'



顯示


/var/lib/dpkg/info/
├── phpmyadmin.conffiles
├── phpmyadmin.config
├── phpmyadmin.list
├── phpmyadmin.md5sums
├── phpmyadmin.postinst
├── phpmyadmin.postrm
├── phpmyadmin.prerm
└── phpmyadmin.templates

0 directories, 8 files




「DEBIAN/templates」對應到「/var/lib/dpkg/info/phpmyadmin.templates」

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

## 下載debian-installer的原始碼

則是可以參考「這一頁」,把debian-installer的原始碼,整個下載下來。

事先安裝幾個RCS套件


$ sudo apt-get install mr subversion git



執行下面的指令,下載debian-installer的原始碼


svn co svn://anonscm.debian.org/svn/d-i/trunk debian-installer
cd debian-installer
scripts/git-setup
mr -p checkout




就會看到「debian-installer/packages/clock-setup」

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

## 更多參考

* Debian Installer internals
* The Debconf Programmer's Tutorial
* Debian Wiki / debconf
* Debian Wiki / DebianInstaller

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

2015/5/11 12:23
應用擴展 工具箱
回覆: 關於debian 8 時間伺服器設定的問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
IanHo 寫到:

然後,若要更改安裝完之後圖形桌面預設值環境既有的NTP,
把 /etc/systemd/timesyncd.conf 裏頭的井字號拿掉,
然後改成:
0.time.stdtime.gov.tw
再去 gnome 設定值 日期與時刻 把 自動調整改為開 就好了???



若不用指令的方式(sudo timedatectl set-ntp true),

用GUI來操作的話,從「前面的實驗結果」來看,看起來流程是如此。

另外以下是額外的探索。


## 額外探索

先執行「debian 8 gnome/設定值」這個應用程式。

然後執行下面的指令觀察


$ systemctl status | grep gnome



你就會看到,有類似下面的一行



1984 gnome-control-center --overview




把「「debian 8 gnome/設定值」這個應用程式關掉,執行下面的指令實驗看看。


$ gnome-control-center --overview



就會出現剛剛,在右上角「debian 8 gnome/設定值」執行後,跳出的應用程式。

查詢「gnome-control-center」使用手冊


$ man gnome-control-center



會看到


PANELS

...略...

datetime
The datetime panel lets you set the timezone and time format.

Some operations in this panel affect all user accounts on the
computer and require privieges.

...略...




可以執行下面的指令


$ gnome-control-center datetime



就會出現「debian 8 gnome/設定值/日期與時刻」這個畫面


或是在這個檔「/usr/share/applications/gnome-datetime-panel.desktop 」
也可以看到「gnome-control-center datetime」


$ grep Exec /usr/share/applications/gnome-datetime-panel.desktop



會顯示


Exec=gnome-control-center datetime



基本上,其他的桌面環境「unity」或是「cinnamon」的「控制台」,都是同樣的模式。

「cinnamon」我在「這篇」有紀錄
程式名稱是「cinnamon-settings」,所屬套件是「cinnamon」。

「unity」,則是紀錄在「這篇討論
程式名稱是「unity-control-center」,所屬套件是「unity-control-center」。


## 套件探索

找出「gnome-control-center」放在哪


$ whereis gnome-control-center



會顯示


gnome-control-center: /usr/bin/gnome-control-center /usr/lib/gnome-control-center /usr/share/gnome-control-center /usr/share/man/man1/gnome-control-center.1.gz




查詢「/usr/bin/gnome-control-center」屬於哪個套件


$ dpkg -S /usr/bin/gnome-control-center



會顯示


gnome-control-center: /usr/bin/gnome-control-center



也就是說「/usr/bin/gnome-control-center」是屬於「gnome-control-center」這個套件


下載「gnome-control-center」的「Source Package」


$ apt-get source gnome-control-center




下載完畢後,執行


$ ls -1



會看到一個資料夾「gnome-control-center-3.14.2」和其他三個檔


gnome-control-center-3.14.2
gnome-control-center_3.14.2-3.debian.tar.xz
gnome-control-center_3.14.2-3.dsc
gnome-control-center_3.14.2.orig.tar.xz



你可以執行,下面的指令,觀看有哪些檔


$ tree gnome-control-center-3.14.2




可以看到有一個資料夾「gnome-control-center-3.14.2/panels/datetime/」

觀看「gnome-control-center-3.14.2/panels/datetime/」有哪些檔案。


$ ls gnome-control-center-3.14.2/panels/datetime/ -1



顯示


backward
cc-datetime-panel.c
cc-datetime-panel.h
cc-datetime-resources.c
cc-datetime-resources.h
cc-timezone-map.c
cc-timezone-map.h
data
date-endian.c
date-endian.h
datetime.gresource.xml
datetime.ui
gnome-datetime-panel.desktop.in.in
icons
Makefile.am
Makefile.in
org.gnome.controlcenter.datetime.policy.in
po-timezones
test-endianess.c
test-timezone.c
test-timezone-gfx.c
timedated1-interface.xml
timedated.c
timedated.h
tz.c
tz.h





先探索到這,因為我會的不多,一時也無法看懂程式怎麼實作。
先紀錄下來,給有興趣想要深入探索的人,有個起點。
探索套件的技巧,都「紀錄」在此了
或是參考這個「索引」,有紀錄一些討論案例。




## 暫記

* datetime.ui#network_time_switch
* cc-datetime-panel.c#queue_set_ntp
* timedated.c#timedate1_call_set_ntp
* gdbus-method-org-freedesktop-timedate1.SetNTP
* http://www.freedesktop.org/wiki/Software/systemd/timedated/

參考上面那一頁執行


$ gdbus introspect --system --dest org.freedesktop.timedate1 --object-path /org/freedesktop/timedate1



顯示


interface org.freedesktop.DBus.Peer {
methods:
Ping();
GetMachineId(out s machine_uuid);
signals:
properties:
};
interface org.freedesktop.DBus.Introspectable {
methods:
Introspect(out s data);
signals:
properties:
};
interface org.freedesktop.DBus.Properties {
methods:
Get(in s interface,
in s property,
out v value);
GetAll(in s interface,
out a{sv} properties);
Set(in s interface,
in s property,
in v value);
signals:
PropertiesChanged(s interface,
a{sv} changed_properties,
as invalidated_properties);
properties:
};
interface org.freedesktop.timedate1 {
methods:
SetTime(in x arg_0,
in b arg_1,
in b arg_2);
SetTimezone(in s arg_0,
in b arg_1);
SetLocalRTC(in b arg_0,
in b arg_1,
in b arg_2);
SetNTP(in b arg_0,
in b arg_1);
signals:
properties:
readonly s Timezone = 'Asia/Taipei';
readonly b LocalRTC = false;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b CanNTP = true;
readonly b NTP = true;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b NTPSynchronized = true;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t TimeUSec = 1431330673381613;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t RTCTimeUSec = 1431330673000000;
};
};



* 查詢 dbus-send --session ntp
* Revisiting Systemd D-Bus Interfaces

參考上面那一頁執行


dbus-send --system --print-reply --reply-timeout=2000 --type=method_call --dest=org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.DBus.Introspectable.Introspect



顯示


method return sender=:1.112 -> dest=:1.111 reply_serial=2
string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping"/>
<method name="GetMachineId">
<arg type="s" name="machine_uuid" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="data" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface" direction="in" type="s"/>
<arg name="property" direction="in" type="s"/>
<arg name="value" direction="out" type="v"/>
</method>
<method name="GetAll">
<arg name="interface" direction="in" type="s"/>
<arg name="properties" direction="out" type="a{sv}"/>
</method>
<method name="Set">
<arg name="interface" direction="in" type="s"/>
<arg name="property" direction="in" type="s"/>
<arg name="value" direction="in" type="v"/>
</method>
<signal name="PropertiesChanged">
<arg type="s" name="interface"/>
<arg type="a{sv}" name="changed_properties"/>
<arg type="as" name="invalidated_properties"/>
</signal>
</interface>
<interface name="org.freedesktop.timedate1">
<property name="Timezone" type="s" access="read">
</property>
<property name="LocalRTC" type="b" access="read">
</property>
<property name="CanNTP" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="NTP" type="b" access="read">
</property>
<property name="NTPSynchronized" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="TimeUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<property name="RTCTimeUSec" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>
<method name="SetTime">
<arg type="x" direction="in"/>
<arg type="b" direction="in"/>
<arg type="b" direction="in"/>
</method>
<method name="SetTimezone">
<arg type="s" direction="in"/>
<arg type="b" direction="in"/>
</method>
<method name="SetLocalRTC">
<arg type="b" direction="in"/>
<arg type="b" direction="in"/>
<arg type="b" direction="in"/>
</method>
<method name="SetNTP">
<arg type="b" direction="in"/>
<arg type="b" direction="in"/>
</method>
</interface>
</node>
"




執行



$ dbus-send --system --print-reply --reply-timeout=2000 --type=method_call --dest=org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1.SetNTP boolean:false boolean:true



顯示


method return sender=:1.108 -> dest=:1.107 reply_serial=2



觀看「NTP enabled」的狀態


$ timedatectl



顯示


Local time: 一 2015-05-11 17:18:11 CST
Universal time: 一 2015-05-11 09:18:11 UTC
RTC time: 一 2015-05-11 09:18:11
Time zone: Asia/Taipei (CST, +0800)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a



執行


$ systemctl list-unit-files | grep timedate



顯示


dbus-org.freedesktop.timedate1.service static
systemd-timedated.service static



然後到「/lib/systemd/system/」這個資料夾去找

觀看「/lib/systemd/system/systemd-timedated.service」的檔案內容


$ cat /lib/systemd/system/systemd-timedated.service



顯示


# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Time & Date Service
Documentation=man:systemd-timedated.service(8) man:localtime(5)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/timedated

[Service]
ExecStart=/lib/systemd/systemd-timedated
BusName=org.freedesktop.timedate1
CapabilityBoundingSet=CAP_SYS_TIME
WatchdogSec=1min
PrivateTmp=yes
ProtectSystem=yes
ProtectHome=yes



從上面的「Documentation=http://www.freedesktop.org/wiki/Software/systemd/timedated」看到,可以到這一頁,看文件說明,又回到剛剛的源頭了 :p


$ firefox http://www.freedesktop.org/wiki/Software/systemd/timedated



「SetNTP」的功能說明


Use SetNTP() to control whether the system clock is synchronized with the network using systemd-timesyncd. This will enable/start resp. disable/stop the systemd-timesyncd service.


第二個參數「user_interaction」


The user_interaction boolean parameters can be used to control whether PolicyKit should interactively ask the user for authentication credentials if it needs to.


2015/5/11 14:42
應用擴展 工具箱

« 1 (2)

 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.