~charmers/charms/trusty/etherpad-lite/trunk

« back to all changes in this revision

Viewing changes to hooks/install

  • Committer: James Page
  • Date: 2011-09-28 12:53:35 UTC
  • Revision ID: james.page@canonical.com-20110928125335-a4cat72jjwe8m2g2
Juju transition, switched from sqlite to dirty default database

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
install_app() {
29
29
  juju-log "Installing ${app_name}..."
30
 
  apt-get -y install -qq git-core daemon libsqlite3-dev gzip g++ abiword
 
30
  apt-get -y install -qq git-core daemon gzip abiword
31
31
  # Grab 1.0 of etherpad
32
32
  git clone ${app_url} ${app_dir} -b ${app_branch}
33
33
  cd ${app_dir} && git checkout 1.0
34
34
 
35
35
  if [ -f ${app_dir}/package.json ]; then
36
 
        # Install ep-lite and sqlite3
37
 
    cd ${app_dir} && npm install && npm install sqlite3
 
36
        # Install ep-lite deps
 
37
    cd ${app_dir} && npm install 
38
38
  fi
39
39
 
40
40
  # Modifiy the app so $app_user can write to it 
41
 
  # needed as starts up with a sqlite database
 
41
  # needed as starts up with a dirty database
42
42
  chown -Rf ${app_user}.${app_user} ${app_dir}
43
43
 
44
44
  cat > /etc/init/${app_name}.conf <<EOS
45
45
description "${app_name} server"
46
46
 
47
 
start on (net-device-up IFACE!=lo
48
 
          and local-filesystems
49
 
          and runlevel [2345])
 
47
start on runlevel [2345]
50
48
stop on runlevel [!2345]
51
49
 
52
50
limit nofile 8192 8192
53
 
 
 
51
 
 
52
pre-start script
 
53
  touch /var/log/${app_name}.log || true
 
54
  chown ${app_user}:${app_user} /var/log/${app_name}.log || true
 
55
end script
 
56
 
54
57
script
55
58
  exec daemon --name=${app_name} --inherit --user=${app_user} --output=/var/log/${app_name}.log \
56
59
    -- ${app_dir}/bin/run.sh 
60
63
[[ -d ${app_dir} ]] || install_app
61
64
 
62
65
configure_app() {
63
 
    juju-log "Configurating ${app_name} with default sqlite database..."
 
66
    juju-log "Configurating ${app_name} with default dirty database..."
64
67
    # TODO: add hook to configure default text in this function
65
 
    cp $(dirname $0)/ep-config/settings.json.sqlite /opt/${app_name}/settings.json
 
68
    cp $(dirname $0)/ep-config/settings.json.dirty /opt/${app_name}/settings.json
66
69
}
67
70
 
68
 
# always configure application - defaults to sqlite
 
71
# always configure application - defaults to node dirty < 1M records
69
72
configure_app
70
73
 
71
 
# Open Port for Access to Application - it will run on sqlite so if good from the start
 
74
# Open Port for Access to Application - it will run on dirty so if good from the start
72
75
open-port 9001
73
76
 
74
77
juju-log "Delaying app external db config (mysqldb might join)"