summarylogtreecommitdiffstats
path: root/mastodon.install
blob: fcaf495157c6b29731204195f03f55bcb80e60e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
_user=mastodon
_homedir=/var/lib/mastodon
_shell=/bin/false

post_install() {
    getent group ${_user} > /dev/null ||
        groupadd -r ${_user} > /dev/null
    getent passwd ${_user} > /dev/null ||
        useradd -rd ${_homedir} -g ${_user} -s ${_shell} ${_user} > /dev/null
    chown -R ${_user}:${_user} ${_homedir}

  # sed -i -e "/^PAPERCLIP_SECRET=\$/s/\$/$(rake secret)/" \
  #        -e "/^SECRET_KEY_BASE=\$/s/\$/$(rake secret)/" \
  #        -e "/^OTP_SECRET=\$/s/\$/$(rake secret)/" \
  #        -e "/^REDIS_HOST=redis\$/s/redis\$/localhost/" \
  #        -e "/^DB_HOST=db\$/s/redis\$/localhost/" \
  #     /etc/mastodon/env.production
  
    cat <<- EOF
    To setup Mastodon, enable and start PostgreSQL and Redis:
    # systemctl enable --now postgresql redis
    Create the Mastodon PostgreSQL user and grant it the ability to create databases with:
    # su - postgres -s /bin/sh -c "createdb -d mastodon"
    Then, run:
    # su - mastodon -s /bin/sh -c "cd '/var/lib/mastodon'; RAILS_ENV=production bundle exec rails mastodon:setup"
    Finally, enable and start all the required services:
    # systemctl enable --now mastodon.target
    EOF

  # echo "1. Configure your instance:"
  # echo "    $ vim /etc/mastodon/env.production"
  # echo ""
  # echo "2. Create a postgres user for mastodon:"
  # echo "    $ sudo -u postgres psql"
  # echo "    > CREATE USER mastodon CREATEDB;"
  # echo ""
  # echo "3. Then setup the database for the first time:"
  # echo "    $ cd ~mastodon && sudo -u mastodon RAILS_ENV=production bundle exec rails db:setup"
  # echo ""
  # echo "4. Create an administrator account:"
  # echo "    $ cd ~mastodon && sudo -u mastodon RAILS_ENV=production bundle exec rails mastodon:make_admin USERNAME=<username>"
  # echo ""
  # echo "5. Enable and start instance:"
}

post_upgrade() {
    chown -R ${_user}:${_user} ${_homedir}

    cat <<- EOF
    To upgrade the database schema, run:
    # su - mastodon -s /bin/sh -c "RAILS_ENV=production bundle exec rails db:migrate"
    To pre-compile assets, run:
    # su - mastodon -s /bin/sh -c "RAILS_ENV=production bundle exec rails assets:precompile"
    EOF
}

post_remove() {
  echo 'You may want to remove the Mastodon user.'
}