github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/acceptancetests/repository/charms/wordpress/hooks/install (about)

     1  #!/bin/bash
     2  
     3  set -xe
     4  
     5  if [[ -d exec.d ]]; then
     6      shopt -s nullglob
     7      for f in exec.d/*/charm-pre-install; do
     8      [[ -x "$f" ]] || continue
     9      ${SHELL} -c "$f"|| {
    10          ## bail out if anyone fails
    11          juju-log -l ERROR "$f: returned exit_status=$? "
    12          exit 1
    13      }
    14      done
    15  fi
    16  
    17  status-set maintenance "installing dependencies"
    18  add-apt-repository ppa:charmers/charm-helpers
    19  apt-get update && apt-get -y upgrade
    20  
    21  apt-get -y install php5-memcache mysql-client pwgen php5 php5-fpm \
    22  	php-apc mailutils php-mail sysstat php5-mysql php5-mcrypt php5-memcache \
    23  	php5-curl rsync nfs-common git-core mktemp
    24  
    25  modprobe nfs || true
    26  
    27  juju-log "Making /mnt/tmp dir ..."
    28  mkdir -p /mnt/tmp
    29  chmod 1777 /mnt/tmp
    30  
    31  juju-log "Making /mnt/logs ..."
    32  mkdir -p /mnt/logs/php-fpm
    33  chmod -R 1777 /mnt/logs
    34  
    35  ## dont make this an actual ramdisk until later when size can be safely tested
    36  ## just using plain disk cache for now
    37  juju-log "Making Ramdisk mount point and config ..."
    38  mkdir -p /mnt/ramdisk/proxy-cache
    39  mkdir -p /mnt/ramdisk/phpfpm-cache
    40  chmod -R 1777 /mnt/ramdisk
    41  
    42  juju-log "Installing PHP-FPM pool configs ..."
    43  rm -f /etc/php5/fpm/pool.d/*
    44  install -o root -g root -m 0644 files/charm/php/php5-fpm_pool.d_www.conf /etc/php5/fpm/pool.d/www.conf
    45  rsync -az /var/lib/php5 /mnt/ && rm -rf /var/lib/php5 && ln -s /mnt/php5 /var/lib/
    46  
    47  juju-log "Creating random secret key ..."
    48  if [ ! -f .wp-secret ]; then
    49  	pwgen -s 10 1 > .wp-secret
    50  fi
    51  
    52  juju-log "Installing wp-cli to make this charm's life a little easier ..."
    53  status-set maintenance "installing components"
    54  git clone https://github.com/wp-cli/wp-cli.git /usr/src/wp-cli
    55  # other hooks call hooks/install and don't expect the CWD to change so
    56  # run this section in a subshell
    57  (
    58  	cd /usr/src/wp-cli
    59  	# 20120926: v0.6.0 is confirmed working, so use it rather than alpha.
    60  	git reset --hard v0.6.0
    61  	git submodule update --init
    62  	utils/dev-build
    63  )
    64  
    65  juju-log "So, environment is setup. We'll wait for some hooks to fire off before we get all crazy"