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)
|
error = r'Failed to mount \\{Name}\{Share} ({IP})'.format(**server)
|
||||||
success = 'Mounted {Name}'.format(**server)
|
success = 'Mounted {Name}'.format(**server)
|
||||||
elif psutil.LINUX:
|
elif psutil.LINUX:
|
||||||
|
# Make mountpoint
|
||||||
cmd = [
|
cmd = [
|
||||||
'sudo', 'mkdir', '-p',
|
'sudo', 'mkdir', '-p',
|
||||||
'/Backups/{Name}'.format(**server)]
|
'/Backups/{Name}'.format(**server)]
|
||||||
run_program(cmd)
|
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 = [
|
cmd = [
|
||||||
'sudo', 'mount',
|
'sudo', 'mount',
|
||||||
'//{IP}/{Share}'.format(**server),
|
'//{IP}/{Share}'.format(**server).replace('\\', '/'),
|
||||||
'/Backups/{Name}'.format(**server),
|
'/Backups/{Name}'.format(**server),
|
||||||
'-o', '{}username={},password={}'.format(
|
'-o', ','.join(cmd_options),
|
||||||
'' if read_write else 'ro,',
|
]
|
||||||
username,
|
|
||||||
password)]
|
# Set result messages
|
||||||
warning = 'Failed to mount /Backups/{Name}, {IP} unreachable.'.format(
|
warning = 'Failed to mount /Backups/{Name}, {IP} unreachable.'.format(
|
||||||
**server)
|
**server)
|
||||||
error = 'Failed to mount /Backups/{Name}'.format(**server)
|
error = 'Failed to mount /Backups/{Name}'.format(**server)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ BACKUP_SERVERS = [
|
||||||
{ 'IP': '10.120.1.23',
|
{ 'IP': '10.120.1.23',
|
||||||
'Name': 'Server1201',
|
'Name': 'Server1201',
|
||||||
'Mounted': False,
|
'Mounted': False,
|
||||||
'Share': r'Public\Backups',
|
'Share': r'Public\TEMP',
|
||||||
'User': 'cx',
|
'User': 'cx',
|
||||||
'Pass': '',
|
'Pass': '',
|
||||||
'RW-User': 'it',
|
'RW-User': 'it',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue