fix vm build on Ubuntu 16.04
This commit is contained in:
parent
eeaeda3970
commit
e16310062b
2 changed files with 38 additions and 17 deletions
10
vm/build.sh
10
vm/build.sh
|
@ -10,6 +10,10 @@ if [ "$MIRROR" = "" ]; then
|
||||||
MIRROR="--mirror http://archive.ubuntu.com/ubuntu/"
|
MIRROR="--mirror http://archive.ubuntu.com/ubuntu/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e "$BASE/settings.sh" ]; then
|
||||||
|
. "$BASE/settings.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $(id -u) -ne 0 ]; then
|
if [ $(id -u) -ne 0 ]; then
|
||||||
echo "you need to run $0 as root"
|
echo "you need to run $0 as root"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -18,12 +22,18 @@ fi
|
||||||
# make sure ubuntu-archive-keyring is installed
|
# make sure ubuntu-archive-keyring is installed
|
||||||
test -e /usr/share/keyrings/ubuntu-archive-keyring.gpg || apt-get install ubuntu-archive-keyring
|
test -e /usr/share/keyrings/ubuntu-archive-keyring.gpg || apt-get install ubuntu-archive-keyring
|
||||||
|
|
||||||
|
vmdebootstrap=`vmdebootstrap --version`
|
||||||
|
if [[ $vmdebootstrap == "1.4" ]]; then
|
||||||
|
EXTRA=--no-systemd-networkd
|
||||||
|
fi
|
||||||
|
|
||||||
vmdebootstrap \
|
vmdebootstrap \
|
||||||
--image ${TARGET}.img \
|
--image ${TARGET}.img \
|
||||||
--size ${SIZE} \
|
--size ${SIZE} \
|
||||||
--sparse \
|
--sparse \
|
||||||
--distribution=${RELEASE} \
|
--distribution=${RELEASE} \
|
||||||
$MIRROR \
|
$MIRROR \
|
||||||
|
$EXTRA \
|
||||||
--enable-dhcp \
|
--enable-dhcp \
|
||||||
--no-serial-console \
|
--no-serial-console \
|
||||||
--no-kernel \
|
--no-kernel \
|
||||||
|
|
|
@ -2,46 +2,57 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
rootdir=$1
|
rootdir=$1
|
||||||
base=$(dirname $0)
|
BASE=$(dirname $0)
|
||||||
RELEASE=trusty
|
RELEASE=trusty
|
||||||
|
|
||||||
|
if [ -e "$BASE/settings.sh" ]; then
|
||||||
|
. "$BASE/settings.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOURCE_LIST="/etc/apt/sources.list.d/base.list"
|
||||||
|
if [ ! -e "$rootdir/$SOURCE_LIST" ]; then
|
||||||
|
SOURCE_LIST="/etc/apt/sources.list"
|
||||||
|
fi
|
||||||
|
|
||||||
cat > "$rootdir/root/pandora_install" << EOF
|
cat > "$rootdir/root/pandora_install" << EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DEBIAN_FRONTEND=noninteractive
|
DEBIAN_FRONTEND=noninteractive
|
||||||
sed -i "s/main/main restricted universe multiverse/g" /etc/apt/sources.list.d/base.list
|
sed -i "s/main\$/main restricted universe multiverse/g" $SOURCE_LIST
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y --force-yes dist-upgrade
|
apt-get -y --force-yes dist-upgrade
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
cat "$base/pandora_install.sh" >> "$rootdir/root/pandora_install"
|
cat "$BASE/pandora_install.sh" >> "$rootdir/root/pandora_install"
|
||||||
|
|
||||||
#reset install proxy settings
|
#reset install proxy settings
|
||||||
cat >> "$rootdir/root/pandora_install" <<EOF
|
cat >> "$rootdir/root/pandora_install" <<EOF
|
||||||
cat > /etc/apt/sources.list.d/base.list <<EOS
|
cat > $SOURCE_LIST <<EOS
|
||||||
deb http://archive.ubuntu.com/ubuntu $RELEASE main restricted universe multiverse
|
deb http://archive.ubuntu.com/ubuntu $RELEASE main restricted universe multiverse
|
||||||
deb-src http://archive.ubuntu.com/ubuntu $RELEASE main restricted universe multiverse
|
deb-src http://archive.ubuntu.com/ubuntu $RELEASE main restricted universe multiverse
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
apt-get -qq update
|
apt-get -qq update
|
||||||
sed -i \
|
sed -i \
|
||||||
-e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="silent"/g' \
|
-e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="silent"/g' \
|
||||||
/etc/default/grub
|
/etc/default/grub
|
||||||
update-grub
|
update-grub
|
||||||
|
rm -f /etc/init/pandora_install.conf /pandora_install
|
||||||
|
shutdown -h now
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x "$rootdir/root/pandora_install"
|
chmod +x "$rootdir/root/pandora_install"
|
||||||
|
|
||||||
test -e "$rootdir/etc/rc.local" && mv "$rootdir/etc/rc.local" "$rootdir/etc/rc.local.orig"
|
cat >> "$rootdir/pandora_install" <<EOF
|
||||||
cat > "$rootdir/etc/rc.local" <<EOF
|
#!/bin/bash
|
||||||
#!/bin/sh -e
|
/root/pandora_install >/root/pandora_install.log 2>&1 &
|
||||||
|
$INSTALL_EXTRA
|
||||||
#execute pandora_install
|
|
||||||
if [ -e /root/pandora_install ]; then
|
|
||||||
/root/pandora_install 2>&1 | tee /root/pandora_install.log || true
|
|
||||||
mv /root/pandora_install /root/pandora_installed
|
|
||||||
shutdown -h now
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
EOF
|
EOF
|
||||||
chmod +x "$rootdir/etc/rc.local"
|
chmod +x "$rootdir/pandora_install"
|
||||||
|
|
||||||
|
cat > "$rootdir/etc/init/pandora_install.conf" << EOF
|
||||||
|
description "install pan.do/ra"
|
||||||
|
start on (local-filesystems and net-device-up IFACE=eth0)
|
||||||
|
stop on [!12345]
|
||||||
|
task
|
||||||
|
exec /pandora_install
|
||||||
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue