-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkimage.debian
executable file
·46 lines (37 loc) · 1.39 KB
/
mkimage.debian
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
DST=$1
SIZE=$2
SRC=$3
if [ "$#" -lt 3 ]; then
echo "Usage: $0 <destination_image> <size> <cloud_image_source>"
exit 1
fi
. $(dirname $0)/functions.sh
set -ev
download_and_unpack "$SRC" "$DST.orig"
create_empty_image "$DST" "$SIZE"
copy_fs "$DST.orig" /dev/sda1 / "$DST" /dev/sda1 /
rm -f "$DST.orig"
gf_listen
gf add-drive "$DST"
gf run
gf mount /dev/sda1 /
gf write /etc/fstab "LABEL=cloudimg-rootfs / ext4 defaults,noatime,nodiratime 0 1
"
gf command "sed -i '/^GRUB_TIMEOUT=/ s/=.*/=1/' /etc/default/grub"
gf command "sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/=.*/=\"biosdevname=0 net.ifnames=0 systemd.show_status=true\"/' /etc/default/grub"
gf command "sed -i '/^GRUB_TIMEOUT_STYLE=/d' /etc/default/grub"
gf rm_f "/etc/default/grub.d/50-cloudimg-settings.cfg"
gf command "grub-install /dev/sda"
gf command "update-grub"
gf command "update-initramfs -u"
gf command "wget https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context_5.10.0-1.deb -O /one-context.deb"
gf command "apt-get purge -y cloud-init"
gf command "apt-get update"
gf sh "dpkg -i /one-context.deb || apt-get install -fy"
gf rm_f "/one-context.deb"
gf command "apt-get clean"
gf command "sed -i 's/#\\?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config"
gf command "sed -i 's/^PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config"
gf umount-all
gf exit