Fix mounting backup shares under Linux
This commit is contained in:
parent
51b6bd0fdf
commit
fa39c85fe4
2 changed files with 19 additions and 6 deletions
|
|
@ -308,18 +308,31 @@ def mount_network_share(server, read_write=False):
|
|||
error = r'Failed to mount \\{Name}\{Share} ({IP})'.format(**server)
|
||||
success = 'Mounted {Name}'.format(**server)
|
||||
elif psutil.LINUX:
|
||||
# Make mountpoint
|
||||
cmd = [
|
||||
'sudo', 'mkdir', '-p',
|
||||
'/Backups/{Name}'.format(**server)]
|
||||
run_program(cmd)
|
||||
|
||||
# Set mount options
|
||||
cmd_options = []
|
||||
cmd_options.append('rw' if read_write else 'ro')
|
||||
cmd_options.append('username={}'.format(username))
|
||||
if password:
|
||||
cmd_options.append('password={}'.format(password))
|
||||
else:
|
||||
# Skip password check
|
||||
cmd_options.append('guest')
|
||||
|
||||
# Set mount command
|
||||
cmd = [
|
||||
'sudo', 'mount',
|
||||
'//{IP}/{Share}'.format(**server),
|
||||
'//{IP}/{Share}'.format(**server).replace('\\', '/'),
|
||||
'/Backups/{Name}'.format(**server),
|
||||
'-o', '{}username={},password={}'.format(
|
||||
'' if read_write else 'ro,',
|
||||
username,
|
||||
password)]
|
||||
'-o', ','.join(cmd_options),
|
||||
]
|
||||
|
||||
# Set result messages
|
||||
warning = 'Failed to mount /Backups/{Name}, {IP} unreachable.'.format(
|
||||
**server)
|
||||
error = 'Failed to mount /Backups/{Name}'.format(**server)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ BACKUP_SERVERS = [
|
|||
{ 'IP': '10.120.1.23',
|
||||
'Name': 'Server1201',
|
||||
'Mounted': False,
|
||||
'Share': r'Public\Backups',
|
||||
'Share': r'Public\TEMP',
|
||||
'User': 'cx',
|
||||
'Pass': '',
|
||||
'RW-User': 'it',
|
||||
|
|
|
|||
Loading…
Reference in a new issue