請問如何在Client加入開機後自動執行客製的程式/腳本

131 views
Skip to first unread message

LV.Wang

unread,
Apr 20, 2021, 4:10:26 AM4/20/21
to DRBL
請問如何讓自己撰寫的程式或者script加入到client端,
成為開機後的自動執行項目之一?

需要在server端或者client端作何設定和調整?

Steven Shiau

unread,
Apr 20, 2021, 4:17:59 AM4/20/21
to dr...@googlegroups.com
這個部份是說無碟環境的用戶端開機後要自動執行嗎?
還是使用Clonezilla SE備份還原後要處理的script?

Steven

On 4/20/2021 4:03 PM, LV.Wang wrote:
> 請問如何讓自己撰寫的程式或者script加入到client端,
> 成為開機後的自動執行項目之一?
>
> 需要在server端或者client端作何設定和調整?
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/66f48eab-f56c-4ad5-80db-a4a447370d31n%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/66f48eab-f56c-4ad5-80db-a4a447370d31n%40googlegroups.com?utm_medium=email&utm_source=footer>。

--
Steven Shiau <steven _at_ stevenshiau org>
Public Key Server PGP Key ID: 4096R/163E3FB0
Fingerprint: EB1D D5BF 6F88 820B BCF5 356C 8E94 C9CD 163E 3FB0

LV.Wang

unread,
Apr 20, 2021, 4:59:13 AM4/20/21
to DRBL
用戶端為windows環境,當選擇以remote-linux-gra並且auto login的情境,希望在啟動進入remote-linux-gra後,執行script

請問要如何設定?

Steven Shiau 在 2021年4月20日 星期二下午4:17:59 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Apr 20, 2021, 5:05:48 AM4/20/21
to dr...@googlegroups.com
若是系統層面,開機要執行,一般會用rc.local的方式。這可以搭配systemd來做,可以參考:
https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/

基本上無碟端用戶端開機後,照上述的方式去進行應該就可以了。只要你不是DRBL
SSI模式應該可行。

Steven

On 4/20/2021 4:50 PM, LV.Wang wrote:
> 用戶端為windows環境,當選擇以remote-linux-gra並且auto
> login的情境,希望在啟動進入remote-linux-gra後,執行script
>
> 請問要如何設定?
>
> Steven Shiau 在 2021年4月20日 星期二下午4:17:59 [UTC+8] 的信中寫道:
>
> 這個部份是說無碟環境的用戶端開機後要自動執行嗎?
> 還是使用Clonezilla SE備份還原後要處理的script?
>
> Steven
>
> On 4/20/2021 4:03 PM, LV.Wang wrote:
> > 請問如何讓自己撰寫的程式或者script加入到client端,
> > 成為開機後的自動執行項目之一?
> >
> > 需要在server端或者client端作何設定和調整?
> > --
> > 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> > 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> > drbl+uns...@googlegroups.com
> > <mailto:drbl+uns...@googlegroups.com>。
> > 如要在網路上查看這項討論,請造訪
> >
> https://groups.google.com/d/msgid/drbl/66f48eab-f56c-4ad5-80db-a4a447370d31n%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/66f48eab-f56c-4ad5-80db-a4a447370d31n%40googlegroups.com>
>
> >
> <https://groups.google.com/d/msgid/drbl/66f48eab-f56c-4ad5-80db-a4a447370d31n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/drbl/66f48eab-f56c-4ad5-80db-a4a447370d31n%40googlegroups.com?utm_medium=email&utm_source=footer>>。
>
>
> --
> Steven Shiau <steven _at_ stevenshiau org>
> Public Key Server PGP Key ID: 4096R/163E3FB0
> Fingerprint: EB1D D5BF 6F88 820B BCF5 356C 8E94 C9CD 163E 3FB0
>
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/ea0379b0-159f-4aae-bf7f-bc3527f88d85n%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/ea0379b0-159f-4aae-bf7f-bc3527f88d85n%40googlegroups.com?utm_medium=email&utm_source=footer>。

LV.Wang

unread,
Apr 20, 2021, 6:38:49 AM4/20/21
to DRBL
謝謝,
1. 請問上述方式是在client進入後進行設定嗎?
會再嘗試看看

2. 請問是否有方法在server端對於client端進行設定?

3. 另外請問client在auto-login到remote-linux-gra後,是否會有files(類windows檔案總管)無法開啟的問題?


