Skip to content

Commit

Permalink
Added owncloud, new config element for gestion server
Browse files Browse the repository at this point in the history
  • Loading branch information
the-glu committed Oct 30, 2013
1 parent 4fca433 commit d42e457
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To be used with azimut-gestion tool !

Copy `config.py.dist` to `config.py` and edit values if needed.

Some scripts except configuration files (for vim, zsh, etc.), who should be in the `AZIMUT_CONFIG` folder. You can find our files (https://github.com/Azimut-Prod/azimut-config)[here].
Some scripts except configuration files (for vim, zsh, etc.), who should be in the `AZIMUT_CONFIG` folder. You can find our files [here](https://github.com/Azimut-Prod/azimut-config).

## Scripts available

Expand Down
4 changes: 3 additions & 1 deletion config.py.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SSH_KEY = '~/.ssh/id_rsa'

AZIMUT_CONFIG = '../azimut-config/'
AZIMUT_CONFIG = '../azimut-config/'

GESTION_ADDRESS = '<gestion_adresse>'
2 changes: 1 addition & 1 deletion files/updateKeys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SERVER='%(server)s'
USERS="%(users)s"

baseURL='http://XXX/keymanager/servers/getKeys/'
baseURL='http://%(gestion_adresse)s/keymanager/servers/getKeys/'

for usr in $USERS; do

Expand Down
62 changes: 35 additions & 27 deletions owncloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,60 @@
#import time
#import config

import server


@task
def setup_owncloud():
"""Install a new owncloud server"""
"""Install a new owncloud server"""

execute(server.install_sudo)
execute(server.upgrade)
execute(setup_repo)
execute(install)
execute(configure_locale)
execute(configure_apache)

execute(setup_repo)
execute(install)
execute(configure_locale)
execute(configure_apache)

@task
def setup_repo():
"""Setup the owncloud repository"""
"""Setup the owncloud repository"""

sudo("echo 'deb http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/ /' >> /etc/apt/sources.list.d/owncloud.list")
sudo("wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key -O - | apt-key add -")
sudo("apt-get -y update")

sudo("echo 'deb http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/ /' >> /etc/apt/sources.list.d/owncloud.list")
sudo("wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key -O - | apt-key add -")
sudo("apt-get -y update")

@task
def install():
"""Install the owncloud package and his depencencies"""
sudo("apt-get -y install apache2 php5 php5-gd php-xml-parser php5-intl php5-mysql smbclient curl libcurl3 php5-curl owncloud")
"""Install the owncloud package and his depencencies"""
sudo("apt-get -y install apache2 php5 php5-gd php-xml-parser php5-intl php5-mysql smbclient curl libcurl3 php5-curl owncloud")


@task
def configure_locale():
"""Configure locales for VM without"""
sudo("echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen")
sudo("locale-gen")
"""Configure locales for VM without"""
sudo("echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen")
sudo("locale-gen")


@task
def configure_apache():
"""Configure apache to work with owncloud"""
"""Configure apache to work with owncloud"""

# Disable default site
sudo("a2dissite 000-default")
# Disable default site
sudo("a2dissite 000-default")

# Enable needed apache modules
sudo("a2enmod rewrite")
sudo("a2enmod headers")
sudo("a2enmod ssl")
# Enable needed apache modules
sudo("a2enmod rewrite")
sudo("a2enmod headers")
sudo("a2enmod ssl")

# Copy config
put('files/owncloud/owncloud.conf', '/etc/apache2/sites-available/')
# Copy config
put('files/owncloud/owncloud.conf', '/etc/apache2/sites-available/')

# Enable site
sudo("a2ensite owncloud.conf")
# Enable site
sudo("a2ensite owncloud.conf")

# Restart apache
sudo("service apache2 restart")
# Restart apache
sudo("service apache2 restart")
15 changes: 11 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def upgrade():
sudo("apt-get upgrade -y")
sudo("apt-get dist-upgrade -y")


@task
def install_sudo():
"""Install the sudo programm. Need to be runned with root"""
Expand All @@ -35,6 +36,7 @@ def reboot():
x -= 1
sudo("reboot")


@task
def shutdown():
"""Shutdown a machine"""
Expand All @@ -57,6 +59,7 @@ def copy_key_manager():
upload_template('files/updateKeys.sh', '/root/updateKeys.sh', {
'server': env.keymanagerName,
'users': env.keyManagerUsers,
'gestion_adresse': config.GESTION_ADDRESS,
}, use_sudo=True)

sudo("chmod +x /root/updateKeys.sh")
Expand All @@ -67,7 +70,7 @@ def cron_key_manager():
"""Install the crontab for the keymanagement"""
sudo('touch /tmp/crondump')
with settings(warn_only=True):
sudo('crontab -l > /tmp/crondump')
sudo('crontab -l > /tmp/crondump')
sudo('echo " 42 * * * * /root/updateKeys.sh" >> /tmp/crondump')
sudo('crontab /tmp/crondump')

Expand Down Expand Up @@ -96,6 +99,7 @@ def copy_config():
put(config.AZIMUT_CONFIG + '/.screenrc', '~')
put(config.AZIMUT_CONFIG + '/.zshrc', '~')


@task
def copy_user_config():
"""Copy the config for a user [$AG:NeedUser]"""
Expand All @@ -120,19 +124,22 @@ def switch_shell_to_zsh():
"""Change the shell to ZSH"""
run('chsh -s /bin/zsh')


@task
def install_rsync():
"""Install rsync"""
sudo("apt-get install rsync")


@task
def add_gestion_for_self_vms():
"""Add a host for it2d vm so they can access the server [$AG:NeedGestion]"""
"""Add a host for gestion vm so they can access the server even if on the same server [$AG:NeedGestion]"""

if not hasattr(env, 'gestion_ip') or env.gestion_ip == '':
return
return
sudo('echo "' + env.gestion_ip + ' ' + env.gestion_name + '" >> /etc/hosts')



@task
def setup():
"""Setup a new server [$AG:NeedKM][$AG:NeedGestion]"""
Expand Down

0 comments on commit d42e457

Please sign in to comment.