mirror of
https://github.com/bashclub/zamba-lxc-toolbox.git
synced 2025-06-12 21:07:03 +02:00
Release 1.0
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
{
|
||||
"unprivileged": 0,
|
||||
"features": {},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "checkmk",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
CheckMK Monitoring Server
|
@ -1,121 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
from pathlib import Path
|
||||
import os
|
||||
import ipaddress
|
||||
import socket
|
||||
import json
|
||||
import subprocess
|
||||
from enum import Enum
|
||||
|
||||
def check_zfs_autosnapshot():
|
||||
proc = subprocess.Popen(["dpkg","-l","zfs-auto-snapshot"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
proc.communicate()
|
||||
if proc.returncode > 0:
|
||||
print ("'zfs-auto-snapshot' is NOT installed on your system. This ist required for 'previous versions' feature in Zamba containers.\nYou can install it with the following command:\n\tapt install zfs-auto-snapshot\n")
|
||||
input ("Press Enter to continue...")
|
||||
|
||||
# get_pve_bridges queries and returns availabe Proxmox bridges
|
||||
def get_pve_bridges():
|
||||
pve_bridges=[]
|
||||
ifaces=os.listdir(os.path.join("/","sys","class","net"))
|
||||
for iface in ifaces:
|
||||
if "vmbr" in iface:
|
||||
pve_bridges.append(iface)
|
||||
return pve_bridges
|
||||
|
||||
# get_pve_storages queries and returns available Proxmox bridges
|
||||
def get_pve_storages(driver=None,content=None):
|
||||
pve_storages={}
|
||||
cmd = ["pvesm","status","--enabled","1"]
|
||||
if content != None:
|
||||
cmd.extend(["--content",content.name])
|
||||
result = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
|
||||
stdout = result[0].decode("utf-8").split('\n')
|
||||
for line in filter(lambda x: len(x)>0, stdout):
|
||||
if not "Status" in line:
|
||||
item = [x for x in line.split(' ') if x.strip()]
|
||||
storage = {}
|
||||
storage["driver"] = item[1]
|
||||
storage["status"] = item[2]
|
||||
storage["total"] = item[3]
|
||||
storage["used"] = item[4]
|
||||
storage["available"] = item[5]
|
||||
storage["percent_used"] = item[6]
|
||||
|
||||
if driver == None:
|
||||
pve_storages[item[0]] = storage
|
||||
else:
|
||||
if driver.name == storage["driver"]:
|
||||
pve_storages[item[0]] = storage
|
||||
|
||||
return pve_storages
|
||||
|
||||
# get_zmb_services queries and returns available Zamba services
|
||||
def get_zmb_services():
|
||||
zmb_services={}
|
||||
for item in Path.iterdir(Path.joinpath(Path.cwd(),"src")):
|
||||
if Path.is_dir(item) and "__" not in item.name:
|
||||
with open(os.path.join(item._str, "info"),"r") as info:
|
||||
description = info.read()
|
||||
zmb_services[item.name] = description
|
||||
return zmb_services
|
||||
|
||||
# get_ct_id queries and returns the next available container id
|
||||
def get_ct_id(base="ct"):
|
||||
with open("/etc/pve/.vmlist","r") as v:
|
||||
vmlist_json = json.loads(v.read())
|
||||
ct_id = 100
|
||||
for cid in vmlist_json["ids"].keys():
|
||||
if int(cid) > ct_id and base == "ct" and vmlist_json["ids"][cid]["type"] == "lxc":
|
||||
ct_id = int(cid)
|
||||
elif int(cid) > ct_id and base == "all":
|
||||
ct_id = int(cid)
|
||||
while True:
|
||||
ct_id = ct_id + 1
|
||||
if ct_id not in vmlist_json["ids"].keys():
|
||||
break
|
||||
return ct_id
|
||||
|
||||
# validate_ct_id queries if ct_id is available and returns as boolean
|
||||
def validate_ct_id(ct_id:int):
|
||||
with open("/etc/pve/.vmlist","r") as v:
|
||||
vmlist_json = json.loads(v.read())
|
||||
ct_id = str(ct_id)
|
||||
if int(ct_id) >= 100 and int(ct_id) <= 999999999 and ct_id not in vmlist_json["ids"].keys():
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def validate_vlan(tag:int):
|
||||
if int(tag) >= 1 and int(tag) <= 4094:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_ct_features(zmb_service):
|
||||
with open(Path.joinpath(Path.cwd(),"src",zmb_service,"features.json")) as ff:
|
||||
return json.loads(ff.read())
|
||||
|
||||
|
||||
class PveStorageContent(Enum):
|
||||
images = 0
|
||||
rootdir = 1
|
||||
vztmpl = 2
|
||||
backup = 3
|
||||
iso = 4
|
||||
snippets = 5
|
||||
|
||||
class PveStorageType(Enum):
|
||||
zfspool = 0
|
||||
dir = 1
|
||||
nfs = 2
|
||||
cifs = 3
|
||||
pbs = 4
|
||||
glusterfs = 5
|
||||
cephfs = 6
|
||||
lvm = 7
|
||||
lvmthin = 8
|
||||
iscsi = 9
|
||||
iscsidirect = 10
|
||||
rbd = 11
|
||||
zfs = 12
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"unprivileged": 0,
|
||||
"features": {},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "debian",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Debian privileged container with basic tools
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"unprivileged": 1,
|
||||
"features": {
|
||||
"nesting": 1
|
||||
},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "debian",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Debian unprivileged container with basic tools
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"unprivileged": 1,
|
||||
"features": {
|
||||
"nesting": 1
|
||||
},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "piler",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Mailpiler email archive
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"unprivileged": 1,
|
||||
"features": {},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "matrix",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Matrix Synapse server with Element Web
|
73
src/menu.py
73
src/menu.py
@ -1,73 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
from enum import Enum
|
||||
from . import config_base
|
||||
|
||||
def radiolist(title:str,question:str,choices):
|
||||
invalid_input=True
|
||||
while(invalid_input):
|
||||
print(f"#### {title} ####\n")
|
||||
print(question)
|
||||
index = {}
|
||||
counter = 1
|
||||
if isinstance(choices,dict):
|
||||
for choice in choices.keys():
|
||||
if len(choice) <= 12:
|
||||
sep="\t\t"
|
||||
else:
|
||||
sep="\t"
|
||||
print(f"{counter}) {choice}{sep}{choices[choice]}")
|
||||
index[str(counter)] = choice
|
||||
counter = counter + 1
|
||||
elif isinstance(choices,list):
|
||||
for choice in choices:
|
||||
print(f"{counter}) {choice}")
|
||||
index[str(counter)] = choice
|
||||
counter = counter + 1
|
||||
else:
|
||||
print (f"object 'choices': {type(choices)} objects are unsupported.")
|
||||
selected = input("Type in number: ")
|
||||
if selected in index.keys():
|
||||
print("\n")
|
||||
return index[selected]
|
||||
|
||||
def question(title:str,q:str,returntype, default, validation=None):
|
||||
print(f"#### {title} ####\n")
|
||||
if str(returntype.name) == "Boolean":
|
||||
if default == True:
|
||||
suggest = "Y/n"
|
||||
else:
|
||||
suggest = "y/N"
|
||||
a = input(f"{q} [{suggest}]\n")
|
||||
if "y" in str(a).lower():
|
||||
return True
|
||||
elif "n" in str(a).lower():
|
||||
return False
|
||||
else:
|
||||
return default
|
||||
elif str(returntype.name) == "Integer":
|
||||
invalid_input = True
|
||||
while(invalid_input):
|
||||
a = input(f"{q} [{default}]\n")
|
||||
if str(a) == "" or f"{str(default)}" == str(a):
|
||||
return default
|
||||
else:
|
||||
try:
|
||||
valid = validation(int(a))
|
||||
if valid:
|
||||
return int(a)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
a = input(f"{q} [{default}]\n")
|
||||
if a == '':
|
||||
return default
|
||||
else:
|
||||
return a
|
||||
|
||||
|
||||
class qType(Enum):
|
||||
Boolean = 0
|
||||
Integer = 1
|
||||
String = 2
|
||||
IPAdress = 3
|
||||
CIDR = 4
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"unprivileged": 1,
|
||||
"features": {},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "open3a",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Open3A Server
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"unprivileged": 0,
|
||||
"features": {
|
||||
"nesting": 1
|
||||
},
|
||||
"sharefs": {},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "ad",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Zamba Active Directory Domain Controller
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"unprivileged": 0,
|
||||
"features": {},
|
||||
"sharefs": {
|
||||
"size": "100",
|
||||
"mountpoint": "/tank"
|
||||
},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "zamba",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Zamba AD Member Server
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"unprivileged": 0,
|
||||
"features": { },
|
||||
"sharefs": {
|
||||
"size": "100",
|
||||
"mountpoint": "/tank"
|
||||
},
|
||||
"mem": 1024,
|
||||
"swap": 1024,
|
||||
"hostname": "zamba",
|
||||
"domain": "zmb.rocks"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Zamba Standalone Server
|
Reference in New Issue
Block a user