Building the Go38Box
Go38Box修改自MoodleBox,而MoodleBox一開始就是設定在Raspberry Pi 3上執行運作,讓使用者可以隨身帶著一個Raspberry Pi 3及行動電源就可以使用Moodle教學平台,MoodleBox官網有做動的img檔可供使用者下載,然後燒錄到Raspberry Pi 3,或者可以透過手動建置的方式,在剛開始官方所提供的是一步一步的指令去修改設定,接著又轉換成使用script自動安裝(github中切換到Branch:https),現在則改用Ansbile自動化組態管理把Moodle安裝到Raspberry Pi 3中,而Go38Box的溫濕度也透過Ansible自動化組態管理來做安裝設定,安裝及設定的方式和Moodlebox一樣,所以以下就依Moodlebox官方的安裝步驟做說明
在官方的Github中有以下10點的安裝步驟
To build a MoodleBox from scratch with this script, you need a Raspberri Pi 3 (Wi-Fi!) and follow these instructions.
Clone Rasbpian Stretch Lite on your microSD card.
Create a
ssh
file on theboot
partition, e.g. usingtouch ssh
Insert the microSD card into your Raspberry
Connect your Raspberry to your Ethernet network and boot it.
Install Ansible on your computer.
Clone this repository to your local drive.
Create a
keys
directory in the repository folder and copy your public key into it, under the nameid_rsa.pub
.Get the IP address of your RaspberryPi and change it in the
hosts.yml
file. Do not change anything else, unless you know what you're doing. You're on your own.Run
ansible-playbook moodlebox.yml
from the repository folder.Wait 30–50 minutes, depending on your SD card and Internet bandwidth. You're done.
1. Clone Rasbpian Stretch Lite on your microSD card.
在Raspberry Pi 3的話就是直接到官方網站下載Raspian Stretch Lite(https://www.raspberrypi.org/downloads/raspbian/),不論是Raspberry Pi 3B還是3B Plus,請下載最新版的Release Date是2018-04-08(2018-04-18-raspbian-stretch-lite.zip),下載完成後檔案的副檔名為zip,不用解壓縮直接用燒錄軟體選該zip檔即可,Mac作業系統可以使用Etcher軟體燒錄到microSD卡中,Windows作業系統可以使用Win32DiskImager燒錄。
2. Create a ssh file on thebootpartition, e.g. using touch ssh
此動作在燒錄到microSD卡後,要先執行指令「touch ssh」產生ssh檔案開機後會啟動ssh服務,Mac作業系統打開終端機執行指令「touch /Volumes/boot/ssh」,Windows作業系統打開檔案總管,找到磁碟機名稱為boot的磁碟編號,例如磁碟機編號為「G」,打開命令提示字元,執行指令「touch G:\ssh」會在該磁碟內建立ssh檔,在Windows下燒錄完成或者重新把microSD插入電腦後,出現「需要格式化磁碟機…」的視窗,請不要執行格式化。
3. Insert the microSD card into your Raspberry
系統燒錄完成後,接著就是把microSD卡插入設備的microSD插槽,Raspberry Pi 3直接把microSD卡推到最底就可以,取出的方式是直接拔出microSD。
4. Connect your Raspberry to your Ethernet network and boot it
Raspberry Pi 3內建RJ-45網路介面,這個步驟只要把網路線線上,及插上電源,會自動開機。
5. Install Ansible on your computer.
目前Ansible測試於Mac系統,請參考Mac 安裝 Ansible 的安裝步驟,如果是要在Windows系統需要透過類似VirtualBox建立Linux虛擬機器並且安裝Ansible。
6. Clone this repository to your local drive.
在本機電腦中安裝好Ansible後,接著就是從GitHub上Clone Repository(復製儲存庫),moodlebox官方的github網址「https://github.com/martignoni/moodlebox」,git的網址「https://github.com/martignoni/moodlebox.git」,如果安裝於Raspberry Pi 3請直接clone官方的設定檔即可,那這邊要修改網址,目前Go38Box專案存放在「https://git.go38.net/go38/go38box-temperature.git」
打開終端機,然後切換到要存放的路徑,輸入指令「git clone https://git.go38.net/go38/go38box-temperature.git」
切換路徑到go38box-tempe,檢查是否有檔案
7. Create akeys
directory in the repository folder and copy your public key into it, under the nameid_rsa.pub
keys
directory in the repository folder and copy your public key into it, under the nameid_rsa.pub
這個步驟主要讓Raspberry Pi 3或Banana Pi M64可以免輸入密碼登入,讓Ansible執行安裝過程中不用再輸入密碼,首先在moodlebox-bpi目錄中建立一個名稱為keys的資料夾
使用ssh-keygen指令產生公開金鑰,產生過程會問要儲存的路徑及密碼,都不設定,用預設值即可,注意一下預設存放的路徑,一般都是在使用者帳號下的「.ssh」資料夾中,ssh-keygen產生過程如下:
執行完ssh-keygen後,預設檔名為id_rsa,會產生兩個檔案id_rsa及id_rsa.pub於「使用者目錄/.ssh」中,確認一下是否有產生所要的檔案,如下:
idrsa為私鑰,這就如登入的密碼,此檔案是放在本機電腦中,而id_rsa.pub為公鑰,此檔案要放在遠端的電腦中認證用,所以要把id_rsa.pub檔案複製到所建立的「keys」資料夾中,在執行Ansible時,會把此檔案放到遠端的設備中,最後檢查keys資料夾中是否有id_rsa.pub檔
8. Get the IP address of your RaspberryPi and change it in thehosts.yml
file. Do not change anything else, unless you know what you're doing. You're on your own.
hosts.yml
file. Do not change anything else, unless you know what you're doing. You're on your own.接著要設定Go38Box專案中的「hosts.yml」檔,此檔案主要是設定要連線的設備ip及登入的帳號及密碼,原始內容如下:
如同官方文件的說明,只要修改設備的ip,就是hosts.yml中的ansible_host參數,其他如果不知道或沒必要請不要修改。
如果Raspberry Pi 3在沒有外接螢幕的狀況下要如何連線並且取得設備的ip呢?接下來就試範當設備燒錄好後,接上網路線並且開機後要如何連線取得設備ip,注意本機電腦和遠端的設備需要在同一個網段下。
Raspberry Pi 3
在終端機中執行指令「ssh pi@raspberrypi.local」,預設密碼為「raspberry」
使用「ifconfig」指令查詢
使用「ip addr」指令查詢
9. Runansible-playbook moodlebox.yml
from the repository folder.
ansible-playbook moodlebox.yml
from the repository folder.將目錄切換到Go38Box專案目錄,然後執行以下的指令開始執行安裝作業
Raspberry Pi 3
10. Wait 30–50 minutes, depending on your SD card and Internet bandwidth. You're done.
整個安裝過程大約30~50分鐘,這個時間會因為使用的microSD卡讀寫的速度與網路頻寬的速度而有所不同。
進入Go38Box溫濕度網站
以上十個步驟完成後,會自動重開機,打開網址就可以看到目前溫濕度的資訊
Raspberry Pi 3預設網址:http://go38box.local
SSH進入Go38Box
如果要ssh到安裝好的Go38Box時,連線的網址會不同,被修改go38box.local,連線網址及帳號密碼,請參照下方的對照表
連線網址對照表
設備連線網址
官方預設值
安裝Go38Box
Raspberry Pi 3
raspberrypi.local
go38box.local
連線的帳號密碼對照表
設備連線帳號 / 密碼
官方預設值
安裝Go38Box
Raspberry Pi 3
pi / raspberry
go38box / Go38box4$
連線後的畫面會多一個樹梅派的logo,正常連線後會看到如下圖的畫面,會顯示一些資訊,但這個資訊目前設定是每10分鐘更新一次,第一行有日期時間,就是資料更新的時間!
Last updated
Was this helpful?