Skip to content

Commit

Permalink
Merge pull request #2109 from defmonk0/issue#2108_samba_config_trigger
Browse files Browse the repository at this point in the history
Enabling samba doesn't always trigger initial configuration dialog. Fixes #2108
  • Loading branch information
phillxnet authored Feb 11, 2020
2 parents 52b25dd + ddb875a commit ed99fcf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/rockstor/smart_manager/views/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
class ServiceMixin(object):

def _save_config(self, service, config):
service.config = json.dumps(config)
if config is not None:
service.config = json.dumps(config)
else:
service.config = None
return service.save()

def _get_config(self, service):
Expand Down
14 changes: 10 additions & 4 deletions src/rockstor/storageadmin/static/storageadmin/js/views/samba.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ SambaView = RockstorLayoutView.extend({
},

switchStatus: function(event, state) {
if (state) {
this.startService();
if (!this.service.get('config')) {
app_router.navigate('services/smb/edit', {
trigger: true,
});
} else {
this.stopService();
if (state) {
this.startService();
} else {
this.stopService();
}
}
},

Expand Down Expand Up @@ -214,4 +220,4 @@ SambaView = RockstorLayoutView.extend({
return new Handlebars.SafeString(html);
});
}
});
});
18 changes: 13 additions & 5 deletions src/rockstor/system/samba.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def rockstor_smb_config(fo, exports):
fo.write(' veto files = /.%s*/\n' % e.snapshot_prefix)
for cco in SambaCustomConfig.objects.filter(smb_share=e):
if (cco.custom_config.strip()):
fo.write(' %s\n' % cco.custom_config)
fo.write(' %s\n' % cco.custom_config)
fo.write('%s\n' % RS_SHARES_FOOTER)


Expand Down Expand Up @@ -180,7 +180,9 @@ def update_global_config(smb_config=None, ad_config=None):


def get_global_config():
config = {}
# start with config as None so it will return null elsewhere
# if no fields are added to it.
config = None
with open(SMB_CONFIG) as sfo:
global_section = False
global_custom_section = False
Expand All @@ -201,9 +203,9 @@ def get_global_config():
# we ignore lines outside [global], empty lines, or
# commends(starting with # or ;)
if ((not global_section or
not global_custom_section or
len(l.strip()) == 0 or
re.match('#', l) is not None or
not global_custom_section or
len(l.strip()) == 0 or
re.match('#', l) is not None or
re.match(';', l) is not None)):
continue
if (global_section and re.match('\[', l) is not None):
Expand All @@ -212,7 +214,13 @@ def get_global_config():
fields = l.strip().split(' = ')
if len(fields) < 2:
continue
# reset config to a usable dictionary since we're about to add
# something to it
if(config is None):
config = {}
config[fields[0].strip()] = fields[1].strip()
# return our config variable, which is either None, or a dictionary with
# fields inside of it
return config


Expand Down

0 comments on commit ed99fcf

Please sign in to comment.