summarylogtreecommitdiffstats
path: root/misskey-db-upgrade.sh
blob: c95fae3f77621e821fa080feff26f1c2c8bee04a (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
#! /usr/bin/env sh

if [ $(id -u) -ne 0 ]; then
    printf "You need to be root\n"
    exit 1
fi

## Migration needs PostgreSQL + redis running.
## Don't migrate if not running
if /usr/bin/systemctl is-active postgresql.service > /dev/null \
  && /usr/bin/systemctl is-active redis.service > /dev/null; then 
    ## misskey needs to be stopped, check for this
    if /usr/bin/systemctl is-active misskey.service; then
      printf "Shutting down misskey\n"
      MK_ACTIVE=1
      /usr/bin/systemctl stop misskey.service
    fi
    printf "Migrate data to new version\n"
    cd "/usr/share/webapps/misskey/"
    /usr/bin/runuser -u misskey -- env HOME="/usr/share/webapps/misskey" yarn migrate
    if ! [ -z ${MK_ACTIVE+x} ] ; then
        printf "starting up misskey\n"
        /usr/bin/systemctl start misskey.service
    else
        printf "Misskey service is *not* started\n"
        printf "Thats your job!\n"
    fi
else
    printf "Misskey migration was not started because PostgreSQL and or redis is inactive.\n"
    printf "Please start the services and run\n"
    printf "# /usr/lib/misskey/misskey-db-upgrade.sh\n"
fi