-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-ch.sh
More file actions
executable file
·69 lines (49 loc) · 1.73 KB
/
setup-ch.sh
File metadata and controls
executable file
·69 lines (49 loc) · 1.73 KB
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
#!/bin/bash
# Simple Firecracker Binary Download Script
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
if [ "$EUID" != 0 ]; then
log_error "Plese run this file with sudo"
exit 1
fi
# Get architecture
ARCH="$(uname -m)"
# Validate architecture
if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then
log_error "Unsupported architecture: $ARCH"
log_error "ch supports x86_64 and aarch64 only"
exit 1
fi
log_info "Detected architecture: $ARCH"
log_info "Downloading latest ch binary..."
release_url="https://github.com/cloud-hypervisor/cloud-hypervisor/releases"
latest=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
if [ $ARCH = "x86_64" ]
then
wget ${release_url}/download/${latest}/cloud-hypervisor-static
mv cloud-hypervisor-static cloud-hypervisor
else
wget ${release_url}/download/${latest}/cloud-hypervisor-static-${ARCH}
mv cloud-hypervisor-static-${ARCH} cloud-hypervisor
fi
chmod +x ./cloud-hypervisor
sudo setcap cap_net_admin+ep ./cloud-hypervisor
log_info "Downloading ubuntu img..."
wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
log_info "Convert img to raw..."
qemu-img convert -p -f qcow2 -O raw focal-server-cloudimg-amd64.img focal-server-cloudimg-amd64.raw
log_info "Download latest firmware..."
release_url="https://github.com/cloud-hypervisor/rust-hypervisor-firmware/releases"
latest=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
wget ${release_url}/download/${latest}/hypervisor-fw
log_info "Downloading mcopy and mkdosfs..."
sudo apt install mtools dosfstools -y