1 # Switching a from-source install to OTP releases
3 ## What are OTP releases?
4 OTP releases are as close as you can get to binary releases with Erlang/Elixir. The release is self-contained, and provides everything needed to boot it, it is easily administered via the provided shell script to open up a remote console, start/stop/restart the release, start in the background, send remote commands, and more.
7 You will be running commands as root. If you aren't root already, please elevate your priviledges by executing `sudo su`/`su`.
9 The system needs to have `curl` and `unzip` installed for downloading and unpacking release builds.
18 apt install curl unzip
21 ## Moving content out of the application directory
22 When using OTP releases the application directory changes with every version so it would be a bother to keep content there (and also dangerous unless `--no-rm` option is used when updating). Fortunately almost all paths in Pleroma are configurable, so it is possible to move them out of there.
24 Pleroma should be stopped before proceeding.
26 ### Moving uploads/custom public files directory
29 # Create uploads directory and set proper permissions (skip if using a remote uploader)
30 # Note: It does not have to be `/var/lib/pleroma/uploads`, you can configure it to be something else later
31 mkdir -p /var/lib/pleroma/uploads
32 chown -R pleroma /var/lib/pleroma
34 # Create custom public files directory
35 # Note: It does not have to be `/var/lib/pleroma/static`, you can configure it to be something else later
36 mkdir -p /var/lib/pleroma/static
37 chown -R pleroma /var/lib/pleroma
39 # If you use the local uploader with default settings your uploads should be located in `~pleroma/uploads`
40 mv ~pleroma/uploads/* /var/lib/pleroma/uploads
42 # If you have created the custom public files directory with default settings it should be located in `~pleroma/instance/static`
43 mv ~pleroma/instance/static /var/lib/pleroma/static
47 Assuming you have all emojis in subdirectories of `priv/static/emoji` moving them can be done with
49 mkdir /var/lib/pleroma/static/emoji
50 ls -d ~pleroma/priv/static/emoji/*/ | xargs -i sh -c 'mv "{}" "/var/lib/pleroma/static/emoji/$(basename {})"'
53 But, if for some reason you have custom emojis in the root directory you should copy the whole directory instead.
55 mv ~pleroma/priv/static/emoji /var/lib/pleroma/static/emoji
57 and then copy custom emojis to `/var/lib/pleroma/static/emoji/custom`.
59 This is needed because storing custom emojis in the root directory is deprecated, but if you just move them to `/var/lib/pleroma/static/emoji/custom` it will break emoji urls on old posts.
61 Note that globs have been replaced with `pack_extensions`, so if your emojis are not in png/gif you should [modify the default value](../configuration/cheatsheet.md#emoji).
65 # Create the config directory
66 # The default path for Pleroma config is /etc/pleroma/config.exs
67 # but it can be set via PLEROMA_CONFIG_PATH environment variable
70 # Move the config file
71 mv ~pleroma/config/prod.secret.exs /etc/pleroma/config.exs
73 # Change `use Mix.Config` at the top to `import Config`
74 $EDITOR /etc/pleroma/config.exs
76 ## Installing the release
77 Before proceeding, get the flavour from [Detecting flavour](otp_en.md#detecting-flavour) section in OTP installation guide.
79 # Delete all files in pleroma user's directory
82 # Set the flavour environment variable to the string you got in Detecting flavour section.
83 # For example if the flavour is `amd64-musl` the command will be
84 export FLAVOUR="amd64-musl"
86 # Clone the release build into a temporary directory and unpack it
87 # Replace `stable` with `unstable` if you want to run the unstable branch
88 su pleroma -s $SHELL -lc "
89 curl 'https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=$FLAVOUR' -o /tmp/pleroma.zip
90 unzip /tmp/pleroma.zip -d /tmp/
93 # Move the release to the home directory and delete temporary files
94 su pleroma -s $SHELL -lc "
95 mv /tmp/release/* ~pleroma/
100 # Start the instance to verify that everything is working as expected
101 su pleroma -s $SHELL -lc "./bin/pleroma daemon"
103 # Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
104 sleep 20 && curl http://localhost:4000/api/v1/instance
107 su pleroma -s $SHELL -lc "./bin/pleroma stop"
110 ## Setting up a system service
111 OTP releases have different service files than from-source installs so they need to be copied over again.
113 **Warning:** The service files assume pleroma user's home directory is `/opt/pleroma`, please make sure all paths fit your installation.
117 # Copy the service into a proper directory
118 cp -f ~pleroma/installation/init.d/pleroma /etc/init.d/pleroma
121 rc-service pleroma start
126 # Copy the service into a proper directory
127 cp ~pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
129 # Reload service files
130 systemctl daemon-reload
132 # Reenable pleroma to start on boot
133 systemctl reenable pleroma
136 systemctl start pleroma
140 Refer to [Running mix tasks](otp_en.md#running-mix-tasks) section from OTP release installation guide.
142 Refer to [Updating](otp_en.md#updating) section from OTP release installation guide.