Update alpine packer, add GUI

This commit is contained in:
Bernhard Ehlers 2020-08-03 12:27:15 +02:00
parent ac384b014a
commit 1d6f4634a1
10 changed files with 241 additions and 88 deletions

2
packer/alpine-linux/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
output-qemu
packer_cache

View File

@ -0,0 +1,28 @@
Packer for Alpine GNS3 appliance
================================
For building an Alpine appliance.
https://alpinelinux.org/
CLI Linux installation
**********************
The only added packages are:
* busybox-extras
* nano
.. code:: bash
packer build alpine_cli.json
GUI Linux installation
**********************
The GUI version has XFCE4 installed.
.. code:: bash
packer build alpine_gui.json

View File

@ -1,47 +0,0 @@
{
"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,68 @@
{
"variables": {
"iso_url": "http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.0-x86_64.iso",
"iso_checksum": "fe694a34c0e2d30b9e5dea7e2c1a3892c1f14cb474b69cc5c557a52970071da5",
"vm_name": "alpine_cli.qcow2",
"setup_script": "setup.sh",
"disk_size": "500"
},
"builders": [
{
"type": "qemu",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "sha256",
"shutdown_command": "poweroff",
"headless": true,
"ssh_username": "root",
"ssh_password": "root",
"vm_name": "{{user `vm_name`}}",
"disk_interface": "ide",
"disk_compression": true,
"net_device": "e1000",
"disk_size": "{{user `disk_size`}}",
"boot_wait": "20s",
"ssh_wait_timeout": "60s",
"boot_command": [
"root<enter><wait>",
"echo 'root:root' | chpasswd<enter>",
"ifconfig lo up<enter>",
"ifconfig eth0 up && udhcpc -i eth0<enter><wait10>",
"setup-sshd -c openssh<enter><wait>",
"sed -i.orig '$aPermitRootLogin yes' /etc/ssh/sshd_config<enter>",
"service sshd restart<enter><wait>"
]
}
],
"provisioners": [
{
"type": "shell",
"script": "scripts/install.sh"
},
{
"type": "shell",
"inline": [
"reboot"
]
},
{
"type": "shell",
"pause_before": "20s",
"inline": [
"apk upgrade --update-cache"
]
},
{
"type": "shell",
"script": "scripts/serial.sh"
},
{
"type": "shell",
"script": "scripts/{{user `setup_script`}}"
},
{
"type": "shell",
"script": "scripts/post_setup.sh"
}
]
}

View File

@ -0,0 +1,68 @@
{
"variables": {
"iso_url": "http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.0-x86_64.iso",
"iso_checksum": "fe694a34c0e2d30b9e5dea7e2c1a3892c1f14cb474b69cc5c557a52970071da5",
"vm_name": "alpine_gui.qcow2",
"setup_script": "setup.sh",
"disk_size": "1000"
},
"builders": [
{
"type": "qemu",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "sha256",
"shutdown_command": "poweroff",
"headless": true,
"ssh_username": "root",
"ssh_password": "root",
"vm_name": "{{user `vm_name`}}",
"disk_interface": "ide",
"disk_compression": true,
"net_device": "e1000",
"disk_size": "{{user `disk_size`}}",
"boot_wait": "20s",
"ssh_wait_timeout": "60s",
"boot_command": [
"root<enter><wait>",
"echo 'root:root' | chpasswd<enter>",
"ifconfig lo up<enter>",
"ifconfig eth0 up && udhcpc -i eth0<enter><wait10>",
"setup-sshd -c openssh<enter><wait>",
"sed -i.orig '$aPermitRootLogin yes' /etc/ssh/sshd_config<enter>",
"service sshd restart<enter><wait>"
]
}
],
"provisioners": [
{
"type": "shell",
"script": "scripts/install.sh"
},
{
"type": "shell",
"inline": [
"reboot"
]
},
{
"type": "shell",
"pause_before": "20s",
"inline": [
"apk upgrade --update-cache"
]
},
{
"type": "shell",
"script": "scripts/gui.sh"
},
{
"type": "shell",
"script": "scripts/{{user `setup_script`}}"
},
{
"type": "shell",
"script": "scripts/post_setup.sh"
}
]
}

View File

@ -0,0 +1,17 @@
# add community repository
sed -i 's/^#\(.*\/v.*\/community\)$/\1/' /etc/apk/repositories
apk update
# install packages
setup-xorg-base lxdm xfwm4 xfdesktop xfce4-appfinder xfce4-session xfce4-settings xfce4-terminal dillo thunar exo adwaita-icon-theme ttf-dejavu xf86-video-qxl
# configure packages
sed -i 's/^.*session=.*/session=\/usr\/bin\/startxfce4/' /etc/lxdm/lxdm.conf
echo "/sbin/poweroff" >> /etc/lxdm/PreShutdown
ln -s /usr/bin/dillo /usr/local/bin/firefox
rc-update add dbus
rc-update add lxdm
# create user account
adduser -D -g "Linux User" user
passwd -u user

View File

@ -0,0 +1,28 @@
#!/bin/sh
set -e
export HOSTNAMEOPTS="-n alpine"
export KEYMAPOPTS="us us"
export INTERFACESOPTS="auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
"
export TIMEZONEOPTS="-z UTC"
export PROXYOPTS="none"
export APKREPOSOPTS="-1"
export SSHDOPTS="-c openssh"
export NTPOPTS="-c none"
export BOOT_SIZE=50
export SWAP_SIZE=0
# Answer to password question twice and yes to format drive
setup-alpine <<EOF
root
root
sda
sys
y
EOF

View File

@ -1,10 +1,8 @@
#Enable a terminal on serial port
echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt1003" >> etc/inittab
# restore default sshd configuration
mv /etc/ssh/sshd_config.orig /etc/ssh/sshd_config
apk add linux-virtgrsec
apk del linux-grsec
rm -Rf /lib/firmware
# clear cache
rm -rf /var/cache/apk/*
# Write 0
dd if=/dev/zero of=/zero ; rm -f /zero
dd if=/dev/zero bs=1M of=/zero ; rm -f /zero

View File

@ -0,0 +1,5 @@
# use serial console
sed -i 's/\(APPEND .*\)/\1 console=ttyS0/' /boot/extlinux.conf
# autologin on serial console
sed -i 's/^#* *ttyS0.*/ttyS0::respawn:\/bin\/login -f root/' /etc/inittab

View File

@ -1,43 +1,29 @@
#!/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/>.
# install additional packages
apk add nano busybox-extras
set -e
# network configuration
cat > /etc/network/interfaces << EOF
#
# This is a sample network config, uncomment lines to configure the network
#
export KEYMAPOPTS="us us"
export HOSTNAMEOPTS="-n alpine"
export INTERFACESOPTS="
# Loopback interface
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
# Static config for eth0
#auto eth0
#iface eth0 inet static
# address 192.168.0.2
# netmask 255.255.255.0
# gateway 192.168.0.1
# up echo nameserver 192.168.0.1 > /etc/resolv.conf
# Answer to password question twice and yes to format drive
setup-alpine <<EOF
gns3
gns3
sda
sys
y
# DHCP config for eth0
# auto eth0
# iface eth0 inet dhcp
# hostname $(hostname)
EOF
cat > /etc/resolv.conf << EOF
EOF