freedombone/src/freedombone-app-pleroma

1022 lines
37 KiB
Plaintext
Raw Normal View History

2017-11-06 12:29:20 +01:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Pleroma backend application
# https://git.pleroma.social/pleroma/pleroma/wikis/Installing-on-Debian-Based-Distributions
2017-11-06 12:29:20 +01:00
#
# Show stopper: This is dependent on https://placehold.it for avatar images,
# so at present it's not usable until a first party placeholder image system
# is included.
#
# There is also a possible issue with the chat system which uses an object called
# "Agent" which may not be supported with the version of elixir within the
# Debian package. This only applies if you're installing from the latest commit.
#
2017-11-06 12:29:20 +01:00
# License
# =======
#
# Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
2017-11-06 12:29:20 +01:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2018-01-15 21:48:59 +01:00
VARIANTS='full full-vim social'
2017-11-06 12:29:20 +01:00
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
PLEROMA_DOMAIN_NAME=
PLEROMA_CODE=
PLEROMA_PORT=4000
PLEROMA_ONION_PORT=8011
PLEROMA_REPO="https://git.pleroma.social/pleroma/pleroma.git"
2018-01-15 21:48:59 +01:00
PLEROMA_COMMIT='80f6ac412a632da090be9f3d86971eac0b95a53d'
2017-11-06 12:29:20 +01:00
PLEROMA_ADMIN_PASSWORD=
2017-11-06 13:41:26 +01:00
PLEROMA_DIR=/etc/pleroma
2017-11-06 19:49:35 +01:00
PLEROMA_SECRET_KEY=""
2017-11-06 12:29:20 +01:00
PLEROMA_BACKGROUND_IMAGE_URL=
PLEROMA_TITLE='Pleroma Server'
# Number of months after which posts expire
PLEROMA_EXPIRE_MONTHS=3
2018-01-20 22:09:25 +01:00
pleroma_expire_posts_script=/usr/bin/pleroma-expire-posts
2018-01-21 18:56:39 +01:00
blocking_script_file=/usr/bin/pleroma-blocking
2017-11-06 12:29:20 +01:00
pleroma_variables=(ONION_ONLY
PLEROMA_DOMAIN_NAME
PLEROMA_CODE
PLEROMA_WELCOME_MESSAGE
PLEROMA_BACKGROUND_IMAGE_URL
DDNS_PROVIDER
PLEROMA_TITLE
PLEROMA_EXPIRE_MONTHS
MY_EMAIL_ADDRESS
MY_USERNAME)
2018-01-21 18:56:39 +01:00
function create_pleroma_blocklist {
echo '#!/bin/bash' > $blocking_script_file
2018-01-21 19:34:08 +01:00
echo "if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then" >> $blocking_script_file
2018-01-21 18:56:39 +01:00
echo ' exit 0' >> $blocking_script_file
echo 'fi' >> $blocking_script_file
echo 'cd /etc/postgresql' >> $blocking_script_file
echo 'while read blocked; do' >> $blocking_script_file
echo ' if [[ "$blocked" == *"."* || "$blocked" == *"@"* ]]; then' >> $blocking_script_file
echo ' if [ ${#blocked} -gt 4 ]; then' >> $blocking_script_file
2018-01-22 10:53:17 +01:00
echo " sudo -u postgres psql -d pleroma -c \"DELETE FROM objects WHERE data->>'content' ilike '%\${blocked}%' or data->>'actor' ilike '%\${blocked}%' or data->>'to' ilike '%\${blocked}%' or data->>'id' ilike '%\${blocked}%' or data->>'external_url' ilike '%\${blocked}%'\"" >> $blocking_script_file
2018-01-22 11:12:14 +01:00
echo " sudo -u postgres psql -d pleroma -c \"DELETE FROM users WHERE nickname ilike '%\${blocked}%'\"" >> $blocking_script_file
2018-01-21 18:56:39 +01:00
echo ' fi' >> $blocking_script_file
echo ' fi' >> $blocking_script_file
2018-01-21 19:34:08 +01:00
echo "done </root/${PROJECT_NAME}-firewall-domains.cfg" >> $blocking_script_file
2018-01-21 18:56:39 +01:00
chmod +x $blocking_script_file
if ! grep -q "$blocking_script_file" /etc/crontab; then
2018-01-22 11:41:30 +01:00
echo "*/2 * * * * root $blocking_script_file > /dev/null" >> /etc/crontab
2018-01-21 18:56:39 +01:00
fi
}
2018-01-20 22:09:25 +01:00
function expire_pleroma_posts {
domain_name=$1
expire_months=$3
if [ ! $expire_months ]; then
expire_months=3
fi
expire_days=$((expire_months * 30))
# files are what take up most of the backup time, so don't keep them for very long
expire_days_files=7
# To prevent the database size from growing endlessly this script expires posts
# after a number of months
if [ ! -d /etc/pleroma ]; then
return
fi
2018-01-20 23:14:00 +01:00
echo '#!/bin/bash' > $pleroma_expire_posts_script
echo "plmonths=\"$PLEROMA_EXPIRE_MONTHS\"" >> $pleroma_expire_posts_script
2018-01-20 23:23:37 +01:00
echo 'if [ ${#plmonths} -eq 0 ]; then' >> $pleroma_expire_posts_script
echo ' exit 1' >> $pleroma_expire_posts_script
echo 'fi' >> $pleroma_expire_posts_script
echo 'if [[ "$plmonths" == "0" ]]; then' >> $pleroma_expire_posts_script
echo ' exit 2' >> $pleroma_expire_posts_script
echo 'fi' >> $pleroma_expire_posts_script
2018-01-20 23:27:35 +01:00
echo 'oldate=$(date +%Y-%m-%d --date="$plmonths months ago")' >> $pleroma_expire_posts_script
echo 'cd /etc/postgresql' >> $pleroma_expire_posts_script
2018-01-20 23:14:00 +01:00
echo "sudo -u postgres psql -d pleroma -c \"DELETE FROM notifications WHERE inserted_at <= '\$oldate 01:01:01'\"" >> $pleroma_expire_posts_script
echo "sudo -u postgres psql -d pleroma -c \"DELETE FROM objects WHERE inserted_at <= '\$oldate 01:01:01'\"" >> $pleroma_expire_posts_script
2018-01-20 22:09:25 +01:00
chmod +x $pleroma_expire_posts_script
pleroma_expire_script=/etc/cron.daily/pleroma-expire
echo '#!/bin/bash' > $pleroma_expire_script
echo "find /etc/pleroma/uploads/* -mtime +${expire_days_files} -exec rm -rf {} +" >> $pleroma_expire_script
2018-01-20 23:27:35 +01:00
echo "$pleroma_expire_posts_script 2> /dev/null" >> $pleroma_expire_script
2018-01-20 22:09:25 +01:00
chmod +x $pleroma_expire_script
# remove any old cron job
if grep -q "pleroma-expire" /etc/crontab; then
sed -i "/pleroma-expire/d" /etc/crontab
rm /usr/bin/pleroma-expire
fi
# remove old expire script
if [ -f /etc/cron.weekly/clear-pleroma-database ]; then
rm /etc/cron.weekly/clear-pleroma-database
fi
}
function pleroma_recompile {
# necessary after parameter changes
2017-11-12 15:52:07 +01:00
chown -R pleroma:pleroma $PLEROMA_DIR
sudo -u pleroma mix clean
sudo -u pleroma mix deps.compile
sudo -u pleroma mix compile
if [ -f /etc/systemd/system/pleroma.service ]; then
systemctl restart pleroma
fi
2018-01-20 22:44:36 +01:00
}
2017-11-06 12:29:20 +01:00
function logging_on_pleroma {
echo -n ''
}
function logging_off_pleroma {
echo -n ''
}
function remove_user_pleroma {
remove_username="$1"
${PROJECT_NAME}-pass -u $remove_username --rmapp pleroma
}
function add_user_pleroma {
new_username="$1"
new_user_password="$2"
${PROJECT_NAME}-pass -u $new_username -a pleroma -p "$new_user_password"
2017-11-06 13:41:26 +01:00
echo '0'
2017-11-06 12:29:20 +01:00
}
function install_interactive_pleroma {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if [[ $ONION_ONLY != "no" ]]; then
PLEROMA_DOMAIN_NAME='pleroma.local'
else
PLEROMA_DETAILS_COMPLETE=
while [ ! $PLEROMA_DETAILS_COMPLETE ]
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
dialog --backtitle $"Freedombone Configuration" \
--title $"Pleroma Configuration" \
--form $"\nPlease enter your Pleroma details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
$"Domain:" 1 1 "$(grep 'PLEROMA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
$"Title:" 2 1 "$(grep '$PLEROMA_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
$"Background image URL:" 3 1 "$(grep '$PLEROMA_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
$"Code:" 4 1 "$(grep 'PLEROMA_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
2> $data
else
dialog --backtitle $"Freedombone Configuration" \
--title $"Pleroma Configuration" \
--form $"\nPlease enter your Pleroma details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
$"Domain:" 1 1 "$(grep 'PLEROMA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
$"Title:" 2 1 "$(grep '$PLEROMA_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
$"Background image URL:" 3 1 "$(grep '$PLEROMA_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
2> $data
fi
sel=$?
case $sel in
1) exit 1;;
255) exit 1;;
esac
PLEROMA_DOMAIN_NAME=$(cat $data | sed -n 1p)
title=$(cat $data | sed -n 2p)
if [ ${#title} -gt 1 ]; then
PLEROMA_TITLE=$welcome_msg
fi
img_url=$(cat $data | sed -n 3p)
if [ ${#img_url} -gt 1 ]; then
PLEROMA_BACKGROUND_IMAGE_URL=$img_url
fi
if [ $PLEROMA_DOMAIN_NAME ]; then
if [[ $PLEROMA_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
PLEROMA_DOMAIN_NAME=""
fi
TEST_DOMAIN_NAME=$PLEROMA_DOMAIN_NAME
validate_domain_name
if [[ $TEST_DOMAIN_NAME != $PLEROMA_DOMAIN_NAME ]]; then
PLEROMA_DOMAIN_NAME=
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
PLEROMA_CODE=$(cat $data | sed -n 4p)
validate_freedns_code "$PLEROMA_CODE"
if [ ! $VALID_CODE ]; then
PLEROMA_DOMAIN_NAME=
fi
fi
fi
fi
if [ $PLEROMA_DOMAIN_NAME ]; then
PLEROMA_DETAILS_COMPLETE="yes"
fi
done
# remove any invalid characters
if [ ${#PLEROMA_TITLE} -gt 0 ]; then
new_title=$(echo "$PLEROMA_TITLE" | sed "s|'||g")
PLEROMA_TITLE="$new_title"
fi
# save the results in the config file
write_config_param "PLEROMA_CODE" "$PLEROMA_CODE"
write_config_param "PLEROMA_TITLE" "$PLEROMA_TITLE"
write_config_param "PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_BACKGROUND_IMAGE_URL"
fi
write_config_param "PLEROMA_DOMAIN_NAME" "$PLEROMA_DOMAIN_NAME"
APP_INSTALLED=1
}
function change_password_pleroma {
curr_username="$1"
new_user_password="$2"
#${PROJECT_NAME}-pass -u "$curr_username" -a pleroma -p "$new_user_password"
}
2018-01-09 20:51:20 +01:00
function pleroma_create_database_failed {
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
}
2017-11-06 12:29:20 +01:00
function pleroma_create_database {
if [ -f $IMAGE_PASSWORD_FILE ]; then
PLEROMA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
if [ ! $PLEROMA_ADMIN_PASSWORD ]; then
PLEROMA_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
fi
if [ ! $PLEROMA_ADMIN_PASSWORD ]; then
return
fi
2017-11-07 19:44:33 +01:00
systemctl restart postgresql
2017-11-06 12:29:20 +01:00
add_postgresql_user pleroma "$PLEROMA_ADMIN_PASSWORD" encrypted
run_system_query_postgresql "create database pleroma;"
# temporarily allow the user to create databases
run_system_query_postgresql "ALTER USER pleroma CREATEDB;"
run_system_query_postgresql "ALTER USER pleroma SUPERUSER;"
2017-11-06 12:29:20 +01:00
run_system_query_postgresql "GRANT ALL ON ALL tables IN SCHEMA public TO pleroma;"
run_system_query_postgresql "GRANT ALL ON ALL sequences IN SCHEMA public TO pleroma;"
2017-11-06 16:56:36 +01:00
run_system_query_postgresql "CREATE EXTENSION citext;"
2017-11-12 16:55:04 +01:00
run_system_query_postgresql "set statement_timeout to 40000;"
2017-11-06 12:29:20 +01:00
2017-11-06 19:49:35 +01:00
read_config_param "PLEROMA_SECRET_KEY"
2017-11-07 22:17:18 +01:00
if [ ${#PLEROMA_SECRET_KEY} -lt 64 ]; then
PLEROMA_SECRET_KEY="$(create_password 30)$(create_password 30)$(create_password 30)"
if [ ${#PLEROMA_SECRET_KEY} -lt 64 ]; then
2018-01-09 20:51:20 +01:00
pleroma_create_database_failed
2017-11-06 19:49:35 +01:00
echo $'Pleroma secret key not created'
exit 6782352
fi
write_config_param "PLEROMA_SECRET_KEY" "$PLEROMA_SECRET_KEY"
fi
2018-01-09 11:37:24 +01:00
if [ ! -d $PLEROMA_DIR/config ]; then
echo $"Missing directory $PLEROMA_DIR/config"
exit 7835393
fi
pleroma_secret=$PLEROMA_DIR/config/dev.secret.exs
2018-01-09 11:37:24 +01:00
if [ ! -f $PLEROMA_DIR/config/dev.exs ]; then
echo $"Did not find $PLEROMA_DIR/config/dev.exs"
exit 78923528
fi
cp $PLEROMA_DIR/config/dev.exs $pleroma_secret
2017-11-06 15:15:33 +01:00
sed -i "s|username:.*|username: \"pleroma\",|g" $pleroma_secret
sed -i "s|password:.*|password: \"$PLEROMA_ADMIN_PASSWORD\",|g" $pleroma_secret
sed -i "s|database:.*|database: \"pleroma\",|g" $pleroma_secret
2017-11-06 19:49:35 +01:00
sed -i "/Pleroma.Web.Endpoint/a secret_key_base: \"$PLEROMA_SECRET_KEY\"," $pleroma_secret
sed -i 's|secret_key_base: | secret_key_base: |g' $pleroma_secret
2017-11-06 18:27:05 +01:00
sed -i "/Pleroma.Web.Endpoint/a pubsub: [name: Pleroma.Web.PubSub, adapter: Phoenix.PubSub.PG2]," $pleroma_secret
sed -i 's|pubsub: | pubsub: |g' $pleroma_secret
sed -i 's|watchers: []|watchers: [],|g' $pleroma_secret
2017-11-08 13:54:36 +01:00
if [[ $ONION_ONLY == 'no' ]]; then
sed -i "/watchers: []/a url: [host: \"$PLEROMA_DOMAIN_NAME\", scheme: \"https\", port: 443]" $pleroma_secret
else
sed -i "/watchers: []/a url: [host: \"$PLEROMA_ONION_HOSTNAME\", scheme: \"http\", port: 80]" $pleroma_secret
fi
sed -i 's|url: | url: |g' $pleroma_secret
if ! grep -q "pbkdf2_rounds" $pleroma_secret; then
sed -i '/config :logger/a config :comeonin, :pbkdf2_rounds, 1' $pleroma_secret
else
sed -i 's|pbkdf2_rounds.*|pbkdf2_rounds, 1|g' $pleroma_secret
fi
2018-01-09 20:34:14 +01:00
sed -i 's|import_config|# import_config|g' $pleroma_secret
2017-11-06 15:15:33 +01:00
2017-11-06 13:41:26 +01:00
cd $PLEROMA_DIR
2018-01-09 11:37:24 +01:00
chown -R pleroma:pleroma $PLEROMA_DIR/*
sudo -u pleroma mix local.rebar --force
2017-11-06 15:20:56 +01:00
if [ ! "$?" = "0" ]; then
2018-01-09 20:51:20 +01:00
pleroma_create_database_failed
2017-11-06 15:20:56 +01:00
echo $'mix local.rebar failed'
exit 73528562
fi
sudo -u pleroma mix local.hex --force
sudo -u pleroma mix deps.compile mimerl
systemctl restart postgresql
sudo -u pleroma mix ecto.create --force
2017-11-06 15:20:56 +01:00
if [ ! "$?" = "0" ]; then
2018-01-09 20:51:20 +01:00
pleroma_create_database_failed
2017-11-06 15:20:56 +01:00
echo $'mix ecto.create failed'
exit 83653582
fi
sudo -u pleroma mix ecto.migrate --force
2017-11-06 15:20:56 +01:00
if [ ! "$?" = "0" ]; then
2018-01-09 20:51:20 +01:00
pleroma_create_database_failed
2017-11-06 15:20:56 +01:00
echo $'mix ecto.migrate failed'
exit 73752573
fi
# revoke the ability to create databases for this user
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
2017-11-06 12:29:20 +01:00
}
function reconfigure_pleroma {
echo -n ''
}
function pleroma_set_background_image {
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Pleroma" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Set a background image URL' 10 60 2>$data
sel=$?
case $sel in
0)
temp_background=$(<$data)
if [ ${#temp_background} -gt 0 ]; then
PLEROMA_BACKGROUND_IMAGE_URL="$temp_background"
write_config_param "PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_BACKGROUND_IMAGE_URL"
if [[ $(pleroma_set_background_image_from_url $PLEROMA_DIR "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE" | tail -n 1) == "0" ]]; then
2017-11-06 21:37:15 +01:00
pleroma_recompile
2017-11-06 12:29:20 +01:00
dialog --title $"Set Pleroma login background" \
--msgbox $"The background image has been set" 6 60
fi
fi
;;
esac
rm $data
}
function pleroma_set_title {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Pleroma" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Set a title' 10 60 2>$data
sel=$?
case $sel in
0)
new_title=$(<$data)
if [ ${#new_title} -gt 0 ]; then
PLEROMA_TITLE="$new_title"
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
write_config_param "PLEROMA_TITLE" "$PLEROMA_TITLE"
sed -i "s|\"name\":.*|\"name\": \"${PLEROMA_TITLE}\",|g" $PLEROMA_DIR/static/config.json
sed -i "s|\"name\":.*|\"name\": \"${PLEROMA_TITLE}\",|g" $PLEROMA_DIR/priv/static/static/config.json
2017-11-06 14:36:51 +01:00
sed -i "s|name: .*|name: \"${PLEROMA_TITLE}\",|g" $PLEROMA_DIR/config/config.exs
systemctl restart pleroma
2017-11-06 12:29:20 +01:00
dialog --title $"Set Pleroma title" \
--msgbox $"The title has been set" 6 60
fi
;;
esac
rm $data
}
function pleroma_set_expire_months {
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
2018-01-20 22:09:25 +01:00
read_config_param "PLEROMA_DOMAIN_NAME"
2017-11-06 12:29:20 +01:00
read_config_param "PLEROMA_EXPIRE_MONTHS"
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Pleroma" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Set an expiry period for posts in months. Anything older will be deleted. Lower values help to keep the database size small and as fast as possible.' 12 60 "$PLEROMA_EXPIRE_MONTHS" 2>$data
sel=$?
case $sel in
0)
new_expiry_months=$(<$data)
if [ ${#new_expiry_months} -gt 0 ]; then
# should contain no spaces
if [[ "$new_expiry_months" == *" "* ]]; then
return
fi
# should be a number
re='^[0-9]+$'
if ! [[ $new_expiry_months =~ $re ]] ; then
return
fi
# set the new value
PLEROMA_EXPIRE_MONTHS=$new_expiry_months
write_config_param "PLEROMA_EXPIRE_MONTHS" "$PLEROMA_EXPIRE_MONTHS"
2018-01-20 22:09:25 +01:00
expire_pleroma_posts $PLEROMA_DOMAIN_NAME $PLEROMA_EXPIRE_MONTHS
2018-01-21 18:56:39 +01:00
create_pleroma_blocklist
2017-11-06 12:29:20 +01:00
dialog --title $"Set Pleroma post expiry period" \
--msgbox $"Expiry period set to $PLEROMA_EXPIRE_MONTHS months" 6 60
fi
;;
esac
rm $data
}
function pleroma_disable_registrations {
dialog --title $"Disable new Pleroma user registrations" \
--backtitle $"Freedombone Control Panel" \
--yesno $"\nDo you wish to disable new registrations?" 10 60
sel=$?
case $sel in
0) sed -i 's|registrations_open:.*|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen":.*|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
;;
1) sed -i 's|registrations_open:.*|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen":.*|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
;;
255) return;;
esac
pleroma_recompile
}
2017-11-10 23:41:55 +01:00
function pleroma_add_emoji {
2017-11-11 14:04:13 +01:00
emoji_resolution='128x128'
2017-11-10 23:41:55 +01:00
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Add Custom Emoji" \
--form "\n" 8 75 2 \
$"Shortcode:" 1 1 "" 1 18 16 15 \
$"ImageURL:" 2 1 "" 2 18 512 10000 \
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
shortcode=$(cat $data | sed -n 1p)
image_url=$(cat $data | sed -n 2p)
rm $data
if [ ${#shortcode} -lt 2 ]; then
return
fi
if [ ${#image_url} -lt 2 ]; then
return
fi
if [[ "$image_url" != *'.'* ]]; then
return
fi
if [[ "$image_url" != *'.png' && "$image_url" != *'.jpg' && "$image_url" != *'.jpeg' && "$image_url" != *'.gif' ]]; then
dialog --title $"Add Custom Emoji" \
--msgbox $"The image must be png/jpg/gif format" 6 60
return
fi
if [[ "$shortcode" == *':'* || "$shortcode" == *' '* || "$shortcode" == *'.'* || "$shortcode" == *'!'* ]]; then
dialog --title $"Add Custom Emoji" \
--msgbox $"The shortcode contains invalid characters" 6 60
return
fi
image_extension='png'
if [[ "$image_url" == *'.jpg' || "$image_url" == *'.jpeg' ]]; then
image_extension='jpg'
fi
if [[ "$image_url" == *'.gif' ]]; then
image_extension='gif'
fi
2017-11-11 12:57:52 +01:00
if [ ! -d $PLEROMA_DIR/priv/static/emoji ]; then
mkdir -p $PLEROMA_DIR/priv/static/emoji
2017-11-10 23:41:55 +01:00
fi
2017-11-11 12:57:52 +01:00
image_filename=$PLEROMA_DIR/priv/static/emoji/${shortcode}.${image_extension}
2017-11-10 23:41:55 +01:00
wget "$image_url" -O $image_filename
if [ ! -f $image_filename ]; then
dialog --title $"Add Custom Emoji" \
--msgbox $"Unable to download the image" 6 60
return
fi
2017-11-11 11:00:12 +01:00
if [[ "$image_url" == *'.jpg' || "$image_url" == *'.jpeg' || "$image_url" == *'.gif' ]]; then
2017-11-11 12:57:52 +01:00
convert $image_filename -resize $emoji_resolution $PLEROMA_DIR/priv/static/emoji/${shortcode}.png
if [ ! -f $PLEROMA_DIR/priv/static/emoji/${shortcode}.png ]; then
2017-11-11 11:00:12 +01:00
dialog --title $"Add Custom Emoji" \
--msgbox $"Unable to convert empji image to png format" 6 60
return
fi
2017-11-11 12:33:36 +01:00
# remove the original
rm $image_filename
2017-11-11 11:00:12 +01:00
image_extension='png'
2017-11-11 12:57:52 +01:00
image_filename=$PLEROMA_DIR/priv/static/emoji/${shortcode}.${image_extension}
else
convert $image_filename -resize $emoji_resolution $image_filename
2017-11-11 11:00:12 +01:00
fi
2017-11-11 13:45:31 +01:00
if ! grep -q "${shortcode}," $PLEROMA_DIR/config/emoji.txt; then
2017-11-11 12:58:20 +01:00
echo "${shortcode}, /emoji/${shortcode}.${image_extension}" >> $PLEROMA_DIR/config/emoji.txt
2017-11-10 23:41:55 +01:00
else
2017-11-11 12:58:20 +01:00
sed -i "s|${shortcode},.*|${shortcode}, /emoji/${shortcode}.${image_extension}|g" $PLEROMA_DIR/config/emoji.txt
2017-11-10 23:41:55 +01:00
fi
chown -R pleroma:pleroma $PLEROMA_DIR
clear
echo ''
echo $'Recompiling Pleroma with the new emoji'
systemctl stop pleroma
pleroma_recompile
dialog --title $"Add Custom Emoji" \
--msgbox $"Custom emoji :${shortcode}: has been added" 6 70
}
2017-11-06 12:29:20 +01:00
function configure_interactive_pleroma {
2018-01-20 22:09:25 +01:00
read_config_param PLEROMA_DOMAIN_NAME
2017-11-06 12:29:20 +01:00
read_config_param PLEROMA_EXPIRE_MONTHS
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Pleroma" \
2017-11-10 23:41:55 +01:00
--radiolist $"Choose an operation:" 15 70 6 \
2017-11-06 12:29:20 +01:00
1 $"Set a background image" off \
2 $"Set the title" off \
3 $"Disable new account registrations" off \
2017-11-10 23:41:55 +01:00
4 $"Add a custom emoji" off \
5 $"Set post expiry period (currently $PLEROMA_EXPIRE_MONTHS months)" off \
6 $"Exit" on 2> $data
2017-11-06 12:29:20 +01:00
sel=$?
case $sel in
1) return;;
255) return;;
esac
case $(cat $data) in
1) pleroma_set_background_image;;
2) pleroma_set_title;;
3) pleroma_disable_registrations;;
2017-11-10 23:41:55 +01:00
4) pleroma_add_emoji;;
5) pleroma_set_expire_months;;
6) break;;
2017-11-06 12:29:20 +01:00
esac
rm $data
done
}
function upgrade_pleroma {
2018-01-20 22:09:25 +01:00
read_config_param PLEROMA_DOMAIN_NAME
2018-01-20 22:11:45 +01:00
read_config_param PLEROMA_EXPIRE_MONTHS
2018-01-20 22:09:25 +01:00
if [ ! -f $pleroma_expire_posts_script ]; then
expire_pleroma_posts $PLEROMA_DOMAIN_NAME $PLEROMA_EXPIRE_MONTHS
fi
2018-01-21 18:56:39 +01:00
if [ ! -f $blocking_script_file ]; then
create_pleroma_blocklist
fi
2018-01-20 22:09:25 +01:00
2017-11-06 21:03:42 +01:00
CURR_PLEROMA_COMMIT=$(get_completion_param "pleroma commit")
if [[ "$CURR_PLEROMA_COMMIT" == "$PLEROMA_COMMIT" ]]; then
return
fi
2017-11-06 12:29:20 +01:00
2017-11-06 21:03:42 +01:00
function_check set_repo_commit
set_repo_commit $PLEROMA_DIR "pleroma commit" "$PLEROMA_COMMIT" $PLEROMA_REPO
chown -R pleroma:pleroma $PLEROMA_DIR
2017-11-12 14:56:21 +01:00
sudo -u pleroma mix deps.get
2017-11-06 21:03:42 +01:00
pleroma_recompile
2018-01-20 22:09:25 +01:00
expire_pleroma_posts $PLEROMA_DOMAIN_NAME $PLEROMA_EXPIRE_MONTHS
2018-01-21 18:56:39 +01:00
create_pleroma_blocklist
2017-11-06 21:03:42 +01:00
}
2017-11-06 12:29:20 +01:00
function backup_local_pleroma {
PLEROMA_DOMAIN_NAME='pleroma'
if grep -q "pleroma domain" $COMPLETION_FILE; then
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
fi
function_check suspend_site
suspend_site ${PLEROMA_DOMAIN_NAME}
2017-11-06 13:41:26 +01:00
source_directory=$PLEROMA_DIR
2017-11-06 12:29:20 +01:00
dest_directory=pleroma
backup_directory_to_usb $source_directory $dest_directory
USE_POSTGRESQL=1
function_check backup_database_to_usb
backup_database_to_usb pleroma
function_check restart_site
restart_site
}
function restore_local_pleroma {
if ! grep -q "pleroma domain" $COMPLETION_FILE; then
return
fi
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
if [ $PLEROMA_DOMAIN_NAME ]; then
echo $"Restoring pleroma"
temp_restore_dir=/root/temppleroma
2017-11-06 13:41:26 +01:00
pleroma_dir=$PLEROMA_DIR
2017-11-06 12:29:20 +01:00
2017-11-08 13:54:36 +01:00
PLEROMA_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_pleroma/hostname)
2017-11-06 12:29:20 +01:00
function_check pleroma_create_database
pleroma_create_database
USE_POSTGRESQL=1
restore_database pleroma
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir pleroma
if [ -d $temp_restore_dir ]; then
2017-11-06 14:10:09 +01:00
chown -R pleroma:pleroma $pleroma_dir
2017-11-06 12:29:20 +01:00
rm -rf $temp_restore_dir
fi
echo $"Restore of pleroma complete"
fi
}
function backup_remote_pleroma {
PLEROMA_DOMAIN_NAME='pleroma'
if grep -q "pleroma domain" $COMPLETION_FILE; then
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
fi
function_check suspend_site
suspend_site ${PLEROMA_DOMAIN_NAME}
2017-11-06 13:41:26 +01:00
source_directory=$PLEROMA_DIR
2017-11-06 12:29:20 +01:00
dest_directory=pleroma
backup_directory_to_friend $source_directory $dest_directory
USE_POSTGRESQL=1
function_check backup_database_to_friend
backup_database_to_friend pleroma
function_check restart_site
restart_site
}
function restore_remote_pleroma {
if ! grep -q "pleroma domain" $COMPLETION_FILE; then
return
fi
PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain")
if [ $PLEROMA_DOMAIN_NAME ]; then
echo $"Restoring pleroma"
temp_restore_dir=/root/temppleroma
2017-11-06 13:41:26 +01:00
pleroma_dir=$PLEROMA_DIR
2017-11-06 12:29:20 +01:00
2017-11-08 13:54:36 +01:00
PLEROMA_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_pleroma/hostname)
2017-11-06 12:29:20 +01:00
function_check pleroma_create_database
pleroma_create_database
USE_POSTGRESQL=1
function_check restore_database_from_friend
restore_database_from_friend pleroma
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir pleroma
if [ -d $temp_restore_dir ]; then
2017-11-06 14:10:09 +01:00
chown -R pleroma:pleroma $pleroma_dir
2017-11-06 12:29:20 +01:00
rm -rf $temp_restore_dir
fi
pleroma_update_after_restore pleroma ${PLEROMA_DOMAIN_NAME}
echo $"Restore of pleroma complete"
fi
}
function remove_pleroma {
if [ ${#PLEROMA_DOMAIN_NAME} -eq 0 ]; then
return
fi
systemctl stop pleroma
systemctl disable pleroma
rm /etc/systemd/system/pleroma.service
2017-11-06 14:10:09 +01:00
userdel pleroma
2017-11-12 15:52:07 +01:00
#apt-get -yq remove esl-erlang elixir erlang-xmerl erlang-dev erlang-parsetools
2017-11-06 13:41:26 +01:00
2017-11-06 12:29:20 +01:00
function_check remove_nodejs
remove_nodejs pleroma-backend
read_config_param "PLEROMA_DOMAIN_NAME"
read_config_param "MY_USERNAME"
echo "Removing $PLEROMA_DOMAIN_NAME"
nginx_dissite $PLEROMA_DOMAIN_NAME
remove_certs $PLEROMA_DOMAIN_NAME
if [ -d /var/www/$PLEROMA_DOMAIN_NAME ]; then
rm -rf /var/www/$PLEROMA_DOMAIN_NAME
fi
if [ -f /etc/nginx/sites-available/$PLEROMA_DOMAIN_NAME ]; then
rm /etc/nginx/sites-available/$PLEROMA_DOMAIN_NAME
fi
2017-11-06 13:41:26 +01:00
if [ -d $PLEROMA_DIR ]; then
rm -rf $PLEROMA_DIR
fi
2017-11-06 12:29:20 +01:00
function_check drop_database_postgresql
2017-11-07 12:44:34 +01:00
drop_database_postgresql pleroma
2017-11-06 12:29:20 +01:00
function_check remove_onion_service
remove_onion_service pleroma ${PLEROMA_ONION_PORT}
remove_app pleroma
remove_completion_param install_pleroma
2017-11-06 13:41:26 +01:00
sed -i '/pleroma domain/d' $COMPLETION_FILE
sed -i '/pleroma commit/d' $COMPLETION_FILE
2018-01-21 18:56:39 +01:00
sed -i "/$blocking_script_file/d" /etc/crontab
2017-11-06 12:29:20 +01:00
function_check remove_ddns_domain
remove_ddns_domain $PLEROMA_DOMAIN_NAME
}
function install_elixir {
apt-get -yq install wget build-essential
if [ ! -d $INSTALL_DIR ]; then
mkdir -p $INSTALL_DIR
fi
cd $INSTALL_DIR
erlang_package=erlang-solutions_1.0_all.deb
wget https://packages.erlang-solutions.com/$erlang_package
if [ ! -f $INSTALL_DIR/$erlang_package ]; then
exit 72853
fi
dpkg -i $erlang_package
apt-get -yq update
apt-get -yq install esl-erlang
apt-get -yq install elixir erlang-xmerl erlang-dev erlang-parsetools
2017-11-06 12:29:20 +01:00
2017-11-06 12:38:58 +01:00
if [ ! -f /usr/local/bin/mix ]; then
echo $'/usr/local/bin/mix not found after elixir installation'
2017-11-06 12:29:20 +01:00
exit 629352
fi
}
function install_pleroma {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
2018-01-20 23:14:00 +01:00
apt-get -yq install wget imagemagick
2017-11-11 11:00:12 +01:00
2017-11-06 12:29:20 +01:00
# We need elixir 1.4+ here, so the debian repo package won't do
install_elixir
function_check install_nodejs
install_nodejs pleroma-backend
install_postgresql
if [ ! -d /var/www/${PLEROMA_DOMAIN_NAME}/htdocs ]; then
mkdir -p /var/www/${PLEROMA_DOMAIN_NAME}/htdocs
2017-11-06 12:29:20 +01:00
fi
2017-11-06 13:41:26 +01:00
if [ -d $PLEROMA_DIR ]; then
rm -rf $PLEROMA_DIR
fi
2017-11-06 12:29:20 +01:00
2017-11-06 13:41:26 +01:00
# get the repo
2017-11-06 14:52:00 +01:00
if [ -f /repos/pleroma/index.html ]; then
mv /repos/pleroma /repos/pleroma-fe
fi
2017-11-06 13:41:26 +01:00
if [ -d /repos/pleroma ]; then
mkdir -p $PLEROMA_DIR
cp -r -p /repos/pleroma/. $PLEROMA_DIR
cd $PLEROMA_DIR
git pull
else
function_check git_clone
git_clone $PLEROMA_REPO $PLEROMA_DIR
2017-11-06 12:29:20 +01:00
fi
2017-11-06 13:41:26 +01:00
if [ ! -d $PLEROMA_DIR ]; then
echo $'Unable to clone pleroma backend repo'
exit 783523
fi
# create user
useradd -d $PLEROMA_DIR -s /bin/false pleroma
2017-11-06 13:41:26 +01:00
# checkout the commit
cd $PLEROMA_DIR
2017-11-06 12:29:20 +01:00
git checkout $PLEROMA_COMMIT -b $PLEROMA_COMMIT
set_completion_param "pleroma commit" "$PLEROMA_COMMIT"
2017-11-06 13:41:26 +01:00
chown -R pleroma:pleroma $PLEROMA_DIR
2017-11-06 12:29:20 +01:00
# web config
function_check add_ddns_domain
add_ddns_domain $PLEROMA_DOMAIN_NAME
PLEROMA_ONION_HOSTNAME=$(add_onion_service pleroma 80 ${PLEROMA_ONION_PORT})
pleroma_nginx_site=/etc/nginx/sites-available/$PLEROMA_DOMAIN_NAME
if [[ $ONION_ONLY == "no" ]]; then
function_check nginx_http_redirect
nginx_http_redirect $PLEROMA_DOMAIN_NAME "index index.html"
echo 'server {' >> $pleroma_nginx_site
echo ' listen 443 ssl;' >> $pleroma_nginx_site
echo ' listen [::]:443 ssl;' >> $pleroma_nginx_site
echo " server_name $PLEROMA_DOMAIN_NAME;" >> $pleroma_nginx_site
echo '' >> $pleroma_nginx_site
function_check nginx_compress
nginx_compress $PLEROMA_DOMAIN_NAME
echo '' >> $pleroma_nginx_site
echo ' # Security' >> $pleroma_nginx_site
function_check nginx_ssl
nginx_ssl $PLEROMA_DOMAIN_NAME
function_check nginx_disable_sniffing
nginx_disable_sniffing $PLEROMA_DOMAIN_NAME
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $pleroma_nginx_site
echo '' >> $pleroma_nginx_site
echo ' # Logs' >> $pleroma_nginx_site
echo ' access_log /dev/null;' >> $pleroma_nginx_site
echo ' error_log /dev/null;' >> $pleroma_nginx_site
echo '' >> $pleroma_nginx_site
2017-11-06 13:41:26 +01:00
echo " root $PLEROMA_DIR;" >> $pleroma_nginx_site
2017-11-06 12:29:20 +01:00
echo '' >> $pleroma_nginx_site
echo ' index index.html;' >> $pleroma_nginx_site
echo ' location / {' >> $pleroma_nginx_site
function_check nginx_limits
nginx_limits $PLEROMA_DOMAIN_NAME '15m'
echo " proxy_pass http://localhost:$PLEROMA_PORT;" >> $pleroma_nginx_site
echo ' }' >> $pleroma_nginx_site
2017-11-06 14:52:00 +01:00
echo ' # include snippets/well-known.conf;' >> $pleroma_nginx_site
2017-11-06 12:29:20 +01:00
echo '}' >> $pleroma_nginx_site
else
echo -n '' > $pleroma_nginx_site
fi
echo 'server {' >> $pleroma_nginx_site
echo " listen 127.0.0.1:$PLEROMA_ONION_PORT default_server;" >> $pleroma_nginx_site
echo " server_name $PLEROMA_ONION_HOSTNAME;" >> $pleroma_nginx_site
echo '' >> $pleroma_nginx_site
function_check nginx_compress
nginx_compress $PLEROMA_DOMAIN_NAME
echo '' >> $pleroma_nginx_site
function_check nginx_disable_sniffing
nginx_disable_sniffing $PLEROMA_DOMAIN_NAME
echo '' >> $pleroma_nginx_site
echo ' # Logs' >> $pleroma_nginx_site
echo ' access_log /dev/null;' >> $pleroma_nginx_site
echo ' error_log /dev/null;' >> $pleroma_nginx_site
echo '' >> $pleroma_nginx_site
2017-11-06 13:41:26 +01:00
echo " root $PLEROMA_DIR;" >> $pleroma_nginx_site
2017-11-06 12:29:20 +01:00
echo '' >> $pleroma_nginx_site
echo ' index index.html;' >> $pleroma_nginx_site
echo ' location / {' >> $pleroma_nginx_site
function_check nginx_limits
nginx_limits $PLEROMA_DOMAIN_NAME '15m'
echo " proxy_pass http://localhost:$PLEROMA_PORT;" >> $pleroma_nginx_site
echo ' }' >> $pleroma_nginx_site
2017-11-06 14:52:00 +01:00
echo ' # include snippets/well-known.conf;' >> $pleroma_nginx_site
2017-11-06 12:29:20 +01:00
echo '}' >> $pleroma_nginx_site
# back end
2017-11-06 13:41:26 +01:00
cd $PLEROMA_DIR
chown -R pleroma:pleroma *
sudo -u pleroma mix local.hex --force
2017-11-06 15:20:56 +01:00
if [ ! "$?" = "0" ]; then
echo $'mix local.hex failed'
exit 1745673
fi
sudo -u pleroma mix deps.get --force
2017-11-06 15:20:56 +01:00
if [ ! "$?" = "0" ]; then
echo $'mix deps.get failed'
exit 7325733
fi
2017-11-06 12:29:20 +01:00
function_check pleroma_create_database
pleroma_create_database
2017-11-06 15:15:33 +01:00
${PROJECT_NAME}-pass -u $MY_USERNAME -a pleroma -p "$PLEROMA_ADMIN_PASSWORD"
2017-11-06 12:29:20 +01:00
2017-11-07 11:31:49 +01:00
# NOTE: we don't need to install the frontend separately,
# since the backend contains a precompiled version of it
install_gnusocial_default_background "pleroma" "$PLEROMA_DOMAIN_NAME"
if [ ! -f $PLEROMA_DIR/priv/static/static/config.json ]; then
2017-11-07 11:58:10 +01:00
echo $"$PLEROMA_DIR/priv/static/static/config.json file missing"
exit 323689
fi
2017-11-07 11:57:15 +01:00
sed -i 's|"theme":.*|"theme": "base16-summerfruit-dark.css",|g' $PLEROMA_DIR/priv/static/static/config.json
2017-11-06 12:29:20 +01:00
if [ $PLEROMA_BACKGROUND_IMAGE_URL ]; then
2017-11-07 11:31:49 +01:00
pleroma_set_background_image_from_url $PLEROMA_DIR/priv/static "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE"
2017-11-06 12:29:20 +01:00
fi
# Get certificate
function_check create_site_certificate
create_site_certificate $PLEROMA_DOMAIN_NAME 'yes'
function_check nginx_ensite
nginx_ensite $PLEROMA_DOMAIN_NAME
systemctl restart postgresql
systemctl restart nginx
set_completion_param "pleroma domain" "$PLEROMA_DOMAIN_NAME"
2017-11-12 18:54:43 +01:00
# We need to set up the url option again because it somehow gets
# lost during mix compile
pleroma_secret=$PLEROMA_DIR/config/dev.secret.exs
2017-11-12 18:54:43 +01:00
if ! grep -q 'watchers: [],' $pleroma_secret; then
2018-01-16 10:56:13 +01:00
sed -i 's|watchers: \[\]|watchers: \[\],|g' $pleroma_secret
2017-11-12 18:54:43 +01:00
fi
if ! grep -q 'url:' $pleroma_secret; then
if [[ $ONION_ONLY == 'no' ]]; then
2018-01-16 10:56:13 +01:00
sed -i "/watchers: /a url: [host: \"$PLEROMA_DOMAIN_NAME\", scheme: \"https\", port: 443]" $pleroma_secret
2017-11-12 18:54:43 +01:00
else
2018-01-16 10:56:13 +01:00
sed -i "/watchers: /a url: [host: \"$PLEROMA_ONION_HOSTNAME\", scheme: \"http\", port: 80]" $pleroma_secret
2017-11-12 18:54:43 +01:00
fi
fi
2018-01-21 18:56:39 +01:00
create_pleroma_blocklist
2017-11-06 12:29:20 +01:00
# daemon
echo '[Unit]' > /etc/systemd/system/pleroma.service
echo 'Description=Pleroma social network' >> /etc/systemd/system/pleroma.service
echo 'After=network.target postgresql.service' >> /etc/systemd/system/pleroma.service
echo '' >> /etc/systemd/system/pleroma.service
echo '[Service]' >> /etc/systemd/system/pleroma.service
echo 'User=pleroma' >> /etc/systemd/system/pleroma.service
2017-11-06 18:55:20 +01:00
echo "WorkingDirectory=$PLEROMA_DIR" >> /etc/systemd/system/pleroma.service
2017-11-06 13:41:26 +01:00
echo "Environment=\"HOME=$PLEROMA_DIR\"" >> /etc/systemd/system/pleroma.service
2017-11-06 12:38:58 +01:00
echo 'ExecStart=/usr/local/bin/mix phx.server' >> /etc/systemd/system/pleroma.service
2017-11-06 12:29:20 +01:00
echo 'ExecReload=/bin/kill $MAINPID' >> /etc/systemd/system/pleroma.service
echo 'KillMode=process' >> /etc/systemd/system/pleroma.service
echo 'Restart=on-failure' >> /etc/systemd/system/pleroma.service
echo '' >> /etc/systemd/system/pleroma.service
echo '[Install]' >> /etc/systemd/system/pleroma.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/pleroma.service
echo 'Alias=pleroma.service' >> /etc/systemd/system/pleroma.service
systemctl daemon-reload
systemctl enable pleroma
systemctl start pleroma
APP_INSTALLED=1
}
# NOTE: deliberately there is no "exit 0"