diff options
| author | hc <hc@email.ch> | 2025-01-26 12:14:06 +0800 |
|---|---|---|
| committer | hc <hc@email.ch> | 2025-01-26 12:14:06 +0800 |
| commit | eabf5b889b42ac79c021a692c6bcdb74fafa5c15 (patch) | |
| tree | b4e7ab0de8706274af346323cac79d0d57e110c5 | |
| parent | ff7f42e5b89d6c1cf664ae866f29f790132a7da7 (diff) | |
update
| -rwxr-xr-x | core/vim.sh | 15 | ||||
| -rwxr-xr-x | others/vm3/.config/cloud-init-generator/debian12.sh | 4 | ||||
| -rw-r--r-- | others/vm3/.config/cloud-init-generator/rocky9.0.sh | 53 | ||||
| -rwxr-xr-x | others/vm3/compute/create.sh | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | port-forward/ssh-multiport-forward.sh | 0 | ||||
| -rwxr-xr-x | setup.sh | 4 |
6 files changed, 78 insertions, 2 deletions
diff --git a/core/vim.sh b/core/vim.sh index c350962..65378ec 100755 --- a/core/vim.sh +++ b/core/vim.sh @@ -34,6 +34,21 @@ endif colorscheme murphy "colorscheme zellner + +" Ctrl+A: Move to the beginning of the line in INSERT mode +inoremap <C-a> <Home> + +" Ctrl+E: Move to the end of the line in INSERT mode +inoremap <C-e> <End> + +" Ctrl+A: Move to the beginning of the line in NORMAL mode +nnoremap <C-a> 0 + +" Ctrl+E: Move to the end of the line in NORMAL mode +nnoremap <C-e> $ + + + EOF diff --git a/others/vm3/.config/cloud-init-generator/debian12.sh b/others/vm3/.config/cloud-init-generator/debian12.sh index de0751f..07c3fb7 100755 --- a/others/vm3/.config/cloud-init-generator/debian12.sh +++ b/others/vm3/.config/cloud-init-generator/debian12.sh @@ -49,6 +49,10 @@ else LS_COLORS=$LS_COLORS:'\''di=38;5;135:ex=00;32:'\'' ; export LS_COLORS PS1='\''[\[\033[01;32m\]\u\[\033[00m\]@\h \[\033[38;5;135m\]\W\[\033[00m\]]\$ '\'' EOF' \ + --run-command 'tee -a /home/user/.bashrc > /dev/null << "EOF" +LS_COLORS=$LS_COLORS:'\''di=38;5;135:ex=00;32:'\'' ; export LS_COLORS +PS1='\''[\[\033[01;32m\]\u\[\033[00m\]@\h \[\033[38;5;135m\]\W\[\033[00m\]]\$ '\'' +EOF' \ --run-command 'echo "sudo growpart /dev/vda 1 && sudo resize2fs /dev/vda1 && source /etc/bash.bashrc" > /home/user/start.sh && chmod +x /home/user/start.sh' && \ # Create flag file after successful customization diff --git a/others/vm3/.config/cloud-init-generator/rocky9.0.sh b/others/vm3/.config/cloud-init-generator/rocky9.0.sh new file mode 100644 index 0000000..c880206 --- /dev/null +++ b/others/vm3/.config/cloud-init-generator/rocky9.0.sh @@ -0,0 +1,53 @@ + +#!/bin/bash +# generates user data, meta data, and seed.iso for cloud init. for rocky +# requires the name of the vm as an argument +# +# osinfo-query os to list all available vm types to deploy. rocky is rocky9.0 or similar +image_url="https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.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}/rocky9.0.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 +runcmd: + - sudo systemctl enable --now serial-getty@ttyS0.service + - sudo growpart /dev/sda 1 + - sudo xfs_growfs / + - sudo dnf install -y vim git + - cd /home/user + - git clone https://git.0nom.ch/setup + - 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" + + diff --git a/others/vm3/compute/create.sh b/others/vm3/compute/create.sh index 3588db4..6d55fdc 100755 --- a/others/vm3/compute/create.sh +++ b/others/vm3/compute/create.sh @@ -6,7 +6,7 @@ # default values vcpu=8 ram_gb=8 -disk_gb=32 +disk_gb=64 os="fedora40" ostype="linux" @@ -91,7 +91,7 @@ fi # Define the disk options based on OS type if [ "$os" = "debian12" ]; then disk_opts="--disk path=${new_vm},format=qcow2" - virt-customize -a ${new_vm} --run-command "rm -f /etc/machine-id && systemd-machine-id-setup" + virt-customize -a ${new_vm} --run-command "rm -f /etc/machine-id ; systemd-machine-id-setup ; hostnamectl set-hostname ${vmname}" else disk_opts="--disk path=${new_vm},format=qcow2 --disk path=$seed_iso,device=cdrom" fi diff --git a/port-forward/ssh-multiport-forward.sh b/port-forward/ssh-multiport-forward.sh index 40d4ef6..40d4ef6 100644..100755 --- a/port-forward/ssh-multiport-forward.sh +++ b/port-forward/ssh-multiport-forward.sh @@ -20,6 +20,10 @@ sudo timedatectl set-timezone Asia/Singapore # then git clone work directory, or git clone altogether +sudo dnf install -y ncurses-term nc # nc for vim +echo "export TERM=xterm-256color" >> ~/.bashrc +source ~/.bashrc +tput colors # shld be 256 |
