-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkimage.centos6
executable file
·44 lines (35 loc) · 1.24 KB
/
mkimage.centos6
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
#!/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 write /etc/mtab "/dev/sda1 / ext4 rw 0 0"
gf write /boot/grub/device.map "(fd0) /dev/fd0
(hd0) /dev/sda"
gf command "grub-install /dev/sda"
gf command "sed -i 's/root=[^ ]\\+/root=UUID=$(gf get-uuid /dev/sda1)/g' /boot/grub/grub.conf"
gf command "sed -i '/^\\(terminal\\|serial\\)/d' /boot/grub/grub.conf"
gf command "curl -L https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context-5.10.0-1.el6.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