feat: megabit mode

This commit is contained in:
Nebel 2021-07-25 13:56:57 +09:00
parent 683c5f5a62
commit eefb903a28
13 changed files with 33 additions and 8 deletions

View file

@ -1,4 +1,4 @@
# Yama
# Megabit OS
Raspberry Pi 向け OS のビルドするためのツール群

View file

@ -1,4 +1,5 @@
alpine-base
i2c-tools
openssh
rsync
wpa_supplicant

4
apkovl/etc/init.d/megabit Executable file
View file

@ -0,0 +1,4 @@
#!/sbin/openrc-run
name=megabit
command="/usr/local/bin/megabit"
pidfile="/var/run/megabit.pid"

11
apkovl/etc/init.d/megabit-sync Executable file
View file

@ -0,0 +1,11 @@
#!/sbin/openrc-run
name=megabit-sync
command="/usr/local/bin/megabit-sync"
pidfile="/var/run/megabit-sync.pid"
start_pre() {
mkdir -p /mnt/tmp
mount /usr/share/megabit/tmp.img /mnt/tmp
modprobe -r g_mass_storage
modprobe g_mass_storage file=/usr/share/megabit/tmp.img
}

View file

@ -1 +0,0 @@
options g_mass_storage file=/dev/mmcblk0p1

View file

@ -1 +0,0 @@
g_mass_storage

View file

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

View file

@ -0,0 +1 @@
/etc/init.d/megabit-sync

4
apkovl/usr/local/bin/megabit Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
export NODE_PATH=$(npm root -g)
nodemon --delay 1 --watch /tmp --signal SIGTERM --exec 'node /tmp/index.js || true' &
echo $! > /var/run/megabit.pid

View file

@ -0,0 +1,3 @@
#!/bin/sh
nodemon --delay 1 --watch /usr/share/megabit/tmp.img --signal SIGTERM --exec 'umount /mnt/tmp; mount /usr/share/megabit/tmp.img /mnt/tmp; rsync -a --delete --exclude=node_modules/ /mnt/tmp/ /tmp/' &
echo $! > /var/run/megabit-sync.pid

View file

@ -16,7 +16,9 @@ services:
- ./dist/overlay.img:/overlay.img
privileged: true
command: |
sh -c '
mount -a \
&& apk add g++ linux-headers make nodejs npm python3
sh -exc '
mkdir -p /mnt/overlay
mount -a
apk add g++ linux-headers make nodejs npm python3
npm install -g megabit nodemon
'

4
fstab
View file

@ -1,2 +1,2 @@
/overlay.img /mnt ext4 rw,relatime,errors=remount-ro 0 0
overlay /usr overlay lowerdir=/usr,upperdir=/mnt/upper/usr,workdir=/mnt/work/usr 0 0
/overlay.img /mnt/overlay ext4 rw,relatime,errors=remount-ro 0 0
overlay /usr overlay lowerdir=/usr,upperdir=/mnt/overlay/upper/usr,workdir=/mnt/overlay/work/usr 0 0

Binary file not shown.