summarylogtreecommitdiffstats
path: root/pleroma.install
blob: ef3d5937c7481da40adad6d70817ef5f95c829f7 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
post_install() {
    username="pleroma"
    home_dir="/opt/${username}"
    uploads_dir="/var/lib/${username}/uploads"
    static_dir="/var/lib/${username}/static"
    config_dir="/etc/${username}"
    tmp_psql="/tmp/setup_otp_db.psql"

    instance_gen_params="instance gen\
 --output \"${config_dir}/config.exs\"\
 --output-psql \"$tmp_psql\"\
 --uploads-dir \"$uploads_dir\"\
 --static-dir \"$static_dir\"\
 --dbname \"$username\"\
 --dbuser \"$username\"\
"

    printf "\n"
    printf "A local installation of postgresql is strongly recommended unless you know what you are doing. Use:\n    $ sudo pacman -S postgresql\nto install postgresql locally.\n\n"
	printf "If postgresql is installed locally, the user should run the following commands to initialize pleroma:\n"

	printf ">>> sudo -Hu $username ${home_dir}/bin/pleroma_ctl ${instance_gen_params}\n"
	printf ">>> sudo -Hu postgres psql -f \"${tmp_psql}\"\n"
	printf ">>> sudo -Hu $username ${home_dir}/bin/pleroma_ctl migrate\n\n"

    printf "If the user is using a remote postgresql instance, they should ensure \"${tmp_psql}\" be executed remotely after the first command:\n"
    printf ">>> sudo -Hu $username -s /bin/bash ${home_dir}/bin/pleroma_ctl ${instance_gen_params}\n"
    printf ">>> # Now execute \"$tmp_psql\" remotely.\n"
	printf ">>> sudo -Hu $username -s /bin/bash ${home_dir}/bin/pleroma_ctl migrate\n\n"

    printf "After initializing pleroma, you may start it with:\n"
    printf ">>> sudo systemctl start pleroma\n\n"

	printf "nginx is recommended to serve Pleroma over HTTP.\n"
	printf "If using a different HTTP server,\n"
	printf "you should remove nginx from the pleroma.service file.\n"

	printf "Check https://docs-develop.pleroma.social/backend/installation/otp_en/#post-installation for post-installation steps.\n"
}

pre_upgrade() {
    systemctl stop pleroma.service
}

post_upgrade() {
    username="pleroma"
    home_dir="/opt/${username}"
    migration_needed="false"

    printf "Procedures to upgrade from version $2 to version $1:\n\n"
    case "$2" in
    "2.4.0-1")
        ;&
    "2.4.0-2")
        printf "Check https://pleroma.social/announcements/2021/08/29/pleroma-patch-release-2-4-1/ for upgrade notes.\n"
        ;&
    "2.4.1-1")
        printf "Check https://pleroma.social/announcements/2022/01/11/pleroma-patch-release-2-4-2/ for upgrade notes.\n"
        ;&
    "2.4.2-1")
        ;&
    "2.4.3-1")
        ;&
    "2.4.4-1")
        ;&
    esac

    if [ "$migration_needed" = "true" ]; then
        printf "\nYou will need to migrate your database as the above upgrade notes state.\n"
        printf "Ensure your postgresql database, whether local or remote, is up, and run the following command:\n"
        printf ">>> cd \"$home_dir\"\n"
        printf ">>> sudo -Hu \"$username\" ./bin/pleroma_ctl migrate\n"
    fi

    printf "\nAfter all these, you may start pleroma with:\n"
    printf ">>> sudo systemctl start pleroma\n"
}