Newer
Older
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
#
# 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/>.
PLEROMA_DOMAIN_NAME=
PLEROMA_CODE=
PLEROMA_PORT=4000
PLEROMA_ONION_PORT=8011
PLEROMA_REPO="https://git.pleroma.social/pleroma/pleroma.git"
PLEROMA_COMMIT='99fd199bda8bd90cd3e8c69d54087531ddc02eac'
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
# limit hellthreads with zillions of mentions
# whether the install function is running
pleroma_installing=
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_remove_setting {
pleroma_setting="$1"
if grep -q " ${pleroma_setting}:" $pleroma_secret; then
sed -i "/ ${pleroma_setting}:/d" $pleroma_secret
fi
}
function pleroma_deprecate_fe {
if ! grep -q 'config :pleroma, :fe, false' $pleroma_secret; then
sed -i 's|config :pleroma, :fe.*|config :pleroma, :fe, false|g' $pleroma_secret
fi
pleroma_remove_setting 'theme'
pleroma_remove_setting 'logo'
pleroma_remove_setting 'logo_mask'
pleroma_remove_setting 'logo_margin'
pleroma_remove_setting 'background'
pleroma_remove_setting 'redirect_root_no_login'
pleroma_remove_setting 'redirect_root_login'
pleroma_remove_setting 'show_instance_panel'
pleroma_remove_setting 'collapse_message_with_subject'
pleroma_remove_setting 'formatting_options_enabled'
pleroma_remove_setting 'hide_user_stats'
pleroma_remove_setting 'scope_options_enabled'
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
function pleroma_enable_web_push_encryption {
if grep -q 'web_push_encryption' "$pleroma_secret"; then
return
fi
cd $PLEROMA_DIR || return
sudo -u pleroma mix web_push.gen.keypair | sudo tee -a "$pleroma_secret"
sed -i "s|administrator@example.com|$MY_EMAIL_ADDRESS|g" "$pleroma_secret"
sed -i '/# Put the following/d' "$pleroma_secret"
if [ $pleroma_installing ]; then
increment_app_install_progress
fi
sudo -u postgres psql pleroma -c "create extension if not exists pg_trgm"
if [ $pleroma_installing ]; then
increment_app_install_progress
fi
sudo -u postgres psql pleroma -c 'create extension if not exists "uuid-ossp"'
if [ $pleroma_installing ]; then
increment_app_install_progress
fi
sudo -u pleroma mix ecto.migrate --force
if [ $pleroma_installing ]; then
increment_app_install_progress
fi
pleroma_recompile
if [ $pleroma_installing ]; then
increment_app_install_progress
fi
PLEROMA_PUSH_PUBLIC_KEY=$(grep "public_key:" "$pleroma_secret" | head -n 1 | awk -F '"' '{print $2}')
PLEROMA_PUSH_PRIVATE_KEY=$(grep "private_key:" "$pleroma_secret" | head -n 1 | awk -F '"' '{print $2}')
if [ "$PLEROMA_PUSH_PUBLIC_KEY" ]; then
write_config_param PLEROMA_PUSH_PUBLIC_KEY "$PLEROMA_PUSH_PUBLIC_KEY"
else
echo $'web_push_encryption failed: no public key'
return
fi
if [ "$PLEROMA_PUSH_PRIVATE_KEY" ]; then
write_config_param PLEROMA_PUSH_PRIVATE_KEY "$PLEROMA_PUSH_PRIVATE_KEY"
else
echo $'web_push_encryption failed: no private key'
return
fi
}
function pleroma_set_permissions {
# set permissions on directories
if [ -d "$PLEROMA_DIR/config" ]; then
chmod 644 "$PLEROMA_DIR/config"/*
fi
if [ -d "$PLEROMA_DIR/deps" ]; then
chmod -R 755 "$PLEROMA_DIR/deps"
fi
}
function pleroma_create_recompile_command {
{ echo '#!/bin/bash';
echo "cd $PLEROMA_DIR || exit 1";
echo "chown -R pleroma:pleroma $PLEROMA_DIR";
echo 'sudo -u pleroma mix clean';
echo 'sudo -u pleroma mix deps.compile';
echo 'sudo -u pleroma mix compile';
echo "chmod 644 $PLEROMA_DIR/config/*";
echo "chmod -R 755 $PLEROMA_DIR/deps/*";
echo 'systemctl restart pleroma'; } > /usr/bin/pleroma-recompile
chmod +x /usr/bin/pleroma-recompile
}
function pleroma_recompile {
# necessary after parameter changes
if [ ! -f /usr/bin/pleroma-recompile ]; then
pleroma_create_recompile_command
if ! grep -q 'chmod' /usr/bin/pleroma-recompile; then
pleroma_create_recompile_command
fi
function pleroma_setting_background {
pleroma_new_background="$1"
if [ "$pleroma_new_background" ]; then
url="$pleroma_new_background"
ext=
if [ ${#url} -gt 0 ]; then
if [[ "$url" == *".jpeg" || "$url" == *".jpg" ]]; then
ext="jpg"
fi
if [[ "$url" == *".png" ]]; then
Loading
Loading full blame...