Changeset 5245


Ignore:
Timestamp:
Jun 21, 2017, 1:15:19 PM (18 months ago)
Author:
Juanma
Message:

fix owner of folders when restoring a moodle backup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • n4d-backup-manager/trunk/fuentes/n4d-backup-manager.install/usr/share/n4d/python-plugins/MoodleManager.py

    r2194 r5245  
     1import pwd
     2import grp
     3import os
    14import imp
    25backupmanager=imp.load_source("BackupManager","/usr/share/n4d/python-plugins/support/BackupManager.py")
     
    1720                self.moodle.set_backup_name("MoodleManager")
    1821                retVal=self.moodle.restore(file_path)
     22                self._last_actions('remove')
    1923                return retVal
    2024
     
    2327                retVal=self.moodle.backup(dir)
    2428                return retVal
     29
     30        def _last_actions(self,action):
     31                if action=='restore':
     32                        folders_to_del=['/var/lib/moodle/cache','/var/lib/moodle/localcache','/var/lib/moodle/sessions']
     33                        for folder in folders_to_del:
     34                                if os.path.exists(folder):
     35                                        shutil.rmtree(folder, ignore_errors=True)
     36                        uid = pwd.getpwnam("www.data'").pw_uid
     37                        gid = grp.getgrnam("www-data").gr_gid
     38                        folders_to_chown=moodleDirs['moodle']
     39                        for folder in folders_to_chown:
     40                                os.chown(folder, uid, gid)
     41
Note: See TracChangeset for help on using the changeset viewer.