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. 5
      precise/base-0k/hooks/install.d/15-etckeeper.sh
  3. 6
      precise/base-0k/hooks/install.d/30-customize.sh
  4. 10
      precise/base-0k/hooks/install.d/35-git-access.sh
  5. 12
      precise/base-0k/hooks/install.d/36-gitsub.sh
  6. 64
      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

5
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
if ! [ -f /etc/.git ]; then
etckeeper init 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

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

@ -12,7 +12,13 @@ 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
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 cat <<EOF >> "$SSH_CONFIG_DIR"/config
Host 0k-ro Host 0k-ro
@ -24,5 +30,3 @@ Host 0k-ro
StrictHostKeyChecking no StrictHostKeyChecking no
EOF EOF
fi

12
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
## ##
if [ -d /opt/apps/git-sub ]; then
cd /opt/apps/git-sub &&
git pull -r
else
mkdir -p /opt/apps && mkdir -p /opt/apps &&
cd /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/
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

64
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,9 +104,8 @@ 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) ## This does not seem to work anymore (docker v1.12, ubutnu 14.04 on gani)
echo "Fetching 0k.io CA certificate..." echo "Fetching 0k.io CA certificate..."
@ -105,8 +114,8 @@ if ! [ -r /etc/ssl/ca.0k.io.pem ]; then
## This is the new way: https://docs.docker.com/engine/security/certificates/ ## This is the new way: https://docs.docker.com/engine/security/certificates/
mkdir -p /etc/docker/certs.d/docker.0k.io 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
ln -sfn /etc/ssl/ca.0k.io.pem /etc/docker/certs.d/docker.0k.io/ca.crt
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
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 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