diaspora-installer/diaspora package helps you set up and run a diaspora* pod on
your server. diaspora is a native debian package with all dependencies packaged
in debian where as diaspora-installer downloads diaspora and dependencies from
the internet.

Read wiki.diasporafoundation.org for more information about diaspora*.

This package makes some choices for you.
- postgresql is used as the database server by diaspora-installer and mysql is
used as the database server by diaspora-installer-mysql
- nginx is used as the server (alternatives include apache)

The package is split into diaspora-installer, diaspora-installer-mysql and
diaspora-common, because diaspora-common will contain files that are common to
diaspora-installer and diaspora packages.

diaspora-common
- contains the database configuration and diaspora configuration yml files which
are copied to (/usr/share/diaspora)
- contains the init script (which will be copied to /etc/init.d/diaspora)
- contains systemd unit files (diaspora.service, diaspora-sidekiq.service and
  diaspora-unicorn.service)
- contains diaspora.conf that is used during the setup
- contains other scripts (adduser, grantpriv, explained later)
- manages symbolic links for directories that diaspora needs write access (for
  example /usr/share/diaspora/tmp is a symbolic link to /run/diaspora)
  Note: When updating a symbolic link, update preinst and postrm as well

Installation
===
There's no binary to be built.
The scripts and configuration are copied to the following places.
- diaspora.yml and database.yml are put in /usr/share/diaspora/config
- adduser.sh, grantpriv.sh, set-env-nginx.sh are put in
  /usr/lib/diaspora-common/scripts
- diaspora-common.init becomes the /etc/init.d/diaspora
- systemd unit files are installed in /lib/systemd/system/

The "config" file gets run and
- sets all the variables required in /etc/diaspora/diaspora.conf
- copies nginx.conf.example to /etc/nginx-sites-available/ and symlinks in
  sites-enabled

diaspora-common postinst does the following:
- runs adduser.sh to create 'diaspora' user with no login possible.
- runs grantpriv.sh to set diaspora_production database's owner to diaspora.
  Grants diaspora privilege to create database. And grants all privileges on
  template1 database to diaspora. This database stores permissions and other
  metadata
  
diaspora-installer postinst does the following:
- the download of the actual diaspora code from github.com (as tar.gz using the
  tags page matching the version provided in diaspora-common.conf)
- verifies the checksum for the downloaded tarball against its known value
- copies that to /usr/share/diaspora/
- `bundle install` all gems based on Gemfile.lock
- bundle exec rake db:create db:migrate
- bundle exec rake assets:precompile
- creating and saving secret token
- starting diaspora

You will then be asked to copy ssl certificates and reload nginx

Running
===
systemctl {start|stop|status|restart} diaspora
/etc/init.d/diaspora {start|stop|status|restart|force-reload}
service diaspora {start|stop|status|restart|force-reload}

Configuration
===
You might want to edit diaspora.yml to make modifications, like integrating
social networks. This file can be found in /etc/diaspora

Later you can restart diaspora service.
sudo systemctl stop diaspora
sudo systemctl start diaspora

Troubleshooting
===

You have to change to /usr/share/diaspora directory, set environment variables
and run commands as diaspora user

cd /usr/share/diaspora
export $(cat /etc/diaspora/diaspora.conf | xargs)
sudo -u diaspora -E -H bundle exec gem show unicorn

You can check if unicorn is running on port 3000 by running
netstat -ntap | grep 3000

If the diaspora service is not running, check its service log file at
/usr/share/diaspora/log/startscript.log

Also check any known issues and work arounds at https://wiki.debian.org/Diaspora

Update Checklist
===

When updating diasora-installer to a new release, change diaspora_version in
diaspora-common.conf and update sha256sum in sha256sums.
