#!/bin/bash ## 0k git remote path GIT_0K_BASE=${GIT_0K_BASE:-"0k-ro:/var/git"} ## 0k git remote options GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""} ## ## Install 0k-manage ## mkdir -p /opt/apps ( if ! [ -d "/opt/apps/0k-manage" ]; then cd /opt/apps && git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" && cd /opt/apps/0k-manage && git checkout 0k/prod/master fi ) ## ## Install 0k-charms ## ( if ! [ -d "/opt/apps/0k-charms" ]; then cd /opt/apps && git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-charms.git" && cd /opt/apps/0k-charms && git checkout master fi if ! [ -d "/srv/charm-store" ]; then mkdir -p /srv/charm-store && find /opt/apps/0k-charms -type d -exec /usr/bin/test -e {}/metadata.yml \ -o -e {}/metadata.yaml \; -print | while read f; do ln -sf "$f" /srv/charm-store/ done fi ) ## ## Install lxc-scripts ## ( if ! [ -d "/opt/apps/lxc-scripts" ]; then cd /opt/apps && git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/lxc-scripts.git" && cd /opt/apps/0k-manage && git checkout master && ln -sf /opt/apps/lxc-scripts/bin/lxc-* /usr/local/sbin/ && [ -d /usr/lib/lxc/templates ] && { ln -sf /opt/apps/lxc-scripts/usr/lib/lxc/templates/lxc-0k-ubuntu-cloud /usr/lib/lxc/templates/ echo TEMPLATE_PATH=/usr/lib/lxc/templates >> /etc/default/lxc } [ -d /usr/share/lxc/templates ] && { ln -sf /opt/apps/lxc-scripts/usr/lib/lxc/templates/lxc-0k-ubuntu-cloud /usr/share/lxc/templates echo TEMPLATE_PATH=/usr/share/lxc/templates >> /etc/default/lxc } fi )