Inital commit

This commit is contained in:
2022-04-15 22:42:28 +02:00
commit f58f6a2953
13 changed files with 348 additions and 0 deletions

9
Playground/testCTfile.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
CTID=100
#CTID=$1
FILE=/opt/test
if pct exec $CTID -- test -f $FILE ; then
echo "File exists in $CTID"
else
echo "File does not exist in $CTID."
fi

4
Playground/testCTloop.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
for CTID in $(pct list | tail -n+2 | awk '{print $1}'); do
echo "Task for $CTID"
done

View File

@@ -0,0 +1,8 @@
#!/bin/bash
ExcludeList=(100 900)
for CTID in $(pct list | tail -n+2 | awk '{print $1}'); do
if [[ "${ExcludeList[*]}" =~ $CTID ]]; then continue; fi
echo "Task for $CTID"
done

15
Playground/testCTpkgm.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
#CTID=$1
CTID=100
DIST=$(pct exec $CTID -- awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)
if [[ "${DIST}" == *"ubuntu"* ]] || [[ "${DIST}" == *"debian"* ]]; then
echo "Apt Detected"
elif [[ "${DIST}" == *"alpine"* ]]; then
echo "APK Detected"
#elif [[ "${DIST}" == *"centos"* ]]; then
# echo "DNF Detected"
else
echo "Package manager in not supported"
fi

View File

@@ -0,0 +1,20 @@
#!/bin/bash
ID=100
#ID=$1
VMS=$(qm list | tail -n+2 | awk '{print $1}')
CTS=$(pct list | tail -n+2 | awk '{print $1}')
EXISTINGIDS=(${CTS[@]} ${VMS[@]})
#for ExistingID in $(qm list | tail -n+2 | awk '{print $1}' &&pct list | tail -n+2 | awk '{print $1}'); do
for ExistingID in "${EXISTINGIDS[@]}"; do
echo $ExistingID
if [ $ExistingID -eq $ID ]; then
echo Exists
IdExists=true
break
fi
IdExists=false
done
if ! $IdExists; then echo "This ID does not exist"; exit; fi
echo end

View File

@@ -0,0 +1,9 @@
#!/bin/bash
ID=100
#ID=$1
VMS=$(qm list | tail -n+2 | awk '{print $1}')
CTS=$(pct list | tail -n+2 | awk '{print $1}')
#Determine id type
if [[ $VMS =~ $ID ]]; then TYPE=VM; fi
if [[ $CTS =~ $ID ]]; then TYPE=CT; fi
echo ID is $TYPE

9
Playground/testVMfile.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
#VMID=$1
VMID=101
FILE=/opt/test
if [ $(qm guest exec $VMID -- test -f $FILE |jq '.exitcode') == 0 ] ; then
echo "File exists in $VMID"
else
echo "File does not exist in $VMID."
fi

4
Playground/testVMloop.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
for VMID in $(qm list | tail -n+2 | awk '{print $1}'); do
echo "Task for $VMID"
done

14
Playground/testVMpkgm.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
#VMID=$1
VMID=100
DIST=$(qm guest exec $VMID -- awk -F= '$1=="ID" { print $2 ;}' /etc/os-release | jq '.["out-data"]')
if [[ "${DIST}" == *"ubuntu"* ]] || [[ "${DIST}" == *"debian"* ]]; then
echo "Apt Detected"
elif [[ "${DIST}" == *"alpine"* ]]; then
echo "APK Detected"
#elif [[ "${DIST}" == *"centos"* ]]; then
# echo "DNF Detected"
else
echo "Package manager in not supported"
fi