commit message from python script

This commit is contained in:
2023-09-22 10:55:26 +02:00
parent 0f4e6fdb73
commit 0fea7eee0c

View File

@@ -3,10 +3,11 @@
import os, sys, subprocess import os, sys, subprocess
class nfs_server_conf: class nfs_server_conf:
def __init__(self, nfs_srv_folders = ["/nfsroot/publicnfs","/nfsroot/datennfs"]) -> None: def __init__(self, nfs_srv_folders = ["/nfsroot/publicnfs","/nfsroot/datennfs"], nfs_config_file = "/etc/exports") -> None:
if not os.geteuid()==0: if not os.geteuid()==0:
raise PermissionError("Sie sind kein Root") raise PermissionError("Sie sind kein Root")
self.nfs_srv_folders = nfs_srv_folders self.nfs_srv_folders = nfs_srv_folders
self.nfs_config_file = nfs_config_file
def mount_serverfolder(self): def mount_serverfolder(self):
for srv_folder in self.nfs_srv_folders: for srv_folder in self.nfs_srv_folders:
@@ -37,10 +38,22 @@ class nfs_server_conf:
def nfs_server_conf(self): def nfs_server_conf(self):
with open("/etc/exports",'r') as exportfs_file: folder_count = []
for exportfs_line in map(str(exportfs_file.readlines()).rstrip("\n")): for srv_folder in self.nfs_srv_folders:
print(exportfs_line) index_count = 0
#print(exportfs_line.rstrip("\n"), sep="") with open(self.nfs_config_file,'r') as exportfs_file:
exportfs_exist = []
print(srv_folder)
for exportfs_line in exportfs_file.readlines():
checkline = exportfs_line.rstrip("\n")[0:len(srv_folder)]
if checkline == srv_folder:
index_count += 1
folder_count.append({"folder_name": srv_folder, "count_exist":index_count})
for folder_counting in folder_count:
if folder_counting["count_exist"] > 0:
print(folder_counting["folder_name"], "ist vorhanden in", self.nfs_config_file )
def nfs_con_user(self): def nfs_con_user(self):