Added mount-backup-shares wrapper
This commit is contained in:
parent
82827b7a0d
commit
77190137f6
2 changed files with 33 additions and 1 deletions
30
scripts/mount-backup-shares
Executable file
30
scripts/mount-backup-shares
Executable file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Wizard Kit: Mount Backup Shares"""
|
||||||
|
# pylint: disable=invalid-name
|
||||||
|
# vim: sts=2 sw=2 ts=2
|
||||||
|
|
||||||
|
import wk
|
||||||
|
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
def main():
|
||||||
|
"""Attempt to mount backup shares and print report."""
|
||||||
|
wk.std.print_info('Mounting Backup Shares')
|
||||||
|
report = wk.net.mount_backup_shares()
|
||||||
|
for line in report:
|
||||||
|
color = 'GREEN'
|
||||||
|
line = f' {line}'
|
||||||
|
if 'Failed' in line:
|
||||||
|
color = 'RED'
|
||||||
|
elif 'Already' in line:
|
||||||
|
color = 'YELLOW'
|
||||||
|
print(wk.std.color_string(line, color))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except SystemExit:
|
||||||
|
raise
|
||||||
|
except: #pylint: disable=bare-except
|
||||||
|
wk.std.major_exception()
|
||||||
|
|
@ -45,7 +45,7 @@ def mount_backup_shares(read_write=False):
|
||||||
report = []
|
report = []
|
||||||
for name, details in BACKUP_SERVERS.items():
|
for name, details in BACKUP_SERVERS.items():
|
||||||
mount_point = None
|
mount_point = None
|
||||||
mount_str = f'{name}/{details["Share"]}'
|
mount_str = f'//{name}/{details["Share"]}'
|
||||||
|
|
||||||
# Prep mount point
|
# Prep mount point
|
||||||
if platform.system() in ('Darwin', 'Linux'):
|
if platform.system() in ('Darwin', 'Linux'):
|
||||||
|
|
@ -57,6 +57,8 @@ def mount_backup_shares(read_write=False):
|
||||||
except OSError:
|
except OSError:
|
||||||
# Assuming permission denied under macOS
|
# Assuming permission denied under macOS
|
||||||
pass
|
pass
|
||||||
|
if mount_point:
|
||||||
|
mount_str += f' to {mount_point}'
|
||||||
|
|
||||||
# Check if already mounted
|
# Check if already mounted
|
||||||
if share_is_mounted(details):
|
if share_is_mounted(details):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue