dabbill

Untitled

Jan 27th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #! /usr/bin/env python3
  2. import os
  3. import sys
  4.  
  5.  
  6. def server_status():
  7. response = os.system("ping -c 1 192.168.1.106")
  8. if response == 0:
  9. return "UP"
  10. else:
  11. return "DOWN"
  12.  
  13.  
  14. user_input = str(sys.argv[1])
  15.  
  16. ping_status = server_status()
  17.  
  18. is_mounted = os.path.ismount("/mnt/NFS/plex")
  19.  
  20. if user_input == "mount":
  21. if is_mounted:
  22. print("Already mounted silly Master!")
  23. else:
  24. if ping_status == "UP":
  25. os.system("sudo mount -t nfs4 192.168.1.10:/mnt/tank/data /mnt/NFS/data")
  26. os.system("sudo mount -t nfs4 192.168.1.10:/mnt/tank/plex /mnt/NFS/plex")
  27. os.system("sudo mount -t nfs4 192.168.1.10:/mnt/tank/backup /mnt/NFS/backup")
  28. os.system("sudo mount -t nfs4 192.168.1.10:/mnt/Torrents /mnt/NFS/Torrents")
  29. print("NFS Mounts have been connected. Master!")
  30. else:
  31. print("No connection to NFS server. Master!")
  32.  
  33. if user_input == "unmount":
  34. if is_mounted:
  35. if ping_status == "UP":
  36. os.system("sudo umount /mnt/NFS/*")
  37. print("NFS Mounts have been disconnected!")
  38.  
  39. else:
  40. os.system("sudo umount -l /mnt/NFS/*")
  41. print("NFS Mounts have been disconnected!")
  42. else:
  43. print("NFS Mounts are already disconnected. Master!")
Advertisement
Add Comment
Please, Sign In to add comment