Last active
April 30, 2017 06:49
-
-
Save yjuba/d3dec3f7f6959921320258ba76d08e93 to your computer and use it in GitHub Desktop.
LXD用のUbuntu Xenialイメージ作成スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
set -x | |
REPO_URL='http://www.ftp.ne.jp/Linux/packages/ubuntu/archive/ubuntu/' | |
work=$(mktemp -d work.XXXXXX) | |
cd ${work} | |
mkdir -p rootfs | |
mkdir -p templates | |
debootstrap --arch amd64 xenial rootfs ${REPO_URL} | |
cat > rootfs/etc/apt/sources.list <<EOF | |
deb ${REPO_URL} xenial main restricted universe multiverse | |
deb ${REPO_URL} xenial-updates main restricted universe multiverse | |
deb ${REPO_URL} xenial-security main restricted universe multiverse | |
EOF | |
cat > rootfs/etc/network/interfaces.d/lo <<EOF | |
auto lo | |
iface lo inet loopback | |
EOF | |
cat > rootfs/etc/network/interfaces.d/eth0 <<EOF | |
auto eth0 | |
iface eth0 inet dhcp | |
EOF | |
cat > templates/hostname.tpl <<EOF | |
{{ container.name }} | |
EOF | |
cat > metadata.yaml <<EOF | |
architecture: x86_64 | |
creation_date: $(date +%s) | |
properties: | |
description: Xenial | |
os: Ubuntu | |
release: "xenial" | |
templates: | |
/etc/hostname: | |
when: | |
- create | |
- copy | |
template: hostname.tpl | |
EOF | |
tar czf ubuntu.tar.gz metadata.yaml rootfs templates | |
lxc image import ubuntu.tar.gz --alias my-ubuntu | |
cd .. | |
rm -rf ${work} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment