post_install() {

  chown -R arangodb:arangodb "/var/lib/arangodb3" &> /dev/null
  chown -R arangodb:arangodb "/var/lib/arangodb3-apps" &> /dev/null
  chown -R arangodb:arangodb "/var/log/arangodb3" &> /dev/null

  cat <<-EOF

  Welcome to ArangoDB.

  To get started you will need to tell systemd to reload it's unit
  files, then enable and start the service:

   sudo systemctl daemon-reload
   sudo systemctl enable arangodb3.service
   sudo systemctl start arangodb3.service

  ArangoDB 3 ships with authentication enabled. To use it you will need
  to start the server with 'authentication = false' in the following
  files:

    /etc/arangodb3/arangosh.conf
    /etc/arangodb3/arangod.conf

  Then set the passwords and create the users you need:

    $> arangosh
    127.0.0.1:8529@_system> require("org/arangodb/users").update("root",
    "mypassword")
    127.0.0.1:8529@_system> require("org/arangodb/users").save("myuser",
    "mypassword");

  Set the 'authentication = true' and then restart ArangoDB:

   sudo systemctl restart arangodb3.service

  You can now use your username and password to access the
  administrative interface at:

    http://localhost:8529

  ArangoDB now works with logrotate:

     sudo logrotate /etc/logrotate.d/arangodb3


  Getting help:
    http://stackoverflow.com/questions/tagged/arangodb
    https://arangodb-community.slack.com
    https://docs.arangodb.com/cookbook
    https://docs.arangodb.com

EOF
}

post_upgrade() {
  cat <<-EOF

  ArangoDB has been upgraded to $1.

  Take a look at the Changelog to see what is new:
  https://github.com/arangodb/arangodb/blob/devel/CHANGELOG

EOF
}

pre_remove() {
  systemctl stop arangodb3.service &> /dev/null
}

post_remove() {
  cat <<-EOF

  ArangoDB has been uninstalled.

  Any data you had stored in ArangoDB is still available in /var/lib/arangodb3.
  Installed Foxx applications are still available in /var/lib/arangodb3-apps.
  Log files are left in /var/log/arangodb3.

EOF
}
