Add command to check for asec vhost
This commit is contained in:
parent
2a1c098ab4
commit
904c69f80f
|
@ -0,0 +1,62 @@
|
|||
#! /usr/bin/env python
|
||||
#
|
||||
# w.c.s. (asec) - w.c.s. extension for poll & survey service
|
||||
# Copyright (C) 2010 Entr'ouvert
|
||||
#
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
from optparse import OptionParser
|
||||
import rfc822
|
||||
import pwd
|
||||
import grp
|
||||
|
||||
sys.path.append('/home/fred/src/eo/wcs')
|
||||
|
||||
from wcs import publisher
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
parser.add_option('--vhost', dest='vhost', help='virtual host (required)')
|
||||
parser.add_option('--uid', dest='uid')
|
||||
parser.add_option('--gid', dest='gid')
|
||||
options, args = parser.parse_args()
|
||||
|
||||
if not options.vhost:
|
||||
parser.error('you need to specify a virtual host')
|
||||
|
||||
pub = publisher.WcsPublisher.create_publisher()
|
||||
pub.app_dir = os.path.join(pub.app_dir, options.vhost)
|
||||
|
||||
if not os.path.exists(pub.app_dir):
|
||||
sys.exit(2)
|
||||
|
||||
uid, gid = tuple(os.stat(pub.app_dir)[4:6])
|
||||
if options.uid:
|
||||
if not pwd.getpwnam(options.uid).pw_uid == uid:
|
||||
sys.exit(3)
|
||||
|
||||
if options.gid:
|
||||
if not grp.getgrnam(options.gid).gr_gid == gid:
|
||||
sys.exit(4)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
2
setup.py
2
setup.py
|
@ -25,7 +25,7 @@ distutils.core.setup(
|
|||
maintainer_email = 'fpeters@entrouvert.com',
|
||||
package_dir = { 'extra': 'extra' },
|
||||
packages = ['extra', 'extra.modules'],
|
||||
scripts = ['create_asec_user.py'],
|
||||
scripts = ['create_asec_user.py', 'check_asec_vhost.py'],
|
||||
cmdclass = {'build_py': qx_build_py},
|
||||
data_files = ['asec-wcs-settings.xml'] + \
|
||||
data_tree('share/wcs/texts', 'texts') + \
|
||||
|
|
Reference in New Issue