2019-06-24 02:51:02 -06:00
# Switching a from-source install to OTP releases
2019-12-09 10:08:31 -07:00
2021-08-10 00:09:31 -06:00
{! backend/installation/otp_vs_from_source.include !}
In this guide we cover how you can migrate from a from source installation to one using OTP releases.
2019-12-09 10:08:31 -07:00
2019-06-26 02:34:58 -06:00
## Pre-requisites
You will be running commands as root. If you aren't root already, please elevate your priviledges by executing `sudo su` /`su`.
The system needs to have `curl` and `unzip` installed for downloading and unpacking release builds.
2020-08-15 00:49:12 -06:00
=== "Alpine"
```sh
apk add curl unzip
```
2019-06-26 02:34:58 -06:00
2020-08-15 00:49:12 -06:00
=== "Debian/Ubuntu"
```sh
apt install curl unzip
```
2019-12-09 10:08:31 -07:00
2019-06-26 02:34:58 -06:00
## Moving content out of the application directory
2022-07-02 15:00:01 -06:00
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 Akkoma are configurable, so it is possible to move them out of there.
2019-06-26 02:34:58 -06:00
2022-07-02 15:00:01 -06:00
Akkoma should be stopped before proceeding.
2019-06-26 02:34:58 -06:00
### Moving uploads/custom public files directory
2019-12-09 10:08:31 -07:00
2019-06-26 02:34:58 -06:00
```sh
# Create uploads directory and set proper permissions (skip if using a remote uploader)
2022-07-02 15:00:01 -06:00
# Note: It does not have to be `/var/lib/akkoma/uploads`, you can configure it to be something else later
mkdir -p /var/lib/akkoma/uploads
chown -R akkoma /var/lib/akkoma
2019-06-26 02:34:58 -06:00
# Create custom public files directory
2022-07-02 15:00:01 -06:00
# Note: It does not have to be `/var/lib/akkoma/static`, you can configure it to be something else later
mkdir -p /var/lib/akkoma/static
chown -R akkoma /var/lib/akkoma
2019-06-26 02:34:58 -06:00
2022-07-02 15:00:01 -06:00
# If you use the local uploader with default settings your uploads should be located in `~akkoma/uploads`
mv ~akkoma/uploads/* /var/lib/akkoma/uploads
2019-06-26 02:34:58 -06:00
2022-07-02 15:00:01 -06:00
# If you have created the custom public files directory with default settings it should be located in `~akkoma/instance/static`
mv ~akkoma/instance/static /var/lib/akkoma/static
2019-06-26 02:34:58 -06:00
```
### Moving emoji
Assuming you have all emojis in subdirectories of `priv/static/emoji` moving them can be done with
```sh
2022-07-02 15:00:01 -06:00
mkdir /var/lib/akkoma/static/emoji
ls -d ~akkoma/priv/static/emoji/*/ | xargs -i sh -c 'mv "{}" "/var/lib/akkoma/static/emoji/$(basename {})"'
2019-06-26 02:34:58 -06:00
```
But, if for some reason you have custom emojis in the root directory you should copy the whole directory instead.
```sh
2022-07-02 15:00:01 -06:00
mv ~akkoma/priv/static/emoji /var/lib/akkoma/static/emoji
2019-06-26 02:34:58 -06:00
```
2022-07-02 15:00:01 -06:00
and then copy custom emojis to `/var/lib/akkoma/static/emoji/custom` .
2019-06-26 02:34:58 -06:00
2022-07-02 15:00:01 -06:00
This is needed because storing custom emojis in the root directory is deprecated, but if you just move them to `/var/lib/akkoma/static/emoji/custom` it will break emoji urls on old posts.
2019-06-26 02:34:58 -06:00
2019-10-02 15:18:32 -06:00
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 ).
2019-06-26 02:34:58 -06:00
### Moving the config
```sh
# Create the config directory
2022-07-02 15:00:01 -06:00
# The default path for Akkoma config is /etc/akkoma/config.exs
2019-06-26 02:34:58 -06:00
# but it can be set via PLEROMA_CONFIG_PATH environment variable
2022-07-02 15:00:01 -06:00
mkdir -p /etc/akkoma
2019-06-26 02:34:58 -06:00
# Move the config file
2022-07-02 15:00:01 -06:00
mv ~akkoma/config/prod.secret.exs /etc/akkoma/config.exs
2019-06-26 02:34:58 -06:00
# Change `use Mix.Config` at the top to `import Config`
2022-07-02 15:00:01 -06:00
$EDITOR /etc/akkoma/config.exs
2019-06-26 02:34:58 -06:00
```
2019-06-24 02:51:02 -06:00
## Installing the release
2019-10-02 15:18:32 -06:00
Before proceeding, get the flavour from [Detecting flavour ](otp_en.md#detecting-flavour ) section in OTP installation guide.
2019-06-26 02:34:58 -06:00
```sh
2022-07-02 15:00:01 -06:00
# Delete all files in akkoma user's directory
rm -r ~akkoma/*
2019-06-26 02:34:58 -06:00
2019-06-26 06:24:06 -06:00
# Set the flavour environment variable to the string you got in Detecting flavour section.
2019-12-09 10:08:31 -07:00
# For example if the flavour is `amd64-musl` the command will be
export FLAVOUR="amd64-musl"
2019-06-26 06:24:06 -06:00
2019-06-26 02:34:58 -06:00
# Clone the release build into a temporary directory and unpack it
2019-10-14 09:38:51 -06:00
# Replace `stable` with `unstable` if you want to run the unstable branch
2022-07-02 15:00:01 -06:00
su akkoma -s $SHELL -lc "
curl 'https://akkoma-updates.s3-website.fr-par.scw.cloud/develop/akkoma-$FLAVOUR.zip' -o /tmp/akkoma.zip
unzip /tmp/akkoma.zip -d /tmp/
2019-06-26 02:34:58 -06:00
"
# Move the release to the home directory and delete temporary files
2022-07-02 15:00:01 -06:00
su akkoma -s $SHELL -lc "
mv /tmp/release/* ~akkoma/
2019-06-26 02:34:58 -06:00
rmdir /tmp/release
2022-07-02 15:00:01 -06:00
rm /tmp/akkoma.zip
2019-06-26 02:34:58 -06:00
"
# Start the instance to verify that everything is working as expected
2022-07-02 15:00:01 -06:00
su akkoma -s $SHELL -lc "./bin/pleroma daemon"
2019-06-26 02:34:58 -06:00
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
sleep 20 & & curl http://localhost:4000/api/v1/instance
# Stop the instance
2022-07-02 15:00:01 -06:00
su akkoma -s $SHELL -lc "./bin/pleroma stop"
2019-06-26 02:34:58 -06:00
```
## Setting up a system service
OTP releases have different service files than from-source installs so they need to be copied over again.
2022-07-02 15:00:01 -06:00
**Warning:** The service files assume akkoma user's home directory is `/opt/akkoma` , please make sure all paths fit your installation.
2019-06-29 02:35:42 -06:00
2020-08-15 00:49:12 -06:00
=== "Alpine"
```sh
# Copy the service into a proper directory
2022-07-02 15:00:01 -06:00
cp -f ~akkoma/installation/init.d/akkoma /etc/init.d/akkoma
2019-12-09 10:08:31 -07:00
2022-07-02 15:00:01 -06:00
# Start akkoma
rc-service akkoma start
2020-08-15 00:49:12 -06:00
```
2019-12-09 10:08:31 -07:00
2020-08-15 00:49:12 -06:00
=== "Debian/Ubuntu"
```sh
# Copy the service into a proper directory
2022-07-02 15:00:01 -06:00
cp ~akkoma/installation/akkoma.service /etc/systemd/system/akkoma.service
2019-06-26 02:34:58 -06:00
2020-08-15 00:49:12 -06:00
# Reload service files
systemctl daemon-reload
2019-06-26 02:34:58 -06:00
2022-07-02 15:00:01 -06:00
# Reenable akkoma to start on boot
systemctl reenable akkoma
2019-06-26 02:34:58 -06:00
2022-07-02 15:00:01 -06:00
# Start akkoma
systemctl start akkoma
2020-08-15 00:49:12 -06:00
```
2019-06-26 02:34:58 -06:00
## Running mix tasks
2019-10-02 15:18:32 -06:00
Refer to [Running mix tasks ](otp_en.md#running-mix-tasks ) section from OTP release installation guide.
2019-06-26 02:34:58 -06:00
## Updating
2019-10-02 15:18:32 -06:00
Refer to [Updating ](otp_en.md#updating ) section from OTP release installation guide.
2022-07-02 15:00:01 -06:00
## Questions
If you encounter any issues or have questions regarding the install process, feel free to ask at [meta.akkoma.dev ](https://meta.akkoma.dev/ ).