Newer
Older
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
# Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
#
# 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/>.
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"
PLEROMA_COMMIT='7ca2a2ddeaa4396c86cd39a43a8fd0a4c8d3ce14'
pleroma_secret=$PLEROMA_DIR/config/dev.secret.exs
PLEROMA_BACKGROUND_IMAGE_URL=
PLEROMA_TITLE='Pleroma Server'
# Number of months after which posts expire
PLEROMA_EXPIRE_MONTHS=3
pleroma_expire_posts_script=/usr/bin/pleroma-expire-posts
PLEROMA_SHORT_DESCRIPTION=$'Federated microblogging'
PLEROMA_DESCRIPTION=$'Federated microblogging'
PLEROMA_MOBILE_APP_URL='https://f-droid.org/packages/com.keylesspalace.tusky'
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)
function pleroma_recompile {
# necessary after parameter changes
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
}
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function pleroma_setting_emoji {
shortcode="$1"
image_url="$2"
if [ ! "$shortcode" ]; then
return
fi
if [[ "$shortcode" == *' '* || "$shortcode" == *':'* ]]; then
return
fi
if [ ${#shortcode} -gt 32 ]; then
return
fi
if [[ "$image_url" != 'http'* ]]; then
return
fi
if [ ${#image_url} -gt 256 ]; then
return
fi
image_extension=
if [[ "$image_url" == *'.jpg' || "$image_url" == *'.jpeg' ]]; then
image_extension='jpg'
fi
if [[ "$image_url" == *'.gif' ]]; then
image_extension='gif'
fi
if [[ "$image_url" == *'.png' ]]; then
image_extension='png'
fi
if [ ! $image_extension ]; then
echo $'Invalid image type'
return
fi
if [ ! -d $PLEROMA_DIR/priv/static/emoji ]; then
mkdir -p $PLEROMA_DIR/priv/static/emoji
fi
image_filename=$PLEROMA_DIR/priv/static/emoji/${shortcode}.${image_extension}
if [ -f "$image_filename" ]; then
mv "$image_filename" "${image_filename}.prev"
fi
wget "$image_url" -O "$image_filename"
if [ ! -f "$image_filename" ]; then
if [ -f "${image_filename}.prev" ]; then
mv "${image_filename}.prev" "${image_filename}"
fi
rm "${image_filename}.prev"
if [[ "$image_url" == *'.jpg' || "$image_url" == *'.jpeg' || "$image_url" == *'.gif' ]]; then
convert "$image_filename" -resize "$emoji_resolution" "$PLEROMA_DIR/priv/static/emoji/${shortcode}.png"
if [ ! -f "$PLEROMA_DIR/priv/static/emoji/${shortcode}.png" ]; then
return
fi
# remove the original
rm "$image_filename"
image_extension='png'
image_filename=$PLEROMA_DIR/priv/static/emoji/${shortcode}.${image_extension}
else
convert "$image_filename" -resize "$emoji_resolution" "$image_filename"
fi
if ! grep -q "${shortcode}," $PLEROMA_DIR/config/emoji.txt; then
echo "${shortcode}, /emoji/${shortcode}.${image_extension}" >> $PLEROMA_DIR/config/emoji.txt
else
sed -i "s|${shortcode},.*|${shortcode}, /emoji/${shortcode}.${image_extension}|g" $PLEROMA_DIR/config/emoji.txt
fi
chown -R pleroma:pleroma $PLEROMA_DIR
}
function pleroma_setting_registration {
allow_registration="$1"
sed -i 's|registrations_open: false|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: False|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen": false|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|"registrationOpen": False|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|registrations_open: true|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: True|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen": true|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|"registrationOpen": True|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
function pleroma_enable_chat {
if [[ "$1" == 't'* || "$1" == 'y'* || "$1" == 'T'* || "$1" == 'Y'* ]]; then
sed -i 's|"chatDisabled":.*|"chatDisabled": false,|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|:chat, enabled:.*|:chat, enabled: true|g' $PLEROMA_DIR/config/config.exs
else
sed -i 's|"chatDisabled":.*|"chatDisabled": true,|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|:chat, enabled:.*|:chat, enabled: false|g' $PLEROMA_DIR/config/config.exs
fi
pleroma_recompile
}
echo "if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then";
echo ' exit 0';
echo 'fi';
Loading
Loading full blame...