-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkimage.centos8
executable file
·42 lines (34 loc) · 1.19 KB
/
mkimage.centos8
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
#!/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 "grub2-install /dev/sda"
gf command "sed -i 's/console=ttyS0,115200n8 //' /etc/default/grub"
gf command "grub2-mkconfig -o /boot/grub2/grub.cfg"
KERNEL="$(gf ls /lib/modules/ | head -n1)"
gf command "dracut -f /boot/initramfs-$KERNEL.img $KERNEL"
gf command "curl -L https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context-5.10.0-1.el8.noarch.rpm -o /one-context.rpm"
gf command "yum install -y epel-release"
gf command "yum install -y /one-context.rpm"
gf rm_f "/one-context.rpm"
gf command "yum clean all"
gf command "sed -i '/^SELINUX=/ s/=.*/=disabled/g' /etc/selinux/config"
gf command "sed -i 's/#\\?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config"
gf umount-all
gf exit