diff --git a/munkiwebadmin/settings_template.py b/munkiwebadmin/settings_template.py index e06bfad..c8ef98d 100644 --- a/munkiwebadmin/settings_template.py +++ b/munkiwebadmin/settings_template.py @@ -170,7 +170,7 @@ if USE_LDAP: import ldap from django_auth_ldap.config import LDAPSearch, PosixGroupType - + # LDAP settings AUTH_LDAP_SERVER_URI = "ldap://foo.example.com" AUTH_LDAP_BIND_DN = "" @@ -183,7 +183,7 @@ ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)") AUTH_LDAP_GROUP_TYPE = PosixGroupType() AUTH_LDAP_FIND_GROUP_PERMS = True - AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", + AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "mail"} # Cache group memberships for an hour to minimize LDAP traffic @@ -228,16 +228,21 @@ # be sure to include trailing slash # for development work (Set DEBUG=True), you can set the ICONS_URL to MEDIA_URL. -# This is not recommended for production. +# This is not recommended for production. MEDIA_ROOT = os.path.join(MUNKI_REPO_DIR, 'icons') ICONS_URL = MEDIA_URL -# For production, you can point to your Munki server +# For production, you can point to your Munki server # if retrieving icons requires no special authentication # -- otherwise, you'll need some other static file server #ICONS_URL = "http://localhost/munki_repo/icons/" #ICONS_URL = "http://munki/repo/icons/" +# For suncing changesfrom the repositoty mwa2 uses to the remote server +# For this to work munki_repo/.git/config should have branch and remote configured. +# You should be able to manually run, 'git pull' and git 'git push' from the repo mwa2 is using +SYNC_REMOTE_REPO = False + # path to the makecatalogs binary MAKECATALOGS_PATH = '/usr/local/munki/makecatalogs' diff --git a/munkiwebadmin/utils.py b/munkiwebadmin/utils.py index 3e8d3ec..5748fa7 100644 --- a/munkiwebadmin/utils.py +++ b/munkiwebadmin/utils.py @@ -10,7 +10,7 @@ APPNAME = settings.APPNAME REPO_DIR = settings.MUNKI_REPO_DIR - +SYNC_REMOTE_REPO = settings.SYNC_REMOTE_REPO LOGGER = logging.getLogger('munkiwebadmin') try: @@ -56,6 +56,27 @@ def path_is_in_git_repo(self, a_path): self.run_git(['status', a_path]) return self.results['returncode'] == 0 + def sync_changes_to_repo(self): + LOGGER.info("Syncing changes...................") + os.chdir(REPO_DIR) + #get_branch_name = self.run_git(['symbolic-ref', '--short', 'HEAD']) + #branch_name = get_branch_name['output'].strip() + if self.results['returncode'] == 0: + # Pull changes + self.run_git(['pull']) + if self.results['returncode'] != 0: + LOGGER.info("Failed to pull changes") + LOGGER.info(self.results['error']) + return -1 + + # Push changes + self.run_git(['push']) + if self.results['returncode'] != 0: + LOGGER.info("Failed to push changes") + LOGGER.info(self.results['error']) + return -1 + return 0 + def commit_file_at_path(self, a_path, committer): """Commits the file at 'a_path'. This method will also automatically generate the commit log appropriate for the status of a_path where @@ -96,8 +117,14 @@ def commit_file_at_path(self, a_path, committer): LOGGER.info("Failed to commit changes to %s", a_path) LOGGER.info(self.results['error']) return -1 + + # if syncing has been set then sync with remote repo + if SYNC_REMOTE_REPO: + #sync changes + self.sync_changes_to_repo() return 0 + def add_file_at_path(self, a_path, committer): """Commits a file to the Git repo.""" if self.path_is_in_git_repo(a_path):