Inital commit
This commit is contained in:
9
Playground/testCTfile.sh
Normal file
9
Playground/testCTfile.sh
Normal 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
4
Playground/testCTloop.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
for CTID in $(pct list | tail -n+2 | awk '{print $1}'); do
|
||||
echo "Task for $CTID"
|
||||
done
|
||||
8
Playground/testCTloopExclude.sh
Normal file
8
Playground/testCTloopExclude.sh
Normal 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
15
Playground/testCTpkgm.sh
Normal 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
|
||||
20
Playground/testDetermineIfExists.sh
Normal file
20
Playground/testDetermineIfExists.sh
Normal 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
|
||||
9
Playground/testDetermineType.sh
Normal file
9
Playground/testDetermineType.sh
Normal 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
9
Playground/testVMfile.sh
Normal 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
4
Playground/testVMloop.sh
Normal 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
14
Playground/testVMpkgm.sh
Normal 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
|
||||
Reference in New Issue
Block a user