mirror of
https://github.com/kou029w/yama.git
synced 2025-01-18 16:08:11 +00:00
create setup-yama script
This commit is contained in:
parent
5b4526ff20
commit
b6009672e1
11 changed files with 60 additions and 41 deletions
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -11,9 +11,7 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt-get install -y qemu-user-static
|
- run: sudo apt-get install -y qemu-user-static
|
||||||
- run: sudo bin/overlay-gen
|
- run: sudo bin/build
|
||||||
- run: bin/build
|
|
||||||
- run: sudo bin/img-gen
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: yama-armhf
|
name: yama-armhf
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
/apkovl/
|
|
||||||
/cache/
|
/cache/
|
||||||
/dist/
|
/dist/
|
||||||
/overlay.img.gz
|
/overlay.img.gz
|
||||||
|
|
26
README.md
26
README.md
|
@ -6,12 +6,20 @@ Raspberry Pi Zero 向け OS のビルドするためのツール群
|
||||||
- WiFi 対応
|
- WiFi 対応
|
||||||
- その他オレオレカスタマイズ
|
- その他オレオレカスタマイズ
|
||||||
|
|
||||||
|
## 使い方
|
||||||
|
|
||||||
|
1. [Releases](https://github.com/kou029w/yama/releases) からイメージをダウンロード
|
||||||
|
2. イメージを microSD カードに書き込む
|
||||||
|
3. (必要に応じて) microSD カードの中の setup-yama ファイルを編集して保存
|
||||||
|
4. microSD カードを Raspberry Pi Zero に差し込む
|
||||||
|
5. Raspberry Pi Zero の電源投入
|
||||||
|
|
||||||
|
電源投入後、2 分で起動完了
|
||||||
|
|
||||||
## ビルド
|
## ビルド
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
bin/overlay-gen
|
|
||||||
bin/build
|
bin/build
|
||||||
bin/img-gen
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 前提条件
|
### 前提条件
|
||||||
|
@ -21,19 +29,7 @@ bin/img-gen
|
||||||
- Docker
|
- Docker
|
||||||
- Docker Compose
|
- Docker Compose
|
||||||
- qemu-user-static
|
- qemu-user-static
|
||||||
- awk, bash, curl, fallocate, grep, gzip, losetup, mkfs.ext4, mkfs.fat, parted, python3, ssh-keygen, tar, xargs
|
- awk, curl, fallocate, gzip, losetup, mkfs.ext4, mkfs.fat, parted, python3, tar, xargs
|
||||||
|
|
||||||
### WiFi の設定
|
|
||||||
|
|
||||||
`apkovl/etc/wpa_supplicant/wpa_supplicant.conf` 配置後ビルド
|
|
||||||
|
|
||||||
```sh
|
|
||||||
bin/conf-gen | tee apkovl/etc/wpa_supplicant/wpa_supplicant.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
### ssh の設定
|
|
||||||
|
|
||||||
`apkovl/root/.ssh/authorized_keys` をパーミッション 600 で配置後ビルド
|
|
||||||
|
|
||||||
## ライセンス
|
## ライセンス
|
||||||
|
|
||||||
|
|
6
apkovl/etc/init.d/setup-yama
Executable file
6
apkovl/etc/init.d/setup-yama
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
start() {
|
||||||
|
if [ -x /media/mmcblk0p1/setup-yama ]; then
|
||||||
|
/media/mmcblk0p1/setup-yama
|
||||||
|
fi
|
||||||
|
}
|
1
apkovl/etc/runlevels/default/setup-yama
Symbolic link
1
apkovl/etc/runlevels/default/setup-yama
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/etc/init.d/setup-yama
|
|
@ -10,9 +10,9 @@ rm -rf dist
|
||||||
mkdir dist
|
mkdir dist
|
||||||
bin/download "${version}" dist
|
bin/download "${version}" dist
|
||||||
docker compose run --rm minirootfs sh -c 'apk update && apk add'
|
docker compose run --rm minirootfs sh -c 'apk update && apk add'
|
||||||
ssh-keygen -A -f apkovl
|
cp -a src/* cache -t dist
|
||||||
cp -a usercfg.txt cache -t dist
|
bin/overlay-gen dist/overlay.img
|
||||||
gzip -cdk overlay.img.gz > dist/overlay.img
|
|
||||||
docker compose run --rm builder
|
docker compose run --rm builder
|
||||||
tar czf dist/localhost.apkovl.tar.gz --owner=0 --group=0 -C apkovl .
|
tar czf dist/localhost.apkovl.tar.gz --owner=0 --group=0 -C apkovl .
|
||||||
tar czf yama-armhf.tar.gz --owner=0 --group=0 -C dist .
|
tar czf yama-armhf.tar.gz --owner=0 --group=0 -C dist .
|
||||||
|
bin/img-gen yama-armhf.img
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# wpa_supplicant.conf の生成
|
|
||||||
# Usage: bin/conf-gen
|
|
||||||
# Required: wpa_supplicant grep
|
|
||||||
set -euo pipefail
|
|
||||||
read -p 'Please enter ssid: ' ssid
|
|
||||||
read -p 'Please enter passphrase: ' -s passphrase
|
|
||||||
wpa_passphrase "$ssid" "$passphrase" \
|
|
||||||
| grep -v '#psk='
|
|
11
bin/img-gen
11
bin/img-gen
|
@ -1,12 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# デバイスイメージファイルの生成
|
# デバイスイメージファイルの生成
|
||||||
# Usage: bin/img-gen
|
# Usage: bin/img-gen yama-armhf.img
|
||||||
# Required: gzip awk fallocate parted xargs losetup mkfs.fat tar
|
# Required: gzip awk fallocate parted xargs losetup mkfs.fat tar
|
||||||
cd -- "$(dirname -- "$0")/.."
|
cd -- "$(dirname -- "$0")/.."
|
||||||
set -eux
|
set -eux
|
||||||
size="$(gzip -l yama-armhf.tar.gz | awk 'END{printf"%.f",$2*1.02}')"
|
size="$(gzip -l yama-armhf.tar.gz | awk 'END{printf"%.f",$2*1.02}')"
|
||||||
fallocate -l "${size}" yama-armhf.img
|
image="$1"
|
||||||
xargs -l parted -s yama-armhf.img <<EOF
|
fallocate -l "${size}" "${image}"
|
||||||
|
xargs -l parted -s "${image}" <<EOF
|
||||||
mklabel msdos
|
mklabel msdos
|
||||||
mkpart primary fat32 0 100%
|
mkpart primary fat32 0 100%
|
||||||
set 1 boot on
|
set 1 boot on
|
||||||
|
@ -14,7 +15,7 @@ EOF
|
||||||
dev="$(losetup -f)"
|
dev="$(losetup -f)"
|
||||||
finally="losetup -d '${dev}'"
|
finally="losetup -d '${dev}'"
|
||||||
trap 'sh -c "${finally}"' EXIT
|
trap 'sh -c "${finally}"' EXIT
|
||||||
losetup -P "${dev}" yama-armhf.img
|
losetup -P "${dev}" "${image}"
|
||||||
part="${dev}p1"
|
part="${dev}p1"
|
||||||
mkfs.fat "${part}"
|
mkfs.fat "${part}"
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
|
@ -22,4 +23,4 @@ finally="rmdir '${tmp}'; ${finally}"
|
||||||
mount "${part}" "${tmp}"
|
mount "${part}" "${tmp}"
|
||||||
finally="umount '${tmp}'; ${finally}"
|
finally="umount '${tmp}'; ${finally}"
|
||||||
tar xf yama-armhf.tar.gz -C "${tmp}"
|
tar xf yama-armhf.tar.gz -C "${tmp}"
|
||||||
finally="${finally}; gzip -f yama-armhf.img"
|
finally="${finally}; gzip -f '${image}'"
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# オーバーレイイメージファイルの生成
|
# オーバーレイイメージファイルの生成
|
||||||
# Usage: bin/overlay-gen
|
# Usage: bin/overlay-gen dist/overlay.img
|
||||||
# Required: fallocate losetup mkfs.ext4 gzip
|
# Required: fallocate losetup mkfs.ext4 gzip
|
||||||
cd -- "$(dirname -- "$0")/.."
|
cd -- "$(dirname -- "$0")/.."
|
||||||
set -eux
|
set -eux
|
||||||
size=512m
|
size=512m
|
||||||
fallocate -l "${size}" overlay.img
|
image="$1"
|
||||||
mkfs.ext4 overlay.img
|
fallocate -l "${size}" "${image}"
|
||||||
|
mkfs.ext4 "${image}"
|
||||||
dev="$(losetup -f)"
|
dev="$(losetup -f)"
|
||||||
finally="losetup -d '${dev}'"
|
finally="losetup -d '${dev}'"
|
||||||
trap 'sh -c "${finally}"' EXIT
|
trap 'sh -c "${finally}"' EXIT
|
||||||
losetup "${dev}" overlay.img
|
losetup "${dev}" "${image}"
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
finally="rmdir '${tmp}'; ${finally}"
|
finally="rmdir '${tmp}'; ${finally}"
|
||||||
mount "${dev}" "${tmp}"
|
mount "${dev}" "${tmp}"
|
||||||
finally="umount '${tmp}'; ${finally}"
|
finally="umount '${tmp}'; ${finally}"
|
||||||
mkdir -p "${tmp}/work/usr"
|
mkdir -p "${tmp}/work/usr"
|
||||||
mkdir -p "${tmp}/upper/usr"
|
mkdir -p "${tmp}/upper/usr"
|
||||||
finally="${finally}; gzip -f overlay.img"
|
|
||||||
|
|
27
src/setup-yama
Executable file
27
src/setup-yama
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
cd -- "$(dirname -- "$0")"
|
||||||
|
exec > setup-yama.log 2>&1
|
||||||
|
|
||||||
|
ssid=""
|
||||||
|
passphrase=""
|
||||||
|
authorized_key=""
|
||||||
|
|
||||||
|
if [ -n "$ssid" ]; then
|
||||||
|
wpa_passphrase "$ssid" "$passphrase" > /etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
|
service wpa_supplicant restart
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$authorized_key" ]; then
|
||||||
|
mkdir -p /root/.ssh
|
||||||
|
chmod 700 /root/.ssh
|
||||||
|
echo "$authorized_key" > /root/.ssh/authorized_keys
|
||||||
|
chmod 600 /root/.ssh/authorized_keys
|
||||||
|
ssh-keygen -A
|
||||||
|
service sshd restart
|
||||||
|
fi
|
||||||
|
|
||||||
|
lbu include /root
|
||||||
|
lbu commit -d mmcblk0p1
|
||||||
|
rm -f -- "$0"
|
||||||
|
echo ok
|
Loading…
Add table
Reference in a new issue