Browse Source

new: [docker-host] change all install script to support update.

postgres
Valentin Lab 6 years ago
parent
commit
894bf065f9
  1. 2
      precise/base-0k/hooks/install.d/05-shyaml.sh
  2. 7
      precise/base-0k/hooks/install.d/15-etckeeper.sh
  3. 6
      precise/base-0k/hooks/install.d/30-customize.sh
  4. 12
      precise/base-0k/hooks/install.d/35-git-access.sh
  5. 16
      precise/base-0k/hooks/install.d/36-gitsub.sh
  6. 78
      precise/host/hooks/install.d/70-0k.sh

2
precise/base-0k/hooks/install.d/05-shyaml.sh

@ -4,4 +4,4 @@
apt-get install -y --force-yes python-pip libyaml-dev python-dev </dev/null apt-get install -y --force-yes python-pip libyaml-dev python-dev </dev/null
pip install shyaml
pip install shyaml --upgrade

7
precise/base-0k/hooks/install.d/15-etckeeper.sh

@ -10,8 +10,9 @@ set +eux
apt-get install -y etckeeper </dev/null apt-get install -y etckeeper </dev/null
sed -i 's/#VCS="git"/VCS="git"/g;s/VCS="bzr"/#VCS="bzr"/g' \
sed -i 's/^#VCS="git"/VCS="git"/g;s/^VCS="bzr"/#VCS="bzr"/g' \
/etc/etckeeper/etckeeper.conf /etc/etckeeper/etckeeper.conf
etckeeper init
if ! [ -f /etc/.git ]; then
etckeeper init
fi

6
precise/base-0k/hooks/install.d/30-customize.sh

@ -18,6 +18,12 @@ parse_git_branch() {
export PS1="\[\033[0;37m\][\[\033[1;30m\]\u\[\033[0;37m\]@\[\033[1;30m\]\H\[\033[0;37m\]]-[\[\033[1;34m\]\w\[\033[0;37m\]]\\\$(parse_git_branch)\n\[\033[1;37m\]\\$ \[\033[0;37m\]" export PS1="\[\033[0;37m\][\[\033[1;30m\]\u\[\033[0;37m\]@\[\033[1;30m\]\H\[\033[0;37m\]]-[\[\033[1;34m\]\w\[\033[0;37m\]]\\\$(parse_git_branch)\n\[\033[1;37m\]\\$ \[\033[0;37m\]"
EOF EOF
if [ -f /root/.bashrc.pre-install ]; then
cp /root/.bashrc.pre-install /root/.bashrc
else
cp /root/.bashrc /root/.bashrc.pre-install
fi
cat <<EOF >> /root/.bashrc cat <<EOF >> /root/.bashrc
## History management ## History management

12
precise/base-0k/hooks/install.d/35-git-access.sh

@ -12,8 +12,14 @@ SSH_CONFIG_DIR=~/.ssh
mkdir -p "$SSH_CONFIG_DIR" mkdir -p "$SSH_CONFIG_DIR"
if ! grep '^Host 0k-ro' "$SSH_CONFIG_DIR"/config >/dev/null 2>&1; then
cat <<EOF >> "$SSH_CONFIG_DIR"/config
if ! [ -e "$SSH_CONFIG_DIR/config.pre-install" ]; then
cp "$SSH_CONFIG_DIR/config" "$SSH_CONFIG_DIR/config.pre-install"
else
cp "$SSH_CONFIG_DIR/config.pre-install" "$SSH_CONFIG_DIR/config"
fi
cat <<EOF >> "$SSH_CONFIG_DIR"/config
Host 0k-ro Host 0k-ro
Hostname git.0k.io Hostname git.0k.io
@ -24,5 +30,3 @@ Host 0k-ro
StrictHostKeyChecking no StrictHostKeyChecking no
EOF EOF
fi

16
precise/base-0k/hooks/install.d/36-gitsub.sh

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eux # -x for verbose logging to juju debug-log
set -eux
## 0k git remote path ## 0k git remote path
@ -14,7 +14,13 @@ GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""}
## install git sub ## install git sub
## ##
mkdir -p /opt/apps &&
cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/git-sub &&
ln -sf /opt/apps/git-sub/bin/git-sub /usr/lib/git-core/
if [ -d /opt/apps/git-sub ]; then
cd /opt/apps/git-sub &&
git pull -r
else
mkdir -p /opt/apps &&
cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/git-sub
fi
ln -sf /opt/apps/git-sub/bin/git-sub /usr/lib/git-core/git-sub

78
precise/host/hooks/install.d/70-0k.sh

