Skip to content

Commit

Permalink
package upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Apr 2, 2013
1 parent 5e8681f commit bfc35d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bh/defaults.py
Expand Up @@ -8,9 +8,9 @@
env.VIRTUALENV = "virtualenv-1.7"
env.REDMINE = "redmine-1.3.0"
env.PYTHON = "2.7.3"
env.APACHE = "httpd-2.2.22"
env.APACHE = "httpd-2.2.24"
env.MOD_WSGI = 'mod_wsgi-3.3'
env.SQLITE = 'sqlite-autoconf-3071502'
env.SQLITE = 'sqlite-autoconf-3071600'
env.APR = "apr-1.4.6"
env.DISTRIBUTE = "distribute-0.6.24"
env.PIP = "pip-1.0.2"
Expand Down
14 changes: 8 additions & 6 deletions bh/root.py
Expand Up @@ -3,7 +3,7 @@
import os
from fabric.api import *
from fabric.contrib.files import contains, exists
from bh.utils import _upload_template, setup_env_for_user
from bh.utils import _upload_template, setup_env_for_user, get_home_dir

@task
def du():
Expand Down Expand Up @@ -88,7 +88,8 @@ def user_create(admin, password='123'):
assert re.search(r"\%(group)s\b" % env, out) # check the user in pasport group

setup_env_for_user(admin)
user_setup( admin, password )
admin_home_dir = get_home_dir(admin)
user_setup( admin, password, admin_home_dir )

@task
def user_remove(admin):
Expand All @@ -100,14 +101,15 @@ def user_remove(admin):
run('rm -fr %(admin_home_dir)s' % env)

@task
def user_setup(admin, password='123'):
def user_setup(admin, password='123', home_dir=None):
""" reinitialize user environment homedir and password
"""
setup_env_for_user(admin)
with settings(pwd=crypt.crypt(password, ".sax/")):
setup_env_for_user(admin, home_dir)
home = home_dir or env.admin_home_dir
with settings(pwd=crypt.crypt(password, ".sax/"), home=home):
sudo('mkdir -p %(admin_home_dir)s' % env)
sudo('touch %(admin_home_dir)s/.scout' % env)
sudo('usermod -p "%(pwd)s" -g %(group)s -d %(admin_home_dir)s -s /bin/bash %(admin)s' % env)
sudo('usermod -p "%(pwd)s" -g %(group)s -d %(home)s -s /bin/bash %(admin)s' % env)
sudo('touch %(admin_home_dir)s/.scout' % env)
chown()

Expand Down
4 changes: 2 additions & 2 deletions bh/utils.py
Expand Up @@ -50,7 +50,7 @@ def get_env(name, default=None):
ret = run("echo $%s" % name)
return ret.strip() or default

def setup_env_for_user(admin=None):
def setup_env_for_user(admin=None, home_dir=None):
""" setup enviroment for the selected admin.
Must be called before each task.
"""
Expand All @@ -59,7 +59,7 @@ def setup_env_for_user(admin=None):
if admin is not None:
env.admin = admin
row = run('cat /etc/passwd | grep %s' % admin )
env.admin_home_dir = row.split(':')[5]
env.admin_home_dir = home_dir or row.split(':')[5]
else:
env.admin = env.user
env.admin_home_dir = get_env('HOME')
Expand Down

0 comments on commit bfc35d4

Please sign in to comment.