def install(self, env):
print 'Install the Tomcat Master.'
# Load the all configuration files
config = Script.get_config()
tomcat_user = config['configurations']['common-env']['user']
tomcat_group = config['configurations']['common-env']['group']
tomcat_home = config['configurations']['common-env']['catalina_home']
tomcat_package = os.path.join(os.path.dirname(__file__), '..', 'tomcat')
# Create user and group (if they don't exist)
try: grp.getgrnam(tomcat_group)
except KeyError: Execute(format('groupadd {tomcat_group}'))
try: pwd.getpwnam(tomcat_user)
except KeyError: Execute(format('adduser {tomcat_user} -g {tomcat_group}'))
Execute(format('mkdir -p {tomcat_home}'),
user=tomcat_user,
group=tomcat_group)
Execute(format('rm -r {tomcat_home}'))
#copy_tree(tomcat_package, tomcat_home)
#os.chown(tomcat_home, tomcat_user, tomcat_group)
os.system(format('cp -a {tomcat_package} {tomcat_home}'))
os.system(format('mkdir {tomcat_home}/logs'))
os.system(format('mkdir {tomcat_home}/work'))
os.system(format('chown {tomcat_user}:{tomcat_group} -R {tomcat_home}'))
os.system(format('chmod ug+x {tomcat_home}/bin/*.sh'))
uid = pwd.getpwnam(tomcat_user).pw_uid
gid = grp.getgrnam(tomcat_group).gr_gid
#copytree(tomcat_package, tomcat_home)
#os.chown(tomcat_package, uid, gid)
#Execute(format('cp -a {tomcat_package} {tomcat_home}'))
# Install packages
self.install_packages(env)
#Directory([tomcat_home],
# recursive=True)
#Execute('cp -r %s/* %s' % (tomcat_package, tomcat_home))
# Create a new user and group
#Execute( format("groupadd -f {tomcat_user}") )
#Execute( format("id -u {tomcat_user} &>/dev/null || useradd -s /bin/bash {tomcat_user} -g {tomcat_user}") )
### Continue installing and configuring your service
print 'Installation complete.'
master.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录