update some content

This commit is contained in:
2021-10-28 14:15:01 +08:00
parent b8600ab259
commit 27b5a11382
163 changed files with 951 additions and 922 deletions

View File

@@ -45,9 +45,9 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link href="https://h.cowbay.org/css/style.css?v=1634607506" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/style.css?v=1635401692" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1634607506" rel="stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1635401692" rel="stylesheet" type='text/css' media='all'>
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
@@ -314,12 +314,12 @@ if (!doNotTrack) {
<p>看似很簡單的一件事情,卻搞了我兩天&hellip;.</p>
<p>本來在 preseed 檔案中,就有 preseed/late_command 可以用</p>
<p>但是測試了很多遍,才終於找到正確的語法</p>
<pre tabindex="0"><code>d-i preseed/late_command \
<pre><code>d-i preseed/late_command \
in-target apt-file update; \
in-target passwd --expire root ;\
in-target /bin/sh -c 'echo &quot;hostname|mail -s pxe_install_complete admin@abc.com&quot; &gt; /etc/rc.local'
</code></pre><p>這會把目標主機上的 /etc/rc.local 的內容改成只有一行</p>
<pre tabindex="0"><code>hostname|mail -s pxe_install_complete admin@abc.com
<pre><code>hostname|mail -s pxe_install_complete admin@abc.com
</code></pre><p>這樣就可以讓主機在完成系統安裝後,第一次重新開機時,送出郵件通知</p>
<p>可是呢因為ubuntu 開機時,本來就會去執行 /etc/rc.local</p>
<p>所以「每次」開機後,都會送出郵件通知</p>
@@ -329,19 +329,19 @@ if (!doNotTrack) {
<p>另一個是用ansible來處理</p>
<p>又或者是,讓這個指令在送出郵件後,「自我還原」或者「自我更新」</p>
<p>自我還原的部份可以這樣做</p>
<pre tabindex="0"><code>hostname|mail -s pxe_install_complete admin@abc.com
<pre><code>hostname|mail -s pxe_install_complete admin@abc.com
echo &quot;#!/bin/sh -e\nexit 0&quot; &gt; /etc/rc.local
</code></pre><p>所以preseed 那邊的語法就要改一下</p>
<pre tabindex="0"><code> in-target /bin/sh -c 'echo &quot;hostname|mail -s pxe_install_complete admin@abc.com;\&quot;exit 0\&quot; &gt; /etc/rc.local'
<pre><code> in-target /bin/sh -c 'echo &quot;hostname|mail -s pxe_install_complete admin@abc.com;\&quot;exit 0\&quot; &gt; /etc/rc.local'
</code></pre><p>這樣一來,在送出郵件後,/etc/rc.local 的檔案內容會被恢復成只有底下這一行</p>
<pre tabindex="0"><code>exit 0
<pre><code>exit 0
</code></pre><p>暫時先這樣子處理</p>
<h3 id="更新">更新</h3>
<p>因為直接把 /etc/rc.local 的內容改掉,實在讓我有點不放心</p>
<p>所以想到一個方式,先備份 /etc/rc.local 然後加入我要的功能</p>
<p>因為我只需要它跑一次就好,所以就可以在最後面加入還原剛剛複製的備份檔案</p>
<p>簡單說在preseed 檔案中 改成這樣</p>
<pre tabindex="0"><code>d-i preseed/late_command \
<pre><code>d-i preseed/late_command \
in-target apt-file update; \
in-target passwd --expire root ;\
in-target cp /etc/rc.local /etc/rc.local.bak ;\
@@ -639,7 +639,7 @@ title="pinterest icon"></i>
</div>
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1634607506"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1635401692"></script>
</body>
</html>