Steven Shiau 在 2021年4月20日 星期二下午5:05:48 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Apr 20, 2021, 8:12:55 AM4/20/21
to dr...@googlegroups.com

On 4/20/21 5:24 PM, LV.Wang wrote:
> 謝謝,
> 1. 請問上述方式是在client進入後進行設定嗎?
> 會再嘗試看看
是。
>
> 2. 請問是否有方法在server端對於client端進行設定?
可以,透過 drbl-client-service 與
drbl-cp-host,你可以把要指定的檔案複製到用戶端的對應目錄,然後啟動用戶端的服務。
指令可以參考: http://drbl.nchc.org.tw/one4all/desktop/drbl-cmd-list.php
不過這部份沒測試過,若有問題請回報。
>
> 3.
> 另外請問client在auto-login到remote-linux-gra後,是否會有files(類windows檔案總管)無法開啟的問題?

我是沒遇過,你的Linux的套件與版本是?

Steven
> <https://groups.google.com/d/msgid/drbl/ea0379b0-159f-4aae-bf7f-bc3527f88d85n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/drbl/ea0379b0-159f-4aae-bf7f-bc3527f88d85n%40googlegroups.com?utm_medium=email&utm_source=footer>>。
>
>
> --
> Steven Shiau <steven _at_ stevenshiau org>
> Public Key Server PGP Key ID: 4096R/163E3FB0
> Fingerprint: EB1D D5BF 6F88 820B BCF5 356C 8E94 C9CD 163E 3FB0
>
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/ce179a94-474e-41aa-9a8f-448837dde630n%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/ce179a94-474e-41aa-9a8f-448837dde630n%40googlegroups.com?utm_medium=email&utm_source=footer>。

LV.Wang

unread,
Apr 21, 2021, 2:50:11 AM4/21/21
to DRBL
謝謝,

對於1.2.今天會再進行測試,

3.的話是ubuntu 20.04,請問無法開啟Files檔案總管是否會跟權限有關?

Steven Shiau 在 2021年4月20日 星期二下午8:12:55 [UTC+8] 的信中寫道:

LV.Wang

unread,
Apr 21, 2021, 2:50:16 AM4/21/21
to DRBL
經測試,
目前在rc.local執行

#! /bin/sh -e
(
      cd /home/test/Desktop && mkdir -p images && mount /dev/sda3 /home/test/Desktop/images
      ntfsclone --save-image --output - /dev/sda2 | pigz > /home/test/Desktop/images/wins0421.ntfsclone.gz
)

會失敗
顯示can't cd directory
和flush error

請問使用上是否有限制?


Steven Shiau 在 2021年4月20日 星期二下午8:12:55 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Apr 21, 2021, 3:45:40 AM4/21/21
to dr...@googlegroups.com
有可能因為這個rc.local跑太快,在NFS還沒掛載/home的時候,就已經執行了,所以可能你的script要加一個等待的機制,直到
/home/test/Desktop 出現的時候,才執行。

Steven
> <https://groups.google.com/d/msgid/drbl/ce179a94-474e-41aa-9a8f-448837dde630n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/drbl/ce179a94-474e-41aa-9a8f-448837dde630n%40googlegroups.com?utm_medium=email&utm_source=footer>>。
>
>
> --
> Steven Shiau <steven _at_ stevenshiau org>
> Public Key Server PGP Key ID: 4096R/163E3FB0
> Fingerprint: EB1D D5BF 6F88 820B BCF5 356C 8E94 C9CD 163E 3FB0
>
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/5636e041-bc58-4e0f-b7ee-d99241ae538bn%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/5636e041-bc58-4e0f-b7ee-d99241ae538bn%40googlegroups.com?utm_medium=email&utm_source=footer>。

LV.Wang

unread,
Apr 21, 2021, 4:10:42 AM4/21/21
to DRBL
謝謝,
在加入
[Unit]
RequiresMountFor

可讓ntfsclone執行完畢,會在驗證檔案是否無誤後,
測試drbl-client-service和drbl-cp-host是否可以達成相同功能


Steven Shiau 在 2021年4月21日 星期三下午3:45:40 [UTC+8] 的信中寫道:

LV.Wang

unread,
Apr 26, 2021, 2:42:53 AM4/26/21
to DRBL
Hi, 
目前從server端針對特定一client下指令
drbl-client-service -h 10.0.0.2 rc.local off

