commit message from python script
This commit is contained in:
41
install_nfsv4_share/nfs_server.py
Normal file
41
install_nfsv4_share/nfs_server.py
Normal file
@@ -0,0 +1,41 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import os, sys
|
||||
|
||||
class nfs_server_conf:
|
||||
def __init__(self, nfs_srv_folders = ["/nfsroot/publicnfs","/nfsroot/datennfs"]) -> None:
|
||||
if not os.geteuid()==0:
|
||||
raise PermissionError("Sie sind kein Root")
|
||||
self.nfs_srv_folders = nfs_srv_folders
|
||||
def create_serverfolder(self):
|
||||
for srv_folder in self.nfs_srv_folders:
|
||||
if os.path.exists(srv_folder):
|
||||
print(srv_folder,"ist bereits vorhanden !")
|
||||
else:
|
||||
os.makedirs(srv_folder, mode=1777)
|
||||
|
||||
def mount_serverfolder(self):
|
||||
for srv_folder in self.nfs_srv_folders:
|
||||
with open("/etc/systemd/system/" + os.path.basename(srv_folder) + ".mount", "w") as unit_file:
|
||||
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)
|
||||
|
||||
def nfs_server_conf(self):
|
||||
pass
|
||||
def nfs_con_user(self):
|
||||
pass
|
||||
def start_nfs_server(self):
|
||||
pass
|
||||
|
||||
def main(self):
|
||||
print("Erstelle Server Verzeichnise : ")
|
||||
nfs_server_conf.create_serverfolder(self)
|
||||
nfs_server_conf.mount_serverfolder(self)
|
||||
|
||||
def __str__(self) -> str:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
my_nfs_server = nfs_server_conf()
|
||||
my_nfs_server.main()
|
||||
Reference in New Issue
Block a user