1
0
Fork 0
mirror of https://github.com/kou029w/yama.git synced 2025-01-18 16:08:11 +00:00

create projects

This commit is contained in:
Nebel 2020-07-21 01:06:43 +09:00
parent 09e01dbe06
commit d86773ccc1
19 changed files with 139 additions and 0 deletions

11
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,11 @@
name: build
on:
schedule: [{ cron: "0 21 * * sun" }] # Every Monday at 6am Asia/Tokyo UTC+9
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" -p "${{ github.token }}"
- run: bin/build
- run: docker-compose push

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/apkovl/
/cache/
/dist/

47
README.md Normal file
View file

@ -0,0 +1,47 @@
# Yama
Raspberry Pi 向け OS のビルドするためのツール群
- Alpine Linux ベース (armhf)
- WiFi 対応
- その他オレオレカスタマイズ
## ビルド
```sh
bin/build
```
### SD カードのフォーマット
- FAT32 (LBA)
- boot フラグ付ける
- ボリュームラベル付けない
### SD カードに書き込み
```sh
rsync -a dist/ /path/to/sd/
```
### 前提条件
- Docker Compose
- curl
- grep
- jq
- ruby
- ssh-keygen
- bash
### 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 で配置後ビルド

View file

1
apkovl/etc/apk/cache Symbolic link
View file

@ -0,0 +1 @@
/media/mmcblk0p1/cache

View file

@ -0,0 +1,3 @@
/media/mmcblk0p1/apks
http://dl-cdn.alpinelinux.org/alpine/v3.12/main
http://dl-cdn.alpinelinux.org/alpine/v3.12/community

3
apkovl/etc/apk/world Normal file
View file

@ -0,0 +1,3 @@
alpine-base
openssh
wpa_supplicant

View file

@ -0,0 +1,6 @@
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
hostname localhost

View file

@ -0,0 +1 @@
/etc/init.d/networking

View file

@ -0,0 +1 @@
/etc/init.d/wpa_supplicant

View file

@ -0,0 +1 @@
/etc/init.d/ntpd

View file

@ -0,0 +1 @@
/etc/init.d/sshd

View file

@ -0,0 +1,4 @@
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
Subsystem sftp /usr/lib/ssh/sftp-server

15
bin/build Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
# ビルド
# Usage: bin/build
# Required: docker-compose
cd -- "$(dirname -- "$0")/.."
set -eux
version="$(bin/version)"
bin/import "${version}" docker.pkg.github.com/kou029w/yama/minirootfs
rm -rf dist
mkdir dist
bin/download "${version}" dist
docker-compose run --rm minirootfs sh -c 'apk update && apk add'
ssh-keygen -A -f apkovl
cp -a cache dist
tar czf dist/localhost.apkovl.tar.gz --owner=0 --group=0 -C apkovl .

9
bin/conf-gen Executable file
View file

@ -0,0 +1,9 @@
#!/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='

8
bin/download Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
# ベースのイメージをダウンロード
# Usage: bin/download version dist
# Required: curl
set -eu
base="http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf"
curl "${base}/alpine-rpi-${1}-armhf.tar.gz" \
| tar xzf - -C "${2}"

7
bin/import Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
# イメージを取得
# Usage: bin/import version my-image-name
# Required: docker
set -eux
base="http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf"
docker import "${base}/alpine-minirootfs-${1}-armhf.tar.gz" "${2}"

10
bin/version Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# 最新のバージョンを取得
# Usage: bin/version
# Required: curl grep jq ruby
set -eu
base="http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf"
curl -s "${base}/latest-releases.yaml" \
| ruby -ryaml -rjson -e 'puts(YAML.load($<).to_json)' \
| jq -r '.[] | select(.title == "Raspberry Pi").file' \
| grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'

8
docker-compose.yml Normal file
View file

@ -0,0 +1,8 @@
version: "3"
services:
minirootfs:
image: docker.pkg.github.com/kou029w/yama/minirootfs
volumes:
- ./cache:/etc/apk/cache
- ./apkovl/etc/apk/repositories:/etc/apk/repositories
- ./apkovl/etc/apk/world:/etc/apk/world