Advertisement
dabbill

Untitled

Jan 23rd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #! /usr/bin/python
  2.  
  3. import os.path
  4. import sys
  5. import subprocess
  6.  
  7. def server_status():
  8. response = os.system("ping -c 1 192.168.1.106")
  9. if response == 0:
  10. pingstatus = "UP"
  11. else:
  12. pingstatus = "DOWN"
  13.  
  14. return pingstatus
  15.  
  16. pingstatus = server_status()
  17.  
  18. is_mounted = os.path.ismount("/mnt/NFS/plex")
  19.  
  20. if is_mounted == True:
  21. print("Already mounted silly Master!")
  22. else:
  23. if pingstatus == "UP":
  24. os.system("sudo mount -t nfs4 -o timeo=10,_netdev,users 192.168.1.10:/mnt/tank/data /mnt/NFS/data")
  25. os.system("sudo mount -t nfs4 -o timeo=10,_netdev,users 192.168.1.10:/mnt/tank/plex /mnt/NFS/plex")
  26. os.system("sudo mount -t nfs4 -o timeo=10,_netdev,users 192.168.1.10:/mnt/tank/backup /mnt/NFS/backup")
  27. os.system("sudo mount -t nfs4 -o timeo=10,_netdev,users 192.168.1.10:/mnt/Torrents /mnt/NFS/Torrents")
  28.  
  29. print("NFS Mounts have been connected. Master!")
  30. elif is_mounted == False:
  31. print("Your NFS Mounts are already disconnected. Master!")
  32. else:
  33. os.system("sudo umount -l /mnt/NFS/plex")
  34. os.system("sudo umount -l /mnt/NFS/data")
  35. os.system("sudo umount -l /mnt/NFS/backup")
  36. os.system("sudo umount -l /mnt/NFS/Torrents")
  37.  
  38. print("NFS Mounts have been disconnected!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement