commit message from python script
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
import os, sys, subprocess
|
||||
|
||||
class nfs_server_conf:
|
||||
def __init__(self, nfs_srv_folders = ["/nfsroot/publicnfs","/nfsroot/datennfs"], nfs_config_file = "/etc/exports") -> None:
|
||||
def __init__(self, nfs_srv_folders = ["/nfsroot/publicnfs","/nfsroot/datennfs"], nfs_config_file = "/etc/exports", allow_network = "192.168.50.0/25") -> None:
|
||||
if not os.geteuid()==0:
|
||||
raise PermissionError("Sie sind kein Root")
|
||||
self.nfs_srv_folders = nfs_srv_folders
|
||||
self.nfs_config_file = nfs_config_file
|
||||
|
||||
self.allow_network = allow_network
|
||||
def mount_serverfolder(self):
|
||||
for srv_folder in self.nfs_srv_folders:
|
||||
unit_mount_file = "/etc/systemd/system/" + os.path.basename(srv_folder) + ".mount"
|
||||
@@ -26,7 +26,7 @@ class nfs_server_conf:
|
||||
print("""[Unit]\nDescription=Mount nfs Server Share\n[Mount]\nWhat={srv_folder}\nWhere={srv_point}\nType=None\nOptions=bind\n[Install]\nWantedBy=multi-user.target""".format(
|
||||
srv_folder=srv_folder,
|
||||
srv_point="/" + os.path.basename(srv_folder)), file=unit_file)
|
||||
if subprocess.run(['systemctl', 'daemon-reload']) .returncode == 0:
|
||||
if subprocess.run(['systemctl', 'daemon-reload']).returncode == 0:
|
||||
print("Systemed daemon-reload wurde ausgeführt")
|
||||
else:
|
||||
raise "Reloade konnte nicht ausgeführt werden."
|
||||
@@ -55,7 +55,7 @@ class nfs_server_conf:
|
||||
print(folder_counting["folder_name"], "ist vorhanden in", self.nfs_config_file )
|
||||
else:
|
||||
with open(self.nfs_config_file, 'a') as add_exportfile:
|
||||
print(folder_counting["folder_name"] + " ", file=add_exportfile)
|
||||
print(folder_counting["folder_name"], self.allow_network + "(rw,sync,insecure,root_squash,no_subtree_check)", file=add_exportfile)
|
||||
print(folder_counting["folder_name"], "ist NICHT vorhanden in", self.nfs_config_file )
|
||||
|
||||
def nfs_con_user(self):
|
||||
|
||||
Reference in New Issue
Block a user