diff options
author | Timo Teräs <timo.teras@iki.fi> | 2016-08-08 15:25:22 +0300 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2016-11-14 20:10:39 +0000 |
commit | 46f65fad4cce984a5f3cb781ee2fe18933665862 (patch) | |
tree | b19f847e4f9b91071cfb1eab5faad4e63b9bd60b /scripts/genapkovl-dhcp.sh | |
parent | cdaf6e91c92269a9ea7afe5cf83fee79f0594d90 (diff) | |
download | aports-46f65fad4cce984a5f3cb781ee2fe18933665862.tar.bz2 aports-46f65fad4cce984a5f3cb781ee2fe18933665862.tar.xz |
scripts/mkimage.sh: scripts to build bootable alpine images
Diffstat (limited to 'scripts/genapkovl-dhcp.sh')
-rwxr-xr-x | scripts/genapkovl-dhcp.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/genapkovl-dhcp.sh b/scripts/genapkovl-dhcp.sh new file mode 100755 index 0000000000..83ed3dd9aa --- /dev/null +++ b/scripts/genapkovl-dhcp.sh @@ -0,0 +1,66 @@ +#!/bin/sh -e + +HOSTNAME="$1" +if [ -z "$HOSTNAME" ]; then + echo "usage: $0 hostname" + exit 1 +fi + +cleanup() { + rm -rf "$tmp" +} + +makefile() { + OWNER="$1" + PERMS="$2" + FILENAME="$3" + cat > "$FILENAME" + chown "$OWNER" "$FILENAME" + chmod "$PERMS" "$FILENAME" +} + +rc_add() { + mkdir -p "$tmp"/etc/runlevels/"$2" + ln -sf /etc/init.d/"$1" "$tmp"/etc/runlevels/"$2"/"$1" +} + +tmp="$(mktemp -d)" +trap cleanup EXIT + +mkdir -p "$tmp"/etc +makefile root:root 0644 "$tmp"/etc/hostname <<EOF +$HOSTNAME +EOF + +mkdir -p "$tmp"/etc/network +makefile root:root 0644 "$tmp"/etc/network/interfaces <<EOF +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + +mkdir -p "$tmp"/etc/apk +makefile root:root 0644 "$tmp"/etc/apk/world <<EOF +alpine-base +EOF + +rc_add devfs sysinit +rc_add dmesg sysinit +rc_add mdev sysinit +rc_add hwdrivers sysinit +rc_add modloop sysinit + +rc_add hwclock boot +rc_add modules boot +rc_add sysctl boot +rc_add hostname boot +rc_add bootmisc boot +rc_add syslog boot + +rc_add mount-ro shutdown +rc_add killprocs shutdown +rc_add savecache shutdown + +tar -c -C "$tmp" etc | gzip -9n > $HOSTNAME.apkovl.tar.gz |