Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
[BUGFIX] Permissions are not applied
Browse files Browse the repository at this point in the history
- PB: Since we do not chown the original folder with the appropriate
user, the use of unison options `-numericids` and `-user` sync to root
now.
- FIX: remove these unison options (unison is running as the required
user). chown recursively the files after the initial sync
  • Loading branch information
mickaelperrin committed Jul 20, 2016
1 parent 18c958f commit 9600147
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions config_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Config:
config = {'volumes': {}}
supervisor_conf_folder = '/etc/supervisor.conf.d/'
unison_template_path = '/etc/supervisor.unison.tpl.conf'
unison_defaults = '-auto -batch -owner -numericids -repeat watch'
unison_defaults = '-auto -batch -repeat watch'

def read_yaml(self, config_file):
"""
Expand Down Expand Up @@ -68,12 +68,13 @@ def create_user(self, user, uid):
else:
print("user already exists")

def set_permissions(self, user, folder):
def set_permissions(self, user, folder, recursive=False):
"""
Set permissions to the folder
"""
args = ' -R ' if recursive else ''
if user != 'root':
os.system("chown " + user + " " + folder)
os.system("chown " + args + user + " " + folder)

def generate_ignore_string(self, ignores, sync_method='unison'):
"""
Expand Down Expand Up @@ -152,6 +153,7 @@ def initial_sync(self):
if 'volumes' in self.config:
for volume, conf in self.config['volumes'].iteritems():
os.system('tar -c -C ' + volume + '.magic ' + self.generate_ignore_string(conf['ignore'], 'tar') + ' . | tar -xC ' + volume)
self.set_permissions(conf['user'], volume, True)

def set(self, config_file):
if config_file:
Expand Down

0 comments on commit 9600147

Please sign in to comment.