-
Notifications
You must be signed in to change notification settings - Fork 3
/
.env
95 lines (83 loc) · 2.87 KB
/
.env
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
export QEMU_AUDIO_DRV=alsa
export GIT_PROJECT=kameleon
export ROOT_PROJECT=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
export KAMELEON_LOG=${KAMELEON_LOG:-"info"}
# enable kameleon autocompletion
source $ROOT_PROJECT/completion/kameleon.bash
QEMU_MONITOR_PORT=11023
function kameleon {
BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec kameleon "$@"
}
function devrun_chroot_clean() {
mount \
| grep rootfs | grep kameleon \
| py "s='rootfs'" "l=x.split(' ')[2].split(s)[0]" "print(l)" \
| uniq \
| xargs -I {} sudo bash "$ROOT_PROJECT"/contrib/scripts/umount-chroot.sh -p -f -a -k -y -c "{}"
}
function devrun_clear() {
KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/tmp/kameleon/"}
RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"}
devrun_chroot_clean
cd $KAMELEON_WORKDIR
kameleon clear $RECIPE_DEV_NAME.yaml
if [ -d "$KAMELEON_WORKDIR/build" ]; then
sudo rm "$KAMELEON_WORKDIR/build" -fr 2> /dev/null
fi
}
function devrun_qemu_stop() {
if nc -w 0 -z localhost $QEMU_MONITOR_PORT 2>/dev/null
then
echo "Shutting down qemu virtual machine"
echo "system_reset" | nc localhost $QEMU_MONITOR_PORT
echo ""
fi
while nc -w 0 -z localhost $QEMU_MONITOR_PORT
do
sleep 0.5
echo -n "."
done
echo " ~> OK"
}
function devrun_qemu() {
KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/tmp/kameleon/"}
RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"}
DRIVE="$KAMELEON_WORKDIR/build/$RECIPE_DEV_NAME/${RECIPE_DEV_NAME}.qcow2"
RAM_COUNT=2048
SPICE_PORT=5900
CPU_COUNT=2
sudo qemu-system-x86_64 \
-name "$VM_NAME" \
-machine pc-1.2,accel=kvm,usb=off -m 2048 -realtime mlock=off \
-smp $CPU_COUNT \
-drive file="$DRIVE",cache=none,media=disk,if=virtio,id=drive0 \
-m $RAM_COUNT \
-no-reboot \
-rtc base=utc \
-soundhw ac97 \
-net nic,model=virtio -net user \
-usb \
-usbdevice tablet \
-vga qxl \
-spice port=$SPICE_PORT,addr=127.0.0.1,disable-ticketing,image-compression=auto_lz \
-device virtio-serial-pci \
-device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
-chardev spicevmc,id=spicechannel0,name=vdagent \
-monitor tcp::$QEMU_MONITOR_PORT,server,nowait \
-daemonize
spicec -h 127.0.0.1 -p $SPICE_PORT --title "$VM_NAME" || :
devrun_qemu_stop
}
function devrun_build() {
KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/tmp/kameleon/"}
RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"}
TEMPLATE=${1:-"chroot/debian7"}
mkdir -p $KAMELEON_WORKDIR && cd $KAMELEON_WORKDIR
cmd="kameleon new $RECIPE_DEV_NAME $TEMPLATE \
&& kameleon build $RECIPE_DEV_NAME.yaml"
eval "$cmd"
if [ -d "$KAMELEON_WORKDIR/build/$RECIPE_DEV_NAME" ]; then
cd "$KAMELEON_WORKDIR/build/$RECIPE_DEV_NAME"
fi
}