summaryrefslogtreecommitdiff
path: root/others/vm3
diff options
context:
space:
mode:
authorYour Name <you@example.com>2024-12-21 16:45:32 +0800
committerYour Name <you@example.com>2024-12-21 16:45:32 +0800
commite94b275f5630e032a6971831f8be520ae81a5d02 (patch)
treec6819daab6bceff1477647f40d52fa23f2c88628 /others/vm3
parentbe3dde6ce14698c5818f21f65037a4beef1199cf (diff)
v1vm3-done
Diffstat (limited to 'others/vm3')
-rwxr-xr-xothers/vm3/.config/init/make_rootkey.sh4
-rwxr-xr-xothers/vm3/compute/create.sh11
-rw-r--r--others/vm3/compute/start.sh4
-rwxr-xr-xothers/vm3/image/fedora.sh12
4 files changed, 20 insertions, 11 deletions
diff --git a/others/vm3/.config/init/make_rootkey.sh b/others/vm3/.config/init/make_rootkey.sh
index 5d07472..f725985 100755
--- a/others/vm3/.config/init/make_rootkey.sh
+++ b/others/vm3/.config/init/make_rootkey.sh
@@ -1,4 +1,4 @@
#!/bin/bash
-sudo mkdir -p ~/keys
-ssh-keygen -t ed25519 -f ~/keys/k1 -N ""
+sudo mkdir -p /root/k
+ssh-keygen -t ed25519 -f /root/k/k1 -N ""
diff --git a/others/vm3/compute/create.sh b/others/vm3/compute/create.sh
index 6d83a03..649cd86 100755
--- a/others/vm3/compute/create.sh
+++ b/others/vm3/compute/create.sh
@@ -14,6 +14,9 @@ disk_gb=$5
if [ $# -ne 5 ]; then
echo "Usage: $0 <vm-name> <os> <vcpu> <ram(gb)> <disk(gb)>"
echo "seed.iso and image file have to be present!"
+ echo ""
+ echo "Available images"
+ sudo ls /var/lib/libvirt/images/.image_store
exit 1
fi
@@ -41,20 +44,20 @@ fi
sudo virt-install --name $vmname \
--vcpus $vcpu \
--memory "$((ram_gb * 1024))"\
- --disk path=$new_vm_path,size=$disk_gb,format=qcow2 \
+ --disk path=$new_vm,format=qcow2 \
--disk path=$seed_iso,device=cdrom \
--os-type linux \
--os-variant $os \
--virt-type kvm \
--graphics none \
--network bridge=virbr0,model=virtio \
- --print-xml > $xml || { echo "Failed to print XML."; exit 1; }
+ --print-xml > $xml #|| { echo "Failed to print XML."; exit 1; }
-sudo virsh define $xml &> /dev/null || { echo "Failed to define the new VM."; exit 1; }
+sudo virsh define $xml #&> /dev/null || { echo "Failed to define the new VM."; exit 1; }
sudo qemu-img resize $new_vm +$disk_gb"G" #&> /dev/null
sudo virsh start $vmname
-sudo rm "${workingdir}"/*
+#sudo rm "${workingdir}"/*
diff --git a/others/vm3/compute/start.sh b/others/vm3/compute/start.sh
new file mode 100644
index 0000000..5a2b3aa
--- /dev/null
+++ b/others/vm3/compute/start.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# starts vm
+# need to remove seed.iso first if vm have the seed iso
diff --git a/others/vm3/image/fedora.sh b/others/vm3/image/fedora.sh
index 109f4fc..cd05e10 100755
--- a/others/vm3/image/fedora.sh
+++ b/others/vm3/image/fedora.sh
@@ -8,15 +8,16 @@
image_url="https://download.fedoraproject.org/pub/fedora/linux/releases/41/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2"
-sshkeysdir="/root/keys"
+sshkeysdir="/root/k"
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #&& echo $scriptdir
dir_path="/var/lib/libvirt/images/.image_store"
src_file="${dir_path}/fedora40.qcow2"
config_dir="/var/lib/libvirt/images/.temp"
-user_data="${config_dir}/user_data"
-meta_data="${config_dir}/meta_data"
+user_data="${config_dir}/user-data"
+meta_data="${config_dir}/meta-data"
seed_iso="${config_dir}/seed.iso"
+# note that cloud init specifically looks for "user-data" and "meta-data" in the seed.iso disk. do not deviate from the naming convention.
if [ $# -ne 1 ]; then
echo "Usage: $0 <vm-name>"
@@ -43,13 +44,14 @@ cat >> "$user_data" << 'EOF'
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: wheel
shell: /bin/bash
+ password: 123
runcmd:
- sudo growpart /dev/sda 1
- sudo xfs_growfs /
- sudo dnf install -y vim git
- cd /home/user
- - git clone https://git.0nom.ch/setup
- - sudo ./setup/setup.sh
+ - #git clone https://git.0nom.ch/setup
+ - #sudo ./setup/setup.sh
- touch /home/user/runcmd_done
EOF