still hacking

Jeffrey Paul 3 years ago
parent 13c28cad52
commit d96fa24bcf
  1. 31
  2. 2
  3. 21
  4. 28
  5. 66
  6. 5

@ -1,3 +1,28 @@
FROM ubuntu:bionic
ADD ./ /tmp/
RUN bash /tmp/ && rm /tmp/
FROM ubuntu:bionic as builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y \
libguestfs-tools \
bash \
libosinfo-bin \
libvirt-bin \
libvirt-clients \
qemu-user \
qemu-utils \
sudo \
RUN useradd -m user
RUN qemu-img create -f qcow2 /image.qcow2 100G
ADD . /home/user/
RUN chown user:user /*.qcow2 && chown user:user /home/user/* && chmod a+rwX /home/user/*
RUN sudo --login -u user /home/user/
ENTRYPOINT /bin/bash

@ -1,4 +1,4 @@
default: build
docker build .
docker build -t sneak/docker-linux-vm .

@ -0,0 +1,21 @@
function install_os() {
osinfo-query os
virsh list
virt-install --virt-type qemu --name linux \
--ram 4096 \
--disk path=/image.qcow2 \
--vcpus 4 \
--os-type linux \
--os-variant ubuntu18.04 \
--initrd-inject=preseed.cfg \ \
--graphics none \
--location '' \
--extra-args 'console=ttyS0,115200n8 serial'
virsh list
virsh console linux

@ -0,0 +1,28 @@
# This script is run by debian installer using preseed/late_command
# directive, see preseed.cfg
# Setup console, remove timeout on boot.
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"/g; s/TIMEOUT=5/TIMEOUT=0/g' /etc/default/grub
# Members of `sudo` group are not asked for password.
sed -i 's/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/g' /etc/sudoers
# Empty message of the day.
echo -n > /etc/motd
# Install collectd and config.
#apt-get install -y collectd-core
#cp /tmp/postinst/collectd.conf /etc/collectd/
export DEBIAN_FRONTEND=noninteractive
apt install -y vim
# Set domain name in hosts file
sed -i 's/\t\([a-z]*\).*/\tvm\t\1/' /etc/hosts
# Avoid using DHCP-server provided domain name.
#sed -i 's/#supersede.*/supersede domain-name "";/' /etc/dhcp/dhclient.conf

@ -0,0 +1,66 @@
# Preconfiguration file for jessie.
# For more details see
d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
# Choose an network interface that has link if possible.
d-i netcfg/choose_interface select auto
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
# Mirror settings.
d-i mirror/country string manual
d-i mirror/http/hostname string
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
# Root account setup. You can set password in plain-text or pre-encrypted.
d-i passwd/root-login boolean false
#d-i passwd/root-password password 98e1c23d2a5a2
#d-i passwd/root-password-again password 98e1c23d2a5a2
#d-i passwd/root-password-crypted password $6$1LCVFshS/kbYVg$M1QS1ZJ3.E7NkAD8sqkqhqExA2HWQ5/iDE.l23Xbr89Z7hTg/jUuBMyrYzANLmRybYcH8Smcy.yGDKMAX3okd0
# User account setup.
#d-i passwd/make-user boolean false
d-i passwd/user-fullname string user
d-i passwd/username string user
d-i passwd/user-password password password
d-i passwd/user-password-again password password
#d-i passwd/user-password-crypted password $6$dU9we2Mm$Btq1Tk1WkFx3/8YsXWbZr13m56uv0PabJKxk5teKAImLLQhtniOURXuOVLmbiBl0O3iS6xQBctNIc9Dn5b3vR.
# Password login is disabled.
d-i passwd/user-password-crypted password !
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# See the contents of /usr/share/zoneinfo/ for valid values.
d-i time/zone string UTC
# Controls whether to use NTP to set the clock during the install.
d-i clock-setup/ntp boolean true
# Simple non-LVM, all files in one partition.
# For more examples see
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# Do not install recommended packages by default.
d-i base-installer/install-recommends boolean false
tasksel tasksel/first multiselect
# Individual additional packages to install. acpid and acpi-support-base are required to make virsh shutdown to work.
# ACPI packages are needed for `virsh shutdown <domain>` to work.
d-i pkgsel/include string openssh-server ca-certificates acpid acpi-support-base
popularity-contest popularity-contest/participate boolean false
# Boot loader installation.
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string /dev/vda
# Run in /target just before the install finishes.
d-i preseed/late_command string cp postinst.tar.gz /target/tmp/ && chmod 755 /target/tmp/ && in-target /tmp/
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

@ -1,5 +0,0 @@
export DEBIAN_FRONTEND=noninteractive
apt update
apt install -y qemu-user