aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/genapkovl-xen.sh
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-08-08 15:25:22 +0300
committerNatanael Copa <ncopa@alpinelinux.org>2016-11-14 20:10:39 +0000
commit46f65fad4cce984a5f3cb781ee2fe18933665862 (patch)
treeb19f847e4f9b91071cfb1eab5faad4e63b9bd60b /scripts/genapkovl-xen.sh
parentcdaf6e91c92269a9ea7afe5cf83fee79f0594d90 (diff)
downloadaports-46f65fad4cce984a5f3cb781ee2fe18933665862.tar.gz
aports-46f65fad4cce984a5f3cb781ee2fe18933665862.tar.bz2
aports-46f65fad4cce984a5f3cb781ee2fe18933665862.tar.xz
scripts/mkimage.sh: scripts to build bootable alpine images
Diffstat (limited to 'scripts/genapkovl-xen.sh')
-rwxr-xr-xscripts/genapkovl-xen.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/scripts/genapkovl-xen.sh b/scripts/genapkovl-xen.sh
new file mode 100755
index 0000000000..3b65e41ca8
--- /dev/null
+++ b/scripts/genapkovl-xen.sh
@@ -0,0 +1,75 @@
+#!/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
+
+makefile root:root 0644 "$tmp"/etc/modules <<EOF
+xen_netback
+xen_blkback
+xenfs
+xen-platform-pci
+xen_wdt
+tun
+EOF
+
+mkdir -p "$tmp"/etc/network
+makefile root:root 0644 "$tmp"/etc/network/interfaces <<EOF
+auto lo
+iface lo inet loopback
+EOF
+
+mkdir -p "$tmp"/etc/apk
+
+makefile root:root 0644 "$tmp"/etc/apk/world <<EOF
+xen
+EOF
+
+rc_add devfs sysinit
+rc_add dmesg sysinit
+rc_add udev 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 udev-postmount default
+rc_add xenstored default
+rc_add xenconsoled default
+
+rc_add mount-ro shutdown
+rc_add killprocs shutdown
+rc_add savecache shutdown
+
+tar -c -C "$tmp" etc | gzip -9n > $HOSTNAME.apkovl.tar.gz