Ejemplo n.º 1
0
 def loadAuthorized(self):
     """Load all authorized users for FE from git."""
     config = getGitConfig()
     for user, userinfo in list(config['AUTH'].items()):
         self.allowedCerts.setdefault(userinfo['full_dn'], {})
         self.allowedCerts[userinfo['full_dn']]['username'] = user
         self.allowedCerts[
             userinfo['full_dn']]['permissions'] = userinfo['permissions']
Ejemplo n.º 2
0
def check_initialized(environ):
    """Env and configuration initialization."""
    global _INITIALIZED
    global _CP
    global _SITES
    if not _INITIALIZED:
        _CP = getGitConfig()
        _SITES += _CP['MAIN']['general']['sites']
        _INITIALIZED = True
Ejemplo n.º 3
0
        for service in [
                '/usr/sbin/httpd -k', 'LookUpService-update',
                'PolicyService-update', 'ProvisioningService-update'
        ]:
            print 'Stop %s' % service
            callCommand('%s start' % service)
        # Update crontab entries
        callCommand("crontab /etc/cron.d/siterm-crons")


def checkAutoUpdate(config):
    """ Check if auto update is enabled in configuration """
    autoupdate = True
    if 'autoupdate' in config['MAIN']['general'].keys():
        autoupdate = bool(config['MAIN']['general']['autoupdate'])
    if not autoupdate:
        print 'Auto Update disabled in configuration. Skipping auto update'
        return
    if config['MAPPING']['type'] == 'Agent':
        agentUpdater()
    elif config['MAPPING']['type'] == 'FE':
        feUpdater()
    else:
        print 'Unknown TYPE. Ignoring Auto Update.'


if __name__ == '__main__':
    CONFIG = getGitConfig()
    pprint.pprint(CONFIG)
    checkAutoUpdate(CONFIG)
Ejemplo n.º 4
0
   See the License for the specific language governing permissions and
   limitations under the License.
Title             : siterm
Author            : Justas Balcas
Email             : justas.balcas (at) cern.ch
@Copyright        : Copyright (C) 2020 California Institute of Technology
Date            : 2020/07/28
"""
import os
import pwd
import grp
from DTNRMLibs.MainUtilities import getGitConfig

DEFAULT_USERNAME = '******'
DEFAULT_GROUP = 'apache'

DEFAULT_GID = grp.getgrnam(DEFAULT_GROUP).gr_gid
DEFAULT_UID = pwd.getpwnam(DEFAULT_USERNAME).pw_uid

if __name__ == "__main__":
    gitConf = getGitConfig()
    for sitename in gitConf['MAIN']['general']['sites']:
        dbname = '/opt/config/%s/sqlite.db' % sitename
        if os.path.isfile(dbname):
            fstat = os.stat(dbname)
            username = pwd.getpwuid(fstat.st_uid).pw_name
            group = grp.getgrgid(fstat.st_gid).gr_name
            if username != DEFAULT_USERNAME or group != DEFAULT_GROUP:
                print 'Chowning database file. New Site? %s' % sitename
                os.chown(dbname, DEFAULT_UID, DEFAULT_GID)