Alpine linux image build and appliance file

This commit is contained in:
Julien Duponchelle 2015-09-28 12:14:31 +02:00
parent 216aece030
commit a11b74132d
9 changed files with 206 additions and 1 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@ __pycache__
*.pyc
.venv
build
packer_cache
output-qemu

View File

@ -0,0 +1,40 @@
{
"qemu": {
"adapters": 1,
"arch": "x86_64",
"adapter_type": "e1000",
"ram": 32,
"console_type": "telnet"
},
"documentation_url": "http://wiki.alpinelinux.org",
"maintainer_email": "developers@gns3.net",
"versions": [
{
"images": {
"hda_disk_image": "alpine-linux-3.2.3.qcow2"
},
"name": "3.2.3"
}
],
"symbol": "linux_guest.svg",
"status": "experimental",
"category": "guest",
"registry_version": 1,
"usage": "User is root. Password is gns3",
"product_name": "Alpine Linux",
"images": [
{
"version": "3.2.3",
"download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/",
"direct_download_url": "http://downloads.sourceforge.net/project/gns-3/Qemu%20Appliances/alpine-linux-3.2.3.qcow2",
"md5sum": "b82d895ecba270ecc5e5b445ec53ee02",
"filesize": 143065088,
"filename": "alpine-linux-3.2.3.qcow2"
}
],
"vendor_name": "Alpine Linux Development Team",
"description": "Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.",
"maintainer": "GNS3 Team",
"name": "Alpine Linux",
"vendor_url": "http://alpinelinux.org"
}

View File

@ -54,6 +54,7 @@ def ask(question, type='string', optional=False):
sys.stdout.write(question + "(optional leave blank for skip) : ")
else:
sys.stdout.write(question + ": ")
sys.stdout.flush()
val = sys.stdin.readline().strip()
if len(val) == 0:
if optional:

37
packer/README.rst Normal file
View File

@ -0,0 +1,37 @@
Packer GNS3 appliance
=====================
This directory contain the packer build script
used for some appliance in the GNS3 registry.
For building an appliance please install packer:
https://packer.io/
And after run:
.. code:: bash
packer build template.json
If you want logs:
.. code:: bash
PACKER_LOG=1 packer build template.json
Conventions
************
User should be gns3 or root.
Password should be gns3.
Note for OSX users
******************
You need qemu with VNC support. If you are using homebrew you need to install it with:
.. code:: bash
brew install qemu --with-sdl

View File

@ -0,0 +1,47 @@
{
"builders":
[
{
"type": "qemu",
"iso_url": "http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.2/releases/x86_64/alpine-mini-3.2.3-x86_64.iso",
"iso_checksum": "a718c78537a0d416fa0b7cfcef1dfb85d1e837aa",
"iso_checksum_type": "sha1",
"shutdown_command": "poweroff",
"format": "qcow2",
"headless": false,
"ssh_username": "root",
"ssh_password": "gns3",
"vm_name": "alpine-linux",
"accelerator": "none",
"disk_interface": "ide",
"net_device": "e1000",
"disk_size": 5000,
"boot_wait": "120s",
"http_directory": "http",
"ssh_wait_timeout": "60m",
"boot_command":
[
"root<enter><wait>",
"echo \"root:gns3\" | chpasswd<enter>",
"ifconfig eth0 up && udhcpc -i eth0<enter><wait5>",
"setup-apkrepos -r<enter><wait5>",
"setup-sshd -c openssh<enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"script": "scripts/setup.sh"
},
{
"type": "shell",
"inline": [ "reboot" ]
},
{
"type": "shell",
"pause_before": "60s",
"script": "scripts/post_setup.sh"
}
]
}

View File

@ -0,0 +1,10 @@
#Enable a terminal on serial port
echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt1003" >> etc/inittab
apk add linux-virtgrsec
apk del linux-grsec
rm -Rf /lib/firmware
rm -rf /var/cache/apk/*
# Write 0
dd if=/dev/zero of=/zero ; rm -f /zero

View File

@ -0,0 +1,43 @@
#!/bin/sh
#
# Copyright (C) 2015 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
export KEYMAPOPTS="us us"
export HOSTNAMEOPTS="-n alpine"
export INTERFACESOPTS="
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp"
export TIMEZONEOPTS="-z UTC"
export PROXYOPTS="none"
export APKREPOSOPTS="-r"
export SSHDOPTS="-c openssh"
export NTPOPTS="-c none"
export SWAP_SIZE=0
# Answer to password question twice and yes to format drive
setup-alpine <<EOF
gns3
gns3
sda
sys
y
EOF

25
packer/compress_qcow2.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# Copyright (C) 2015 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
ls -lh "$1"
mv "$1" "${1}.backup"
qemu-img convert -O qcow2 "${1}.backup" "$1"
rm "${1}.backup"
echo "Compression OK"
ls -lh "$1"

View File

@ -74,7 +74,7 @@
},
"port_name_format": {
"type": "string",
"title": "Optional formating of the newtorking port example: eth{0}"
"title": "Optional formating of the networking port example: eth{0}"
},
"port_segment_size": {
"type": "integer",