From f8e1b44a937528418b2b86d768895471a0c0a383 Mon Sep 17 00:00:00 2001 From: Lyanis Souidi Date: Sat, 11 May 2024 20:30:37 +0200 Subject: [PATCH] Add scripts --- config/remove_subscription_warning.sh | 6 ++++++ vm/create_from_template.sh | 29 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 config/remove_subscription_warning.sh create mode 100644 vm/create_from_template.sh diff --git a/config/remove_subscription_warning.sh b/config/remove_subscription_warning.sh new file mode 100644 index 0000000..181e3d8 --- /dev/null +++ b/config/remove_subscription_warning.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Create backup and remove subscription warning from js file +sed -Ezi.bak "s/(function\(orig_cmd\) \{)/\1\n\torig_cmd\(\);\n\treturn;/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js + +systemctl restart pveproxy.service diff --git a/vm/create_from_template.sh b/vm/create_from_template.sh new file mode 100644 index 0000000..8b267d3 --- /dev/null +++ b/vm/create_from_template.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +INPUT_FILE=$1 + +if [ -z "$INPUT_FILE" ]; then + echo "Usage: $0 " + echo "Input file format:" + echo -e "\tusername pool_name" + echo -e "\tusername pool_name" + echo -e "\t..." + exit 1 +fi + +NEXT_VM_ID=202404101 + +TEMPLATE_VM_ID=202404001 + +while read -r line; do + USERNAME=$(echo "$line" | awk '{print $1}') + POOL_NAME=$(echo "$line" | awk '{print $2}') + + echo "Creating VM for $USERNAME ($POOL_NAME)" + + qm clone $TEMPLATE_VM_ID $NEXT_VM_ID --name "$USERNAME" --full false --pool $POOL_NAME + + pvesh set /access/acl --path /vms/$NEXT_VM_ID --roles PVEVMUser --users "$USERNAME@arda.lan" + + ((NEXT_VM_ID++)) +done < "$INPUT_FILE"