Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- import os
- import sys
- def server_status():
- response = os.system("ping -c 1 192.168.1.106")
- if response == 0:
- return "UP"
- else:
- return "DOWN"
- user_input = str(sys.argv[1])
- ping_status = server_status()
- is_mounted = os.path.ismount("/mnt/NFS/plex")
- if user_input == "mount":
- if is_mounted:
- print("Already mounted silly Master!")
- else:
- if ping_status == "UP":
- os.system("sudo mount -t nfs4 192.168.1.10:/mnt/tank/data /mnt/NFS/data")
- os.system("sudo mount -t nfs4 192.168.1.10:/mnt/tank/plex /mnt/NFS/plex")
- os.system("sudo mount -t nfs4 192.168.1.10:/mnt/tank/backup /mnt/NFS/backup")
- os.system("sudo mount -t nfs4 192.168.1.10:/mnt/Torrents /mnt/NFS/Torrents")
- print("NFS Mounts have been connected. Master!")
- else:
- print("No connection to NFS server. Master!")
- if user_input == "unmount":
- if is_mounted:
- if ping_status == "UP":
- os.system("sudo umount /mnt/NFS/*")
- print("NFS Mounts have been disconnected!")
- else:
- os.system("sudo umount -l /mnt/NFS/*")
- print("NFS Mounts have been disconnected!")
- else:
- print("NFS Mounts are already disconnected. Master!")
Advertisement
Add Comment
Please, Sign In to add comment