diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..2d63400 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,3 @@ +app +alpine*.img* +flash.sh \ No newline at end of file diff --git a/example/build_image.sh b/example/build_image.sh new file mode 100755 index 0000000..cd9a39c --- /dev/null +++ b/example/build_image.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +docker run --rm -v "$PWD":/work -w /work -e GOOS=linux -e GOARCH=arm -e GOARM=5 golang:1.13-alpine go build -v -o ./app . + +docker run --rm -it -v "$PWD":/input -v $PWD:/output bboehmke/raspi-alpine-builder \ No newline at end of file diff --git a/example/image.sh b/example/image.sh new file mode 100755 index 0000000..bba425c --- /dev/null +++ b/example/image.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +cp ${INPUT_PATH}/app ${ROOTFS_PATH}/usr/bin/test_app +cp ${INPUT_PATH}/init.sh ${ROOTFS_PATH}/etc/init.d/test_app + +chroot_exec rc-update add test_app default diff --git a/example/init.sh b/example/init.sh new file mode 100755 index 0000000..27d5f56 --- /dev/null +++ b/example/init.sh @@ -0,0 +1,13 @@ +#!/sbin/openrc-run + +command="/usr/bin/test_app" +pidfile="/var/run/test_app.pid" +command_args="" +command_background=true + + +depend() { + use logger dns + need net + after firewall +} diff --git a/example/main.go b/example/main.go new file mode 100644 index 0000000..db66839 --- /dev/null +++ b/example/main.go @@ -0,0 +1,10 @@ +package main + +import "net/http" + +func main() { + http.HandleFunc("/", func(writer http.ResponseWriter, _ *http.Request) { + writer.Write([]byte("It works!")) + }) + http.ListenAndServe(":8080", nil) +}