Newer
Older
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
#
# functions common to GNU Social server varieties
#
# License
# =======
#
#
# 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/>.
# Qvitter upstream: https://git.gnu.io/h2p/Qvitter"
QVITTER_THEME_REPO="https://code.freedombone.net/bashrc/Qvitter"
QVITTER_THEME_COMMIT='c6f09bda4e45be4290cf7409fa5efb4420538032'
PLEROMA_FRONTEND_REPO="https://git.pleroma.social/pleroma/pleroma-fe.git"
PLEROMA_FRONTEND_COMMIT='3b3bbaab822b553f514a62d20d679acc5ce4414a'
SHARINGS_REPO="http://code.freedombone.net/bashrc/Sharings"
SHARINGS_COMMIT='0d30fe7d153c7ab44e8459970b8f2b5dec06e43c'
SHARINGS_THEME_REPO="http://code.freedombone.net/bashrc/SharingsTheme"
SHARINGS_THEME_COMMIT='a46ef375d19e8ef6889653668a7e697b0ba2013c'
GNUSOCIAL_MARKDOWN_REPO="https://git.gnu.io/chimo/markdown.git"
GNUSOCIAL_MARKDOWN_COMMIT='03c53942f94b3376f0946e6e1fe566cc21ccf232'
function gnusocial_set_limits {
filename="$1"
sed -i 's|client_body_buffer_size.*|client_body_buffer_size 5m;|g' "$filename"
sed -i 's|limit_conn conn_limit_per_ip.*|limit_conn conn_limit_per_ip 100;|g' "$filename"
sed -i 's|req_limit_per_ip.*|req_limit_per_ip burst=100 nodelay;|g' "$filename"
}
# Stuff to be done after restoring from backup
function gnusocial_update_after_restore {
cd "/var/www/${gnusocial_domain}/htdocs" || exit 36
# Ensure that the database password is correct
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
sed -i "s|\$config['db']['database'].*|\$config['db']['database'] = 'mysqli://root:${MARIADB_PASSWORD}@localhost/${gnusocial_variant}';|g" config.php
chmod g+w "/var/www/$gnusocial_domain/htdocs"
chmod a+w "/var/www/$gnusocial_domain/htdocs/avatar"
chmod a+w "/var/www/$gnusocial_domain/htdocs/file"
chown -R www-data:www-data "/var/www/$gnusocial_domain/htdocs"
chmod +x "/var/www/$gnusocial_domain/htdocs/scripts/maildaemon.php"
# This seems to be necessary to get the UI back
gnusocial_use_classic "$gnusocial_variant"
gnusocial_use_qvitter "$gnusocial_variant"
# start the daemons
su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
}
ext="$2"
if [ -d "/var/www/${domain_name}/htdocs/local/plugins/Qvitter/img" ]; then
if [ -f "bg_custom.${ext}" ]; then
cp "bg_custom.${ext}" "/var/www/${domain_name}/htdocs/local/plugins/Qvitter/img"
if ! grep -q "bg_custom.${ext}" "/var/www/${domain_name}/htdocs/config.php"; then
if grep -q 'sitebackground' "/var/www/${domain_name}/htdocs/config.php"; then
sed -i '/sitebackground/d' "/var/www/${domain_name}/htdocs/config.php"
echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> "/var/www/${domain_name}/htdocs/config.php"
function pleroma_custom_logo {
basedir="$1"
if [ "$2" ]; then
if [[ "$2" == *".png" ]]; then
cp "$2" "$basedir/priv/static/static/logo.png"
return
fi
fi
if [ -f "$HOME/${PROJECT_NAME}/img/logo_fbone3.png" ]; then
if [ -d "$basedir/static" ]; then
cp "$HOME/${PROJECT_NAME}/img/logo_fbone3.png" "$basedir/static/logo.png"
fi
cp "$HOME/${PROJECT_NAME}/img/logo_fbone3.png" "$basedir/priv/static/static/logo.png"
else
if [ -f "/home/$MY_USERNAME/${PROJECT_NAME}/img/logo_fbone3.png" ]; then
if [ -d "$basedir/static" ]; then
cp "/home/$MY_USERNAME/${PROJECT_NAME}/img/logo_fbone3.png" "$basedir/static/logo.png"
fi
cp "/home/$MY_USERNAME/${PROJECT_NAME}/img/logo_fbone3.png" "$basedir/priv/static/static/logo.png"
function pleroma_set_background_image_from_url {
basedir="$1"
domain_name="$2"
url="$3"
title="$4"
if [ ${#domain_name} -eq 0 ]; then
echo "1"
return
fi
ext="gif"
fi
fi
if [ ${#ext} -gt 0 ]; then
cd "$basedir" || exit 63
if [ -f "bg_custom.${ext}" ]; then
rm "bg_custom.${ext}"
wget "$url" -O "bg_custom.${ext}"
if [ ! -f "bg_custom.${ext}" ]; then
echo "$url"
echo $'Custom background image for pleroma could not be downloaded'
echo "1"
return
fi
if [ -d "$basedir/static" ]; then
cp "bg_custom.${ext}" "static/bg_custom.${ext}"
chown www-data:www-data "static/bg_custom.${ext}"
sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" static/config.json
if [ -f "$pleroma_secret" ]; then
if grep -q "\"background\":" "$pleroma_secret"; then
sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" "$pleroma_secret"
fi
if [ -d priv/static/static ]; then
cp "bg_custom.${ext}" "priv/static/static/bg_custom.${ext}"
chown www-data:www-data "priv/static/static/bg_custom.${ext}"
sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" priv/static/static/config.json
if [ -f "$pleroma_secret" ]; then
if grep -q "\"background\":" "$pleroma_secret"; then
sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" "$pleroma_secret"
fi
if [[ "$basedir" != "$PLEROMA_DIR" ]]; then
qvitter_update_background "${domain_name}" "${ext}"
if [ -f "$basedir/static/config.json" ]; then
sed -i "s|\"name\":.*|\"name\": \"${title}\",|g" "$basedir/static/config.json"
if [ -f "$basedir/priv/static/static/config.json" ]; then
Loading
Loading full blame...