@ -15,7 +15,10 @@ GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""}
mkdir -p /opt/apps mkdir -p /opt/apps
( (
if ! [ -d "/opt/apps/0k-manage" ]; then
if [ -d "/opt/apps/0k-manage" ]; then
cd /opt/apps/0k-manage &&
git pull -r
else
cd /opt/apps && cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" && git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" &&
cd /opt/apps/0k-manage && cd /opt/apps/0k-manage &&
@ -48,20 +51,19 @@ mkdir -p /opt/apps
## ##
( (
if ! [ -d "/opt/apps/0k-charms" ]; then
cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-charms.git" &&
if [ -d "/opt/apps/0k-charms" ]; then
cd /opt/apps/0k-charms && cd /opt/apps/0k-charms &&
git checkout master
git checkout master &&
git pull -r
else
cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-charms.git"
fi fi
if ! [ -d "/srv/charm-store" ]; then 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
mkdir -p /srv/charm-store
fi fi
ln -sfn /opt/apps/0k-charms /srv/charm-store/0k-charms
) )
@ -73,19 +75,27 @@ mkdir -p /opt/apps
( (
if ! [ -d "/opt/apps/lxc-scripts" ]; then if ! [ -d "/opt/apps/lxc-scripts" ]; then
cd /opt/apps && cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/lxc-scripts.git" &&
cd /opt/apps/0k-manage &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/lxc-scripts.git"
fi
cd /opt/apps/lxc-scripts &&
git checkout master && git checkout master &&
ln -sf /opt/apps/lxc-scripts/bin/lxc-* /usr/local/sbin/ &&
git pull -r &&
ln -sfn /opt/apps/lxc-scripts/bin/lxc-* /usr/local/sbin/ &&
if [ -f /etc/default/lxc.pre-install ]; then
cp /etc/default/lxc.pre-install /etc/default/lxc
else
cp /etc/default/lxc /etc/default/lxc.pre-install
fi
[ -d /usr/lib/lxc/templates ] && { [ -d /usr/lib/lxc/templates ] && {
ln -sf /opt/apps/lxc-scripts/usr/lib/lxc/templates/lxc-0k-ubuntu-cloud /usr/lib/lxc/templates/
ln -sfn /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 echo TEMPLATE_PATH=/usr/lib/lxc/templates >> /etc/default/lxc
} }
[ -d /usr/share/lxc/templates ] && { [ -d /usr/share/lxc/templates ] && {
ln -sf /opt/apps/lxc-scripts/usr/lib/lxc/templates/lxc-0k-ubuntu-cloud /usr/share/lxc/templates
ln -sfn /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 echo TEMPLATE_PATH=/usr/share/lxc/templates >> /etc/default/lxc
} }
fi
) )
## ##
@ -94,19 +104,18 @@ mkdir -p /opt/apps
## Note that docker should be installed after (or be restarted). ## Note that docker should be installed after (or be restarted).
type -p curl >/dev/null 2>&1 || apt-get install -y curl </dev/null
apt-get install -y curl </dev/null
if ! [ -r /etc/ssl/ca.0k.io.pem ]; then
## This does not seem to work anymore (docker v1.12, ubutnu 14.04 on gani)
echo "Fetching 0k.io CA certificate..."
curl http://docker.0k.io/get/ca.0k.io.pem > /etc/ssl/ca.0k.io.pem
cat /etc/ssl/ca.0k.io.pem >> /etc/ssl/certs/ca-certificates.crt
## This does not seem to work anymore (docker v1.12, ubutnu 14.04 on gani)
echo "Fetching 0k.io CA certificate..."
curl http://docker.0k.io/get/ca.0k.io.pem > /etc/ssl/ca.0k.io.pem
cat /etc/ssl/ca.0k.io.pem >> /etc/ssl/certs/ca-certificates.crt
## This is the new way: https://docs.docker.com/engine/security/certificates/
mkdir -p /etc/docker/certs.d/docker.0k.io
ln -sfn /etc/ssl/ca.0k.io.pem /etc/docker/certs.d/docker.0k.io/ca.crt
## This is the new way: https://docs.docker.com/engine/security/certificates/
mkdir -p /etc/docker/certs.d/docker.0k.io
ln -sf /etc/ssl/ca.0k.io.pem /etc/docker/certs.d/docker.0k.io/ca.crt
fi
service docker restart service docker restart
@ -173,7 +182,10 @@ EOF
fi fi
fi fi
if ! [ -d "/opt/apps/0k-compose" ]; then
if [ -d "/opt/apps/0k-compose" ]; then
cd "/opt/apps/0k-compose" &&
git pull -r
else
mkdir -p /opt/apps && cd /opt/apps mkdir -p /opt/apps && cd /opt/apps
git clone "$GIT_0K_BASE"/0k/0k-compose.git git clone "$GIT_0K_BASE"/0k/0k-compose.git
fi fi
@ -197,8 +209,9 @@ export CONFIGSTORE=\$DOCKER_DATASTORE/config
EOF EOF
echo "DEFAULT_COMPOSE_FILE=/etc/compose/compose.yml" >> /etc/compose/local.conf
if ! egrep "^DEFAULT_COMPOSE_FILE=/etc/compose/compose.yml$" /etc/compose/local.conf >/dev/null 2>&1; then
echo "DEFAULT_COMPOSE_FILE=/etc/compose/compose.yml" >> /etc/compose/local.conf
fi
## ##
@ -207,7 +220,10 @@ echo "DEFAULT_COMPOSE_FILE=/etc/compose/compose.yml" >> /etc/compose/local.conf
( (
if ! [ -d "/opt/apps/0k-pgm" ]; then
if [ -d "/opt/apps/0k-pgm" ]; then
cd /opt/apps/0k-pgm &&
git pull -r
else
cd /opt/apps && cd /opt/apps &&
git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-pgm.git" && git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-pgm.git" &&
cd /opt/apps/0k-pgm && cd /opt/apps/0k-pgm &&
@ -216,6 +232,6 @@ echo "DEFAULT_COMPOSE_FILE=/etc/compose/compose.yml" >> /etc/compose/local.conf
ln -sf /opt/apps/0k-pgm/bin/* /usr/local/bin/ ln -sf /opt/apps/0k-pgm/bin/* /usr/local/bin/
apt-get install -y --force-yes pv buffer < /dev/null apt-get install -y --force-yes pv buffer < /dev/null
require psql || apt-get install -y postgresql-client </dev/null
apt-get install -y postgresql-client </dev/null
) )
Loading…
Cancel
Save