diff options
| author | Your Name <you@example.com> | 2024-12-22 19:03:49 +0800 |
|---|---|---|
| committer | Your Name <you@example.com> | 2024-12-22 19:03:49 +0800 |
| commit | f7f159a04671690786de2f84e34046c103521d58 (patch) | |
| tree | 22b45e904c1aa6800250ec6e998d0022fd018ade /others/vm3/image | |
| parent | 2916e3eff503473f6bf8b90e0921b0ccd347166f (diff) | |
vm.shupdate
Diffstat (limited to 'others/vm3/image')
| -rwxr-xr-x | others/vm3/image/fedora.sh | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/others/vm3/image/fedora.sh b/others/vm3/image/fedora.sh deleted file mode 100755 index cd05e10..0000000 --- a/others/vm3/image/fedora.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -# generates user data, meta data, and seed.iso for cloud init. for fedora -# requires the name of the vm as an argument -# -# osinfo-query os to list all available vm types to deploy. fedora is fedora 40 - - -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/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" -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>" - exit 1 -fi - -sudo mkdir -p "$dir_path" -sudo mkdir -p "$config_dir" - -[ ! -f "$src_file" ] && echo "source image does not exist! downloading..." && sudo wget -O "$src_file" "$image_url" - -cat > "$user_data" << EOF -#cloud-config -users: - - name: user - ssh-authorized-keys: -EOF - -for key in $sshkeysdir/*.pub; do - echo " - $(cat "$key")" >> $user_data -done - -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 - - touch /home/user/runcmd_done -EOF - -cat > "$meta_data" << EOF -instance-id: vm_id -local-hostname: $1 -EOF - -genisoimage -output "$seed_iso" -volid cidata -joliet -rock "$user_data" "$meta_data" &> /dev/null || { echo "Failed to create seed.iso."; exit 1; } - -echo "Configuration files generated successfully" |
