~usmteam/usm/usm_directory

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
#Ubuntu Server Manager
#Copyright (C) 2007 usmteam
#
#This file is part of Ubuntu Server Manager 
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


import commands
import os,sys

import logging
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(levelname)s %(message)s',
                    filename='/var/log/usm/backend/backend_wait.log',
                    filemode='w')


class plugin:
    def __init__(self,globals={}):
        pass
    
    def info(self):
        cmds="slapd_db",
        return cmds
    
    def handler(self,cmd,values):#0=success,1=error
        if cmd=="slapd_db":
            result=self.slapd_db(values)
        
    def run(self,cmd):
        print cmd
        return commands.getstatusoutput(cmd)
    
    def slapd_db(self,path):
        result=0
        if not os.path.exists(path):
            print "sudo mkdir "+path
            r=self.run("sudo mkdir "+path)
        print "sudo chown -R openldap:openldap "+path
        r=self.run("sudo chown -R openldap:openldap "+path)
        return result