然後對該client下reboot指令,仍會執行rc.local

請問可能是何處沒有設定到呢?

LV.Wang 在 2021年4月21日 星期三下午4:10:42 [UTC+8] 的信中寫道:

LV.Wang

unread,
Apr 26, 2021, 3:42:21 AM4/26/21
to DRBL
請問此rc.local是在client新增並啟用,
是否會因此無法從server端下off指令?

(有試著從server的tftpboot/nodes/10.0.0.2/etc下調整rc.local內容,會反映在client)

LV.Wang 在 2021年4月26日 星期一下午2:42:53 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Apr 26, 2021, 9:48:18 AM4/26/21
to dr...@googlegroups.com

On 4/26/21 3:40 PM, LV.Wang wrote:
> 請問此rc.local是在client新增並啟用,
> 是否會因此無法從server端下off指令?
應該不會。
>
> (有試著從server的tftpboot/nodes/10.0.0.2/etc下調整rc.local內容,會反映在client)
>
> LV.Wang 在 2021年4月26日 星期一下午2:42:53 [UTC+8] 的信中寫道:
>
> Hi, 
> 目前從server端針對特定一client下指令
> drbl-client-service -h 10.0.0.2 rc.local off
>
若執行: drbl-client-service rc.local off

也就是不指定用戶端,是否也是沒辦法關閉所有的?若是,也許drbl-client-service有問題,我們要再往下查看看才知道。
請回覆完整的rc.local設定機制,讓我們這邊也可以依照您的設定,來測試看看。
另外,也跑一下 "drbl-bug-report"然後將產生的檔案一併貼上來。
Thanks.

Steven
> <https://groups.google.com/d/msgid/drbl/5636e041-bc58-4e0f-b7ee-d99241ae538bn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/drbl/5636e041-bc58-4e0f-b7ee-d99241ae538bn%40googlegroups.com?utm_medium=email&utm_source=footer>>。
>
>
> --
> Steven Shiau <steven _at_ stevenshiau org>
> Public Key Server PGP Key ID: 4096R/163E3FB0
> Fingerprint: EB1D D5BF 6F88 820B BCF5 356C 8E94 C9CD 163E
> 3FB0
>
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/afecab38-fe69-4036-aff3-b9de9a79e07cn%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/afecab38-fe69-4036-aff3-b9de9a79e07cn%40googlegroups.com?utm_medium=email&utm_source=footer>。

LV.Wang

unread,
Apr 26, 2021, 9:32:38 PM4/26/21
to DRBL
1. 執行drbl-client-service rc.local off也不會關閉,有無指定都無作用(client仍會執行)

2. drbl-bug-report由於內容為空,沒有錯誤訊息僅系統資訊,若仍需要稍後附上

     - 建立rc-local.service文件
     - 創建文件rc.local
     - 給rc.local加上權限
     - sudo systemctl enable rc-local
     - sudo systemctl start rc-local

補充: 試過drbl-client-service rc.local off / drbl-client-service rc-local off皆無作用

Steven Shiau 在 2021年4月26日 星期一下午9:48:18 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Apr 28, 2021, 12:08:20 AM4/28/21
to dr...@googlegroups.com

On 4/27/2021 9:21 AM, LV.Wang wrote:
> 2. drbl-bug-report由於內容為空,沒有錯誤訊息僅系統資訊,若仍需要稍後附上

這部份需要,因為有些詳細的環境內容,才容易複製環境,來測試。

基本上他會產生一個類似這樣的檔案: DRBL-BUG-RPT-20210428-1207.txt
就附上那個檔即可。

Steven

LV.Wang

unread,
Apr 28, 2021, 2:11:45 AM4/28/21
to DRBL
Hi, 

想請教在rc.local中,是否能將ntfsclone的進度,
除了輸出在terminal外,同時將百分比寫到另一個檔案(或者從client傳回給drbl-server端) ?

DRBL-BUG-RPT-20210427-0918.txt
檔案內容如下: 
To report the bug, fill out the contents in the following table, then send it to DRBL mailing list or post it on the DRBL forum."
-------CUT BEGIN HERE--------------------------------------------
Description of problem:

How reproducible:

Steps to Reproduce:

Actual results:

Expected results:


Some info about the DRBL environment (PLEASE DO NOT EDIT THEM!):
===
OS version: Ubuntu 20.04
Server arch: x86_64
Server CPU:  Intel(R) Xeon(R) E-2144G CPU @ 3.60GHz
Server memory size: 16184628 kB
Server Kernel version: 5.8.0-43-generic
Installed DRBL-related packages:  drbl-2.32.10-drbl1 clonezilla-3.39.14-drbl1 partclone-0.3.14-drbl1 mkpxeinitrd-net-2.5.2-drbl1 ipxe-1.0.0+git-20190109.133f4c4-0ubuntu3.2 partimage-0.6.9-7build1 ntfsprogs-<none> gzip-1.10-0ubuntu4 bzip2-1.0.8-2 lzop-1.04-1 pigz-2.4-1 pbzip2-1.1.13-1build1 udpcast-20120424-2 syslinux-3:6.04~git20190206.bf6db5b4+dfsg1-2
Client kernel version: 5.8.0-43-generic
Client kernel arch: x86_64
NICs with private IP address in server: enp4s0 wlx88d7f60517b9
Private IP address in server: 10.0.0.1 192.168.5.109
Total client no: 1
Client IP address: 10.0.0.2
===
-------CUT END HERE----------------------------------------------


Steven Shiau 在 2021年4月28日 星期三下午12:08:20 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Apr 28, 2021, 6:09:50 PM4/28/21
to dr...@googlegroups.com
確認drbl-client-service不能支援systemd的rc-local.service。
Ubuntu
20.04的systemd有內建rc-local.service,所以不需要自己創,且要配合內建的rc-local.service來改,要花點時間研究看怎樣改drbl-client-service成可以支援:
$ dpkg -L systemd | grep rc-local.service
/lib/systemd/system/rc-local.service
/lib/systemd/system/rc-local.service.d
/lib/systemd/system/rc-local.service.d/debian.conf

至於跑ntfsclone的進度如何同時輸出在terminal與到另一個檔案,你可以用
tee這個指令, 例如:

(ntfsclone --save-image --output - /dev/sda5 | pigz > sda5.ntfs.gz )
2>&1 | tee /tmp/ntfsclone.log

Steven
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/0b1b632f-9d84-4be5-92f7-1c49868ee574n%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/0b1b632f-9d84-4be5-92f7-1c49868ee574n%40googlegroups.com?utm_medium=email&utm_source=footer>。

LV.Wang

unread,
Apr 28, 2021, 10:12:51 PM4/28/21
to DRBL
謝謝,

1. 再麻煩你們有消息通知
2. 會再進行測試


Steven Shiau 在 2021年4月29日 星期四上午6:09:50 [UTC+8] 的信中寫道:

Steven Shiau

unread,
Jun 5, 2021, 9:35:51 AM6/5/21
to dr...@googlegroups.com
我發現因為systemd有內建rc-local.service會run-time去產生service,執行/etc/rc.local,只要/etc/rc.local是可執行的。
所以應該是drblpush
-i之後,用戶端自己的/etc/rc.local存在,就會在開機的時候,systemd這個rc-local
service就會執行/etc/rc.local。因此不需要用drbl-client-service來啟動。
請測試確認看看。

Steven
> <https://groups.google.com/d/msgid/drbl/0b1b632f-9d84-4be5-92f7-1c49868ee574n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/drbl/0b1b632f-9d84-4be5-92f7-1c49868ee574n%40googlegroups.com?utm_medium=email&utm_source=footer>>。
>
>
> --
> Steven Shiau <steven _at_ stevenshiau org>
> Public Key Server PGP Key ID: 4096R/163E3FB0
> Fingerprint: EB1D D5BF 6F88 820B BCF5 356C 8E94 C9CD 163E 3FB0
>
> --
> 這是 Google 網路論壇針對「DRBL」群組發送的訂閱通知郵件。
> 如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到
> drbl+uns...@googlegroups.com
> <mailto:drbl+uns...@googlegroups.com>。
> 如要在網路上查看這項討論,請造訪
> https://groups.google.com/d/msgid/drbl/94c77487-4a59-4766-8f9d-258eed6f148dn%40googlegroups.com
> <https://groups.google.com/d/msgid/drbl/94c77487-4a59-4766-8f9d-258eed6f148dn%40googlegroups.com?utm_medium=email&utm_source=footer>。
Reply all
Reply to author
Forward
0 new messages