aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-01-02 22:04:07 -0200
committerSilvio Rhatto <rhatto@riseup.net>2018-01-02 22:04:07 -0200
commit7441b792e197734b85f7c01a64397fb97a267128 (patch)
tree9e75019a3ed39e556a42d817c12605d29d2138f6
parent6207b570cf9bc67fb0988ce91f5c79e6430c0acc (diff)
downloadkvmx-7441b792e197734b85f7c01a64397fb97a267128.tar.gz
kvmx-7441b792e197734b85f7c01a64397fb97a267128.tar.bz2
Adds qcow2_compression config, use https://deb.debian.org/debian/ mirror when possible
-rwxr-xr-xkvmx11
-rwxr-xr-xkvmx-create26
-rw-r--r--kvmxfile5
-rwxr-xr-xshare/provision/development5
-rwxr-xr-xshare/provision/messenger2
5 files changed, 37 insertions, 12 deletions
diff --git a/kvmx b/kvmx
index 80fbcff..e4fedb8 100755
--- a/kvmx
+++ b/kvmx
@@ -1312,6 +1312,11 @@ function kvmx_restart {
echo "Guest $VM was not running, so starting it anyway..."
kvmx_start
else
+ #if [ "$ssh_support" != "y" ]; then
+ # echo sudo reboot | kvmx_ssh
+ # exit
+ #fi
+
echo "Powering off guest $VM..."
kvmx_poweroff
@@ -1616,11 +1621,15 @@ function kvmx_compress {
exit 1
fi
+ if [ "$qcow2_compression" != "0" ]; then
+ $compression = "-c"
+ fi
+
# Size before compression
local size_before_bytes="`du $image | awk '{ print $1 }'`"
local size_before_human="`du -h $image | awk '{ print $1 }'`"
- qemu-img convert -O qcow2 -p -c $image $image.new && mv $image.new $image || exit 1
+ qemu-img convert -O qcow2 -p $compression $image $image.new && mv $image.new $image || exit 1
# Size after compression
local size_after_bytes="`du $image | awk '{ print $1 }'`"
diff --git a/kvmx-create b/kvmx-create
index cdf3278..3071346 100755
--- a/kvmx-create
+++ b/kvmx-create
@@ -109,7 +109,7 @@ function kvmx_config {
kvmx_user_config domain example.org "Domain"
kvmx_user_config arch amd64 "System arch"
kvmx_user_config version stretch "Distro version"
- kvmx_user_config mirror http://http.debian.net/debian/ "Debian mirror"
+ kvmx_user_config mirror https://deb.debian.org/debian/ "Debian mirror"
kvmx_user_config ssh_support y "Administration using passwordless SSH (y/n)"
kvmx_user_config ssh_custom y "Setup a custom SSH keypair (y/n)"
kvmx_user_config user user "Initial user name"
@@ -124,6 +124,11 @@ function kvmx_config {
kvmx_user_config size 3G "Image size"
kvmx_user_config format qcow2 "Image format: raw or qcow2"
+
+ if [ "$format" == "qcow2" ]; then
+ kvmx_user_config qcow2_compression y "Image compression (y/n)"
+ fi
+
kvmx_user_config method custom "Bootstrap method: custom or vmdeboostrap"
kvmx_user_config bootloader grub "Bootloader: grub or extlinux"
}
@@ -155,6 +160,10 @@ function kvmx_create_vmdebootstrap {
# Image format
if [ "$format" == "qcow2" ]; then
format="--convert-qcow2"
+
+ if [ "$qcow2_compression" == "y" ]; then
+ compression="-c"
+ fi
fi
if [ "$booloader" == "grub" ]; then
@@ -208,6 +217,7 @@ function kvmx_create_custom {
fi
# Check for requirements.
+ #for req in debootstrap parted apt-transport-https; do
for req in debootstrap parted; do
kvmx_install_package $req
done
@@ -232,7 +242,7 @@ function kvmx_create_custom {
# Initial system install.
echo "Installing base system..."
kvmx_sudo_run LC_ALL=C DEBIAN_FRONTEND=noninteractive debootstrap \
- --arch=$arch $version $WORK/ $mirror
+ --force-check-gpg --arch=$arch $version $WORK/ $mirror
# Initial configuration.
echo "Applying initial configuration..."
@@ -288,11 +298,11 @@ function kvmx_create_custom {
$APT_INSTALL grub-pc
# Serial console support
- echo '' >> $WORK/etc/default/grub
- echo '# Custom configuration' >> $WORK/etc/default/grub
- echo 'GRUB_TERMINAL=serial' >> $WORK/etc/default/grub
- echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' >> $WORK/etc/default/grub
- echo 'GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"' >> $WORK/etc/default/grub
+ echo '' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo '# Custom configuration' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo 'GRUB_TERMINAL=serial' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo 'GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
kvmx_sudo_run chroot $WORK/ update-grub
kvmx_sudo_run chroot $WORK/ grub-install $device
@@ -336,7 +346,7 @@ EOF
if [ "$format" == "qcow2" ]; then
echo "Converting raw image to qcow2..."
kvmx_sudo_run mv $image $image.raw
- kvmx_sudo_run qemu-img convert -O qcow2 ${image}.raw $image
+ kvmx_sudo_run qemu-img convert -O qcow2 -p $compression ${image}.raw $image
kvmx_sudo_run rm ${image}.raw
fi
diff --git a/kvmxfile b/kvmxfile
index 9f2310a..5701f0d 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -105,6 +105,9 @@ size="10G"
# Image format: raw or qcow2
format="qcow2"
+# Image compression (qcow2 only)
+qcow2_compression="1"
+
# Bootstrap method: custom or vmdeboostrap
method="custom"
@@ -121,7 +124,7 @@ arch="amd64"
version="stretch"
# Debian mirror
-mirror="http://http.debian.net/debian/"
+mirror="https://deb.debian.org/debian/"
# Memory
memory="2048"
diff --git a/share/provision/development b/share/provision/development
index 0f44c07..0b477df 100755
--- a/share/provision/development
+++ b/share/provision/development
@@ -30,7 +30,10 @@ APT_INSTALL="sudo LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y"
cd
# Configuring APT
-sudo sed -i -e "s|main$|main contrib non-free|g" /etc/apt/sources.list || exit 1
+$APT_INSTALL apt-transport-https || exit 1
+sudo sed -i -e "s|http://http.debian.net|https://deb.debian.org|g" /etc/apt/sources.list || exit 1
+sudo sed -i -e "s|http://deb.debian.org|https://deb.debian.org|g" /etc/apt/sources.list || exit 1
+sudo sed -i -e "s|main$|main contrib non-free|g" /etc/apt/sources.list || exit 1
# Upgrade
if which hydractl &> /dev/null; then
diff --git a/share/provision/messenger b/share/provision/messenger
index 895b325..ceb178c 100755
--- a/share/provision/messenger
+++ b/share/provision/messenger
@@ -35,7 +35,7 @@ $APT_INSTALL curl apt-transport-https
# Setup Signal repository
#curl -s https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add -
sudo cp $DIRNAME/files/messenger/etc/apt/trusted.gpg.d/signal.org.gpg /etc/apt/trusted.gpg.d/
-echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee /etc/apt/sources.list.d/signal-xenial.list
+echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee /etc/apt/sources.list.d/signal-xenial.list > /dev/null
# Install Signal
sudo apt update && $APT_INSTALL signal-desktop