2016-07-03 17:13:34 +02:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
2016-10-01 21:15:48 +02:00
# gnusocial application
2016-07-03 17:13:34 +02:00
#
# License
# =======
#
2017-04-05 12:23:04 +02:00
# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
2016-07-03 17:13:34 +02: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/>.
2016-10-12 11:49:12 +02:00
VARIANTS='full full-vim media'
2016-07-06 17:47:55 +02:00
2016-11-14 14:42:49 +01:00
IN_DEFAULT_INSTALL=0
2016-10-19 22:23:11 +02:00
SHOW_ON_ABOUT=1
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DOMAIN_NAME=
GNUSOCIAL_CODE=
GNUSOCIAL_ONION_PORT=8087
GNUSOCIAL_REPO="https://git.gnu.io/gnu/gnu-social.git"
2017-05-27 11:30:58 +02:00
GNUSOCIAL_COMMIT='1517deeeb621a0256106d0108855e8827713e2cc'
2016-10-16 14:54:28 +02:00
GNUSOCIAL_ADMIN_PASSWORD=
2017-02-22 21:51:23 +01:00
2016-10-16 14:54:28 +02:00
GNUSOCIAL_BACKGROUND_IMAGE_URL=
GNUSOCIAL_MARKDOWN_REPO="https://git.gnu.io/chimo/markdown.git"
GNUSOCIAL_MARKDOWN_COMMIT='03c53942f94b3376f0946e6e1fe566cc21ccf232'
# Sharings plugin for gnusocial
2016-07-03 17:13:34 +02:00
SHARINGS_REPO="http://git.lasindias.club/bashrc/Sharings"
SHARINGS_COMMIT='d5c6c7f855d9afff9086c09ea706f38c859bc0d4'
SHARINGS_THEME_REPO="http://git.lasindias.club/manuel/SharingsTheme"
SHARINGS_THEME_COMMIT='7106c7ef03'
2017-02-22 21:51:23 +01:00
GNUSOCIAL_TITLE='Pleroma FE'
2017-04-05 12:23:04 +02:00
# Number of months after which posts expire
GNUSOCIAL_EXPIRE_MONTHS=3
2016-11-24 19:37:10 +01:00
gnusocial_variables=(ONION_ONLY
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DOMAIN_NAME
GNUSOCIAL_CODE
GNUSOCIAL_WELCOME_MESSAGE
GNUSOCIAL_BACKGROUND_IMAGE_URL
2016-10-05 23:33:41 +02:00
DDNS_PROVIDER
2016-10-16 14:54:28 +02:00
GNUSOCIAL_MARKDOWN_REPO
GNUSOCIAL_MARKDOWN_COMMIT
2016-10-05 23:33:41 +02:00
SHARINGS_REPO
SHARINGS_COMMIT
SHARINGS_THEME_REPO
SHARINGS_THEME_COMMIT
2017-02-22 21:51:23 +01:00
GNUSOCIAL_TITLE
2017-04-05 12:23:04 +02:00
GNUSOCIAL_EXPIRE_MONTHS
2016-10-05 23:33:41 +02:00
MY_USERNAME)
2016-12-12 11:10:38 +01:00
function gnusocial_fix_endless_reloads {
# This fixes a bug introduced with commit 5f7032dfee1fd202c14e76a9f8b37af35d584901
# and which causes OrFox to endlessly reload the page
sed -i 's| && common_local_referer()||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/lib/apiauthaction.php
}
2016-10-02 12:17:01 +02:00
function remove_user_gnusocial {
remove_username="$1"
2016-11-19 20:17:33 +01:00
${PROJECT_NAME}-pass -u $remove_username --rmapp gnusocial
2016-10-16 20:50:56 +02:00
function_check get_completion_param
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-10-16 14:54:28 +02:00
if [ -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-10-02 12:17:01 +02:00
php scripts/deleteprofile.php -n $remove_username -y
2016-10-02 00:39:56 +02:00
fi
2016-10-02 12:17:01 +02:00
}
2016-10-02 00:39:56 +02:00
2016-10-02 12:17:01 +02:00
function add_user_gnusocial {
2016-10-02 00:39:56 +02:00
new_username="$1"
new_user_password="$2"
2016-11-19 20:17:33 +01:00
${PROJECT_NAME}-pass -u $new_username -a gnusocial -p "$new_user_password"
2016-10-16 20:50:56 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-10-16 14:54:28 +02:00
if [ -d /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs ]; then
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-10-02 00:39:56 +02:00
php scripts/registeruser.php -n $new_username -w "$new_user_password" -e "$new_username@$HOSTNAME"
2016-10-16 14:54:28 +02:00
${PROJECT_NAME}-addemail -u $new_username -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
2016-10-02 00:39:56 +02:00
echo '0'
else
2016-10-02 12:17:01 +02:00
echo '1'
2016-10-02 00:39:56 +02:00
fi
}
2016-09-30 12:34:39 +02:00
function install_interactive_gnusocial {
2016-09-30 20:22:10 +02:00
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
2016-10-03 14:49:29 +02:00
2016-09-30 20:22:10 +02:00
if [[ $ONION_ONLY != "no" ]]; then
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DOMAIN_NAME='gnusocial.local'
2016-09-30 20:22:10 +02:00
else
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DETAILS_COMPLETE=
while [ ! $GNUSOCIAL_DETAILS_COMPLETE ]
2016-09-30 20:22:10 +02:00
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" \
2016-10-16 14:54:28 +02:00
--title $"GNU Social Configuration" \
2017-02-22 21:51:23 +01:00
--form $"\nPlease enter your GNU Social 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 \
2016-10-16 14:54:28 +02:00
$"Domain:" 1 1 "$(grep 'GNUSOCIAL_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
2017-02-22 22:31:57 +01:00
$"Title:" 2 1 "$(grep '$GNUSOCIAL_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
2016-10-16 14:54:28 +02:00
$"Background image URL:" 3 1 "$(grep '$GNUSOCIAL_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
$"Code:" 4 1 "$(grep 'GNUSOCIAL_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
2016-09-30 20:22:10 +02:00
2> $data
else
dialog --backtitle $"Freedombone Configuration" \
2016-10-16 14:54:28 +02:00
--title $"GNU Social Configuration" \
2017-02-22 21:51:23 +01:00
--form $"\nPlease enter your GNU Social 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 \
2016-10-16 14:54:28 +02:00
$"Domain:" 1 1 "$(grep 'GNUSOCIAL_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
2017-02-22 21:51:23 +01:00
$"Title:" 2 1 "$(grep '$GNUSOCIAL_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
2016-10-16 14:54:28 +02:00
$"Background image URL:" 3 1 "$(grep '$GNUSOCIAL_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
2016-09-30 20:22:10 +02:00
2> $data
fi
sel=$?
case $sel in
1) exit 1;;
255) exit 1;;
esac
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DOMAIN_NAME=$(cat $data | sed -n 1p)
2017-02-22 21:51:23 +01:00
title=$(cat $data | sed -n 2p)
if [ ${#title} -gt 1 ]; then
GNUSOCIAL_TITLE=$welcome_msg
2016-09-30 20:22:10 +02:00
fi
img_url=$(cat $data | sed -n 3p)
if [ ${#img_url} -gt 1 ]; then
2016-10-16 14:54:28 +02:00
GNUSOCIAL_BACKGROUND_IMAGE_URL=$img_url
2016-09-30 20:22:10 +02:00
fi
2016-10-16 14:54:28 +02:00
if [ $GNUSOCIAL_DOMAIN_NAME ]; then
if [[ $GNUSOCIAL_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
GNUSOCIAL_DOMAIN_NAME=""
2016-09-30 20:22:10 +02:00
fi
2016-10-16 14:54:28 +02:00
TEST_DOMAIN_NAME=$GNUSOCIAL_DOMAIN_NAME
2016-09-30 20:22:10 +02:00
validate_domain_name
2016-10-16 14:54:28 +02:00
if [[ $TEST_DOMAIN_NAME != $GNUSOCIAL_DOMAIN_NAME ]]; then
GNUSOCIAL_DOMAIN_NAME=
2016-09-30 20:22:10 +02:00
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
2016-10-16 14:54:28 +02:00
GNUSOCIAL_CODE=$(cat $data | sed -n 4p)
validate_freedns_code "$GNUSOCIAL_CODE"
2016-09-30 20:22:10 +02:00
if [ ! $VALID_CODE ]; then
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DOMAIN_NAME=
2016-09-30 20:22:10 +02:00
fi
fi
fi
fi
2016-10-16 14:54:28 +02:00
if [ $GNUSOCIAL_DOMAIN_NAME ]; then
GNUSOCIAL_DETAILS_COMPLETE="yes"
2016-09-30 20:22:10 +02:00
fi
done
2016-10-17 18:54:22 +02:00
# remove any invalid characters
2017-02-22 21:51:23 +01:00
if [ ${#GNUSOCIAL_TITLE} -gt 0 ]; then
new_title=$(echo "$GNUSOCIAL_TITLE" | sed "s|'||g")
GNUSOCIAL_TITLE="$new_title"
2016-10-17 18:54:22 +02:00
fi
2016-09-30 20:22:10 +02:00
# save the results in the config file
2016-10-16 14:54:28 +02:00
write_config_param "GNUSOCIAL_CODE" "$GNUSOCIAL_CODE"
2017-02-22 21:51:23 +01:00
write_config_param "GNUSOCIAL_TITLE" "$GNUSOCIAL_TITLE"
2016-10-16 14:54:28 +02:00
write_config_param "GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_BACKGROUND_IMAGE_URL"
2016-09-30 20:22:10 +02:00
fi
2016-10-16 14:54:28 +02:00
write_config_param "GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_DOMAIN_NAME"
2016-10-10 20:11:33 +02:00
APP_INSTALLED=1
2016-09-30 12:34:39 +02:00
}
2016-09-25 12:20:41 +02:00
function change_password_gnusocial {
2016-11-20 13:37:13 +01:00
curr_username="$1"
new_user_password="$2"
2017-05-23 16:49:08 +02:00
read_config_param 'GNUSOCIAL_DOMAIN_NAME'
2016-11-20 13:37:13 +01:00
2016-12-04 13:28:45 +01:00
cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/scripts
php setpassword.php "$curr_username" "$new_user_password"
2016-11-20 13:37:13 +01:00
${PROJECT_NAME}-pass -u "$curr_username" -a gnusocial -p "$new_user_password"
2016-07-25 20:55:51 +02:00
}
function gnusocial_create_database {
2016-11-19 10:37:35 +01:00
if [ -f $IMAGE_PASSWORD_FILE ]; then
GNUSOCIAL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
if [ ! $GNUSOCIAL_ADMIN_PASSWORD ]; then
2016-10-16 14:54:28 +02:00
GNUSOCIAL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
2016-09-25 12:20:41 +02:00
fi
fi
2016-10-16 14:54:28 +02:00
if [ ! $GNUSOCIAL_ADMIN_PASSWORD ]; then
2016-09-25 12:20:41 +02:00
return
fi
function_check create_database
2016-10-16 14:54:28 +02:00
create_database gnusocial "$GNUSOCIAL_ADMIN_PASSWORD" $MY_USERNAME
2016-07-25 20:55:51 +02:00
}
2016-07-09 12:36:12 +02:00
function reconfigure_gnusocial {
2016-09-25 12:20:41 +02:00
echo -n ''
2016-07-09 12:36:12 +02:00
}
2016-10-20 21:55:59 +02:00
function gnusocial_set_background_image {
2017-04-04 00:27:10 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-10-20 21:55:59 +02:00
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"GNU Social" \
--backtitle $"Freedombone Control Panel" \
2017-02-22 22:14:56 +01:00
--inputbox $'Set a background image URL' 10 60 2>$data
2016-10-20 21:55:59 +02:00
sel=$?
case $sel in
0)
temp_background=$(<$data)
if [ ${#temp_background} -gt 0 ]; then
GNUSOCIAL_BACKGROUND_IMAGE_URL="$temp_background"
write_config_param "GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_BACKGROUND_IMAGE_URL"
2017-04-03 23:33:30 +02:00
if [[ $(pleroma_set_background_image_from_url "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" | tail -n 1) == "0" ]]; then
2016-10-20 21:55:59 +02:00
dialog --title $"Set GNU Social login background" \
--msgbox $"The background image has been set" 6 60
fi
fi
;;
esac
}
2017-02-22 21:51:23 +01:00
function gnusocial_set_title {
2016-10-20 21:55:59 +02:00
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"GNU Social" \
--backtitle $"Freedombone Control Panel" \
2017-02-22 21:51:23 +01:00
--inputbox $'Set a title' 10 60 2>$data
2016-10-20 21:55:59 +02:00
sel=$?
case $sel in
0)
2017-02-22 21:51:23 +01:00
new_title=$(<$data)
if [ ${#new_title} -gt 0 ]; then
GNUSOCIAL_TITLE="$new_title"
2017-04-04 11:47:06 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2017-02-22 21:51:23 +01:00
write_config_param "GNUSOCIAL_TITLE" "$GNUSOCIAL_TITLE"
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/static
sed -i "s|\"name\":.*|\"name\": \"${GNUSOCIAL_TITLE}\",|g" config.json
dialog --title $"Set GNU Social title" \
--msgbox $"The title has been set" 6 60
2016-10-20 21:55:59 +02:00
fi
;;
esac
}
2017-04-05 12:58:20 +02:00
function gnusocial_set_expire_months {
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
read_config_param "GNUSOCIAL_EXPIRE_MONTHS"
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"GNU Social" \
--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 "$GNUSOCIAL_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
GNUSOCIAL_EXPIRE_MONTHS=$new_expiry_months
write_config_param "GNUSOCIAL_EXPIRE_MONTHS" "$GNUSOCIAL_EXPIRE_MONTHS"
expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
dialog --title $"Set GNU Social post expiry period" \
--msgbox $"Expiry period set to $GNUSOCIAL_EXPIRE_MONTHS months" 6 60
fi
;;
esac
}
2016-10-20 21:55:59 +02:00
function configure_interactive_gnusocial {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"GNU Social" \
2017-05-07 19:19:45 +02:00
--radiolist $"Choose an operation:" 17 70 8 \
2017-02-22 22:14:56 +01:00
1 $"Set a background image" off \
2017-02-22 21:51:23 +01:00
2 $"Set the title" off \
2017-04-05 12:58:20 +02:00
3 $"Set post expiry period (currently $GNUSOCIAL_EXPIRE_MONTHS months)" off \
2017-04-20 20:29:20 +02:00
4 $"Select Qvitter user interface" off \
5 $"Select Pleroma user interface" off \
2017-05-02 22:42:44 +02:00
6 $"Select Classic user interface" off \
2017-05-07 19:19:45 +02:00
7 $"Select Armadillo user interface" off \
8 $"Exit" on 2> $data
2016-10-20 21:55:59 +02:00
sel=$?
case $sel in
1) return;;
255) return;;
esac
case $(cat $data) in
1) gnusocial_set_background_image;;
2017-02-22 21:51:23 +01:00
2) gnusocial_set_title;;
2017-04-05 12:58:20 +02:00
3) gnusocial_set_expire_months;;
2017-04-20 20:29:20 +02:00
4) gnusocial_use_qvitter gnusocial;;
5) gnusocial_use_pleroma gnusocial;;
2017-05-01 18:34:32 +02:00
6) gnusocial_use_classic gnusocial;;
2017-05-07 19:19:45 +02:00
7) gnusocial_use_armadillo gnusocial;;
8) break;;
2016-10-20 21:55:59 +02:00
esac
done
}
2016-07-06 16:01:28 +02:00
function upgrade_gnusocial {
2016-10-01 21:15:48 +02:00
if grep -q "gnusocial domain" $COMPLETION_FILE; then
2016-10-16 20:50:56 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-09-25 12:20:41 +02:00
fi
2016-07-06 16:40:09 +02:00
2016-09-25 12:20:41 +02:00
# update to the next commit
function_check set_repo_commit
2016-10-16 14:54:28 +02:00
set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs "gnusocial commit" "$GNUSOCIAL_COMMIT" $GNUSOCIAL_REPO
2016-07-06 16:40:09 +02:00
2016-12-12 11:10:38 +01:00
gnusocial_fix_endless_reloads
2016-12-11 14:16:22 +01:00
# Ensure that installation script is removed
if [ -f /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php ]; then
rm /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php
fi
2017-04-05 00:10:20 +02:00
if [ -d $INSTALL_DIR/pleroma ]; then
if [ -f /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index.php ]; then
mv /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index.php /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/index_qvitter.php
fi
fi
2017-04-21 19:40:45 +02:00
gnusocial_block_user_script
2017-05-03 18:02:50 +02:00
gnusocial_block_domain_script gnusocial $GNUSOCIAL_DOMAIN_NAME
2017-04-21 19:40:45 +02:00
2017-04-04 12:11:19 +02:00
gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
2017-02-22 21:51:23 +01:00
upgrade_pleroma "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
2017-04-11 15:20:40 +02:00
install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
2017-04-05 00:10:20 +02:00
chown -R www-data:www-data /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
2016-07-06 16:01:28 +02:00
}
2016-07-06 16:40:09 +02:00
2016-07-06 15:55:09 +02:00
function backup_local_gnusocial {
2016-10-16 14:54:28 +02:00
GNUSOCIAL_DOMAIN_NAME='gnusocial'
2016-10-01 21:15:48 +02:00
if grep -q "gnusocial domain" $COMPLETION_FILE; then
2016-10-16 20:50:56 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-09-25 12:20:41 +02:00
fi
2016-07-07 12:20:10 +02:00
2016-10-16 14:54:28 +02:00
source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
2016-09-25 12:20:41 +02:00
if [ -d $source_directory ]; then
dest_directory=gnusocial
function_check suspend_site
2016-10-16 14:54:28 +02:00
suspend_site ${GNUSOCIAL_DOMAIN_NAME}
2016-07-07 12:20:10 +02:00
2016-09-25 12:20:41 +02:00
function_check backup_directory_to_usb
backup_directory_to_usb $source_directory $dest_directory
2016-07-07 12:20:10 +02:00
2016-09-25 12:20:41 +02:00
function_check backup_database_to_usb
backup_database_to_usb gnusocial
2016-07-07 12:20:10 +02:00
2016-09-25 12:20:41 +02:00
function_check restart_site
restart_site
fi
2016-07-06 15:55:09 +02:00
}
2016-07-09 11:46:05 +02:00
function restore_local_gnusocial {
2016-10-01 21:15:48 +02:00
if ! grep -q "gnusocial domain" $COMPLETION_FILE; then
2016-09-25 12:20:41 +02:00
return
fi
2016-10-16 20:50:56 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-10-16 14:54:28 +02:00
if [ $GNUSOCIAL_DOMAIN_NAME ]; then
2016-10-01 21:15:48 +02:00
echo $"Restoring gnusocial"
2016-09-25 12:20:41 +02:00
temp_restore_dir=/root/tempgnusocial
2016-10-16 14:54:28 +02:00
gnusocial_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
2016-09-25 12:20:41 +02:00
# stop the daemons
cd $gnusocial_dir
2017-06-03 18:49:23 +02:00
scripts/stopdaemons.sh
2016-09-25 12:20:41 +02:00
function_check gnusocial_create_database
gnusocial_create_database
2016-10-16 14:54:28 +02:00
restore_database gnusocial ${GNUSOCIAL_DOMAIN_NAME}
2016-09-25 12:20:41 +02:00
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
# start the daemons
cd $gnusocial_dir
2017-05-12 19:44:42 +02:00
su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
2016-10-01 21:15:48 +02:00
echo $"Restore of gnusocial complete"
2016-09-25 12:20:41 +02:00
fi
2016-07-09 11:46:05 +02:00
}
2016-07-06 15:55:09 +02:00
function backup_remote_gnusocial {
2016-10-01 21:15:48 +02:00
if grep -q "gnusocial domain" $COMPLETION_FILE; then
2016-10-16 20:50:56 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-10-16 14:54:28 +02:00
temp_backup_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
2016-09-25 12:20:41 +02:00
if [ -d $temp_backup_dir ]; then
function_check suspend_site
2016-10-16 14:54:28 +02:00
suspend_site ${GNUSOCIAL_DOMAIN_NAME}
2016-09-25 12:20:41 +02:00
function_check backup_database_to_friend
backup_database_to_friend gnusocial
echo $"Backing up GNU social installation"
function_check backup_directory_to_friend
backup_directory_to_friend $temp_backup_dir gnusocial
function_check restart_site
restart_site
else
2016-10-01 21:15:48 +02:00
echo $"gnusocial domain specified but not found in ${temp_backup_dir}"
2016-09-25 12:20:41 +02:00
fi
fi
2016-07-04 22:02:22 +02:00
}
2016-07-09 11:46:05 +02:00
function restore_remote_gnusocial {
2016-10-01 21:15:48 +02:00
if grep -q "gnusocial domain" $COMPLETION_FILE; then
echo $"Restoring gnusocial"
2016-10-16 20:50:56 +02:00
GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
2016-09-25 12:20:41 +02:00
# stop the daemons
2016-10-16 14:54:28 +02:00
cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
2017-06-03 18:49:23 +02:00
scripts/stopdaemons.sh
2016-09-25 12:20:41 +02:00
function_check gnusocial_create_database
gnusocial_create_database
function_check restore_database_from_friend
2016-10-16 14:54:28 +02:00
restore_database_from_friend gnusocial ${GNUSOCIAL_DOMAIN_NAME}
2016-09-25 12:20:41 +02:00
if [ -d /root/tempgnusocial ]; then
rm -rf /root/tempgnusocial
fi
# start the daemons
2016-10-16 14:54:28 +02:00
cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
2017-05-12 19:44:42 +02:00
su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
2016-10-01 21:15:48 +02:00
echo $"Restore of gnusocial complete"
2016-09-25 12:20:41 +02:00
fi
2016-07-09 11:46:05 +02:00
}
2016-07-05 21:07:43 +02:00
function remove_gnusocial {
2016-10-16 14:54:28 +02:00
if [ ${#GNUSOCIAL_DOMAIN_NAME} -eq 0 ]; then
2016-10-09 21:57:06 +02:00
return
fi
2017-02-22 21:51:23 +01:00
function_check remove_nodejs
remove_nodejs pleroma-gnusocial
2016-10-16 14:54:28 +02:00
read_config_param "GNUSOCIAL_DOMAIN_NAME"
2016-10-14 15:56:14 +02:00
read_config_param "MY_USERNAME"
2016-10-16 14:54:28 +02:00
echo "Removing $GNUSOCIAL_DOMAIN_NAME"
nginx_dissite $GNUSOCIAL_DOMAIN_NAME
2016-10-20 23:02:16 +02:00
remove_certs $GNUSOCIAL_DOMAIN_NAME
2017-04-04 16:54:20 +02:00
if [ -f /etc/cron.hourly/gnusocial-daemons ]; then
rm /etc/cron.hourly/gnusocial-daemons
fi
2016-10-27 20:56:57 +02:00
if [ -f /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/stopdaemons.sh ]; then
2017-06-03 20:58:09 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2017-06-03 18:49:23 +02:00
scripts/stopdaemons.sh
2016-10-27 20:56:57 +02:00
fi
2017-04-04 21:16:00 +02:00
kill_pid=$(ps aux | grep /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php | awk -F ' ' '{print $2}' | head -n 1)
kill -9 $kill_pid
2016-10-16 14:54:28 +02:00
if [ -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
fi
2016-10-16 14:54:28 +02:00
if [ -f /etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME ]; then
rm /etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
fi
function_check drop_database
drop_database gnusocial
function_check remove_onion_service
2016-10-16 14:54:28 +02:00
remove_onion_service gnusocial ${GNUSOCIAL_ONION_PORT}
2016-10-01 14:14:39 +02:00
if grep -q "gnusocial" /etc/crontab; then
sed -i "/gnusocial/d" /etc/crontab
2016-10-01 12:55:56 +02:00
fi
2016-09-30 23:50:16 +02:00
remove_app gnusocial
2016-10-17 15:44:49 +02:00
remove_completion_param install_gnusocial
2016-10-28 10:40:31 +02:00
sed -i '/gnusocial/d' $COMPLETION_FILE
2016-11-02 18:49:21 +01:00
remove_backup_database_local gnusocial
2016-11-06 15:13:00 +01:00
2017-04-20 14:43:55 +02:00
sed -i '/gnusocial-firewall/d' /etc/crontab
2016-11-06 15:13:00 +01:00
function_check remove_ddns_domain
remove_ddns_domain $GNUSOCIAL_DOMAIN_NAME
2016-07-03 22:22:12 +02:00
}
2016-07-05 22:50:11 +02:00
function install_gnusocial_main {
2016-10-16 14:54:28 +02:00
if [ ! $GNUSOCIAL_DOMAIN_NAME ]; then
echo $'No domain name was given for gnusocial'
2016-09-25 12:20:41 +02:00
exit 7359
fi
2016-09-30 22:38:44 +02:00
if [[ $(app_is_installed gnusocial_main) == "1" ]]; then
2016-09-25 12:20:41 +02:00
return
fi
2017-04-04 12:11:19 +02:00
gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
function_check install_mariadb
install_mariadb
function_check get_mariadb_password
get_mariadb_password
function_check repair_databases_script
repair_databases_script
2017-05-29 15:40:34 +02:00
apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
2017-06-04 10:42:16 +02:00
apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
2016-09-25 12:20:41 +02:00
2016-10-16 14:54:28 +02:00
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME ]; then
mkdir /var/www/$GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
fi
2016-10-16 14:54:28 +02:00
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
2016-09-25 12:20:41 +02:00
function_check git_clone
2016-10-16 14:54:28 +02:00
git_clone $GNUSOCIAL_REPO /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
2016-09-25 12:20:41 +02:00
echo $'Unable to clone gnusocial repo'
exit 87525
fi
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
git checkout $GNUSOCIAL_COMMIT -b $GNUSOCIAL_COMMIT
2016-10-16 20:50:56 +02:00
set_completion_param "gnusocial commit" "$GNUSOCIAL_COMMIT"
2016-09-25 12:20:41 +02:00
2016-12-12 11:10:38 +01:00
gnusocial_fix_endless_reloads
2016-12-04 13:42:36 +01:00
chmod g+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/avatar
chmod a+w /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/file
2016-12-04 14:51:25 +01:00
chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-10-16 14:54:28 +02:00
chmod +x /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php
2016-09-25 12:20:41 +02:00
function_check gnusocial_create_database
gnusocial_create_database
if [ ! -f "/etc/aliases" ]; then
touch /etc/aliases
fi
if ! grep -q "www-data: root" /etc/aliases; then
echo 'www-data: root' >> /etc/aliases
fi
2016-10-16 14:54:28 +02:00
if ! grep -q "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php" /etc/aliases; then
echo "*: /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/maildaemon.php" >> /etc/aliases
2016-09-25 12:20:41 +02:00
fi
function_check add_ddns_domain
2016-10-16 14:54:28 +02:00
add_ddns_domain $GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
2016-10-16 14:54:28 +02:00
gnusocial_nginx_site=/etc/nginx/sites-available/$GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
if [[ $ONION_ONLY == "no" ]]; then
function_check nginx_http_redirect
2017-04-03 21:24:25 +02:00
nginx_http_redirect $GNUSOCIAL_DOMAIN_NAME "index index.php"
2016-10-16 14:54:28 +02:00
echo 'server {' >> $gnusocial_nginx_site
echo ' listen 443 ssl;' >> $gnusocial_nginx_site
2016-11-17 23:45:20 +01:00
echo ' listen [::]:443 ssl;' >> $gnusocial_nginx_site
2016-10-16 14:54:28 +02:00
echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
2017-05-14 11:52:16 +02:00
function_check nginx_compress
nginx_compress $GNUSOCIAL_DOMAIN_NAME
echo '' >> $gnusocial_nginx_site
2016-10-16 14:54:28 +02:00
echo ' # Security' >> $gnusocial_nginx_site
2016-09-25 12:20:41 +02:00
function_check nginx_ssl
2016-10-16 14:54:28 +02:00
nginx_ssl $GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
function_check nginx_disable_sniffing
2016-10-16 14:54:28 +02:00
nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Logs' >> $gnusocial_nginx_site
2016-11-10 14:26:31 +01:00
echo ' access_log /dev/null;' >> $gnusocial_nginx_site
echo ' error_log /dev/null;' >> $gnusocial_nginx_site
2016-10-16 14:54:28 +02:00
echo '' >> $gnusocial_nginx_site
echo ' # Root' >> $gnusocial_nginx_site
echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Index' >> $gnusocial_nginx_site
echo ' index index.php;' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # PHP' >> $gnusocial_nginx_site
echo ' location ~ \.php {' >> $gnusocial_nginx_site
echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
2017-06-03 21:20:04 +02:00
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $gnusocial_nginx_site
2016-10-16 14:54:28 +02:00
echo ' }' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Location' >> $gnusocial_nginx_site
echo ' location / {' >> $gnusocial_nginx_site
2016-10-01 13:18:23 +02:00
function_check nginx_limits
2016-10-16 14:54:28 +02:00
nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
echo ' }' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Fancy URLs' >> $gnusocial_nginx_site
echo ' location @gnusocial {' >> $gnusocial_nginx_site
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
echo ' }' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
echo ' deny all;' >> $gnusocial_nginx_site
echo ' }' >> $gnusocial_nginx_site
2016-11-11 17:26:54 +01:00
echo '' >> $gnusocial_nginx_site
2016-12-04 19:44:24 +01:00
# DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
2016-10-16 14:54:28 +02:00
echo '}' >> $gnusocial_nginx_site
2016-09-25 12:20:41 +02:00
else
2016-10-16 14:54:28 +02:00
echo -n '' > $gnusocial_nginx_site
2016-09-25 12:20:41 +02:00
fi
2016-10-16 14:54:28 +02:00
echo 'server {' >> $gnusocial_nginx_site
echo " listen 127.0.0.1:$GNUSOCIAL_ONION_PORT default_server;" >> $gnusocial_nginx_site
echo " server_name $GNUSOCIAL_DOMAIN_NAME;" >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
2017-05-14 11:52:16 +02:00
function_check nginx_compress
nginx_compress $GNUSOCIAL_DOMAIN_NAME
echo '' >> $gnusocial_nginx_site
2016-09-25 12:20:41 +02:00
function_check nginx_disable_sniffing
2016-10-16 14:54:28 +02:00
nginx_disable_sniffing $GNUSOCIAL_DOMAIN_NAME
echo '' >> $gnusocial_nginx_site
echo ' # Logs' >> $gnusocial_nginx_site
2016-11-10 14:26:31 +01:00
echo ' access_log /dev/null;' >> $gnusocial_nginx_site
echo ' error_log /dev/null;' >> $gnusocial_nginx_site
2016-10-16 14:54:28 +02:00
echo '' >> $gnusocial_nginx_site
echo ' # Root' >> $gnusocial_nginx_site
echo " root /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs;" >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Index' >> $gnusocial_nginx_site
echo ' index index.php;' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # PHP' >> $gnusocial_nginx_site
echo ' location ~ \.php {' >> $gnusocial_nginx_site
echo ' include snippets/fastcgi-php.conf;' >> $gnusocial_nginx_site
2017-06-03 21:20:04 +02:00
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $gnusocial_nginx_site
2016-10-16 14:54:28 +02:00
echo ' }' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Location' >> $gnusocial_nginx_site
echo ' location / {' >> $gnusocial_nginx_site
2016-10-01 13:18:23 +02:00
function_check nginx_limits
2016-10-16 14:54:28 +02:00
nginx_limits $GNUSOCIAL_DOMAIN_NAME '15m'
echo ' try_files $uri $uri/ @gnusocial;' >> $gnusocial_nginx_site
echo ' }' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Fancy URLs' >> $gnusocial_nginx_site
echo ' location @gnusocial {' >> $gnusocial_nginx_site
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $gnusocial_nginx_site
echo ' }' >> $gnusocial_nginx_site
echo '' >> $gnusocial_nginx_site
echo ' # Restrict access that is unnecessary anyway' >> $gnusocial_nginx_site
echo ' location ~ /\.(ht|git) {' >> $gnusocial_nginx_site
echo ' deny all;' >> $gnusocial_nginx_site
echo ' }' >> $gnusocial_nginx_site
2016-11-11 18:36:30 +01:00
echo '' >> $gnusocial_nginx_site
2016-12-04 19:44:24 +01:00
# DO NOT ENABLE KEYBASE. gnusocial really doesn't like having a .well-known directory
2016-10-16 14:54:28 +02:00
echo '}' >> $gnusocial_nginx_site
2016-09-25 12:20:41 +02:00
function_check configure_php
configure_php
function_check create_site_certificate
2016-10-16 14:54:28 +02:00
create_site_certificate $GNUSOCIAL_DOMAIN_NAME 'yes'
2016-09-25 12:20:41 +02:00
# Ensure that the database gets backed up locally, if remote
# backups are not being used
function_check backup_databases_script_header
backup_databases_script_header
function_check backup_database_local
backup_database_local gnusocial
function_check nginx_ensite
2016-10-16 14:54:28 +02:00
nginx_ensite $GNUSOCIAL_DOMAIN_NAME
2016-09-25 12:20:41 +02:00
# NOTE: For the typical case always enable SSL and only
# disable it if in onion only mode. This is due to complexities
2016-10-01 21:15:48 +02:00
# with the way URLs are generated by gnusocial
2016-09-25 12:20:41 +02:00
gnusocial_ssl='always'
if [[ $ONION_ONLY != 'no' ]]; then
gnusocial_ssl='never'
fi
2016-10-16 14:54:28 +02:00
GNUSOCIAL_ONION_HOSTNAME=$(add_onion_service gnusocial 80 ${GNUSOCIAL_ONION_PORT})
2016-09-25 12:20:41 +02:00
2016-10-16 14:54:28 +02:00
GNUSOCIAL_SERVER=${GNUSOCIAL_DOMAIN_NAME}
2016-09-25 12:20:41 +02:00
if [[ $ONION_ONLY != 'no' ]]; then
2016-10-16 14:54:28 +02:00
GNUSOCIAL_SERVER=${GNUSOCIAL_ONION_HOSTNAME}
2016-09-25 12:20:41 +02:00
fi
# Create the configuration
2016-10-16 14:54:28 +02:00
gnusocial_installer=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/scripts/install_cli.php
2016-09-25 12:20:41 +02:00
if [ ! -f $gnusocial_installer ]; then
2016-11-24 16:44:37 +01:00
rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
2016-10-01 21:15:48 +02:00
echo $'No gnusocial commandline installer found'
2016-09-25 12:20:41 +02:00
exit 53026
fi
2016-10-16 14:54:28 +02:00
${gnusocial_installer} --server "${GNUSOCIAL_SERVER}" \
2016-09-25 12:20:41 +02:00
--host="localhost" --database="gnusocial" \
--dbtype=mysql --username="root" -v \
--password="$MARIADB_PASSWORD" \
--sitename=$"GNU Social" --fancy='yes' \
--admin-nick="$MY_USERNAME" \
2016-10-16 14:54:28 +02:00
--admin-pass="$GNUSOCIAL_ADMIN_PASSWORD" \
2016-09-25 12:20:41 +02:00
--site-profile="community" \
--ssl=${gnusocial_ssl}
# There can be a lot of warnings here so the return value check is disabled
#if [ ! "$?" = "0" ]; then
# # failed to install
# echo $'Could not install GNU Social'
# exit 72357
#fi
2016-10-16 14:54:28 +02:00
# check gnusocial has a config file
gnusocial_config_file=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
if [ ! -f $gnusocial_config_file ]; then
2016-12-01 12:17:33 +01:00
drop_database gnusocial
2016-11-24 16:44:37 +01:00
rm -rf /var/www/$GNUSOCIAL_DOMAIN_NAME
2016-10-16 14:54:28 +02:00
echo $'Gnusocial config.php not found'
2016-09-25 12:20:41 +02:00
exit 87586
fi
# Some useful settings
2016-10-16 14:54:28 +02:00
if ! grep -q "Recommended GNU social settings" $gnusocial_config_file; then
echo "" >> $gnusocial_config_file
echo "// Recommended GNU social settings" >> $gnusocial_config_file
echo "\$config['thumbnail']['maxsize'] = 3000;" >> $gnusocial_config_file
echo "\$config['profile']['delete'] = true;" >> $gnusocial_config_file
echo "\$config['profile']['changenick'] = true;" >> $gnusocial_config_file
echo "\$config['public']['localonly'] = false;" >> $gnusocial_config_file
echo "addPlugin('StoreRemoteMedia');" >> $gnusocial_config_file
echo "\$config['queue']['enabled'] = true;" >> $gnusocial_config_file
echo "\$config['queue']['daemon'] = true;" >> $gnusocial_config_file
echo "\$config['ostatus']['hub_retries'] = 3;" >> $gnusocial_config_file
2016-09-25 12:20:41 +02:00
fi
2016-11-18 15:43:19 +01:00
# turn off logging
2016-11-18 16:45:21 +01:00
echo "\$config['site']['logfile'] = '/dev/null';" >> $gnusocial_config_file
2016-12-04 19:05:33 +01:00
echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> $gnusocial_config_file
2016-11-18 15:43:19 +01:00
2016-09-25 12:20:41 +02:00
# This improves performance
2016-10-16 14:54:28 +02:00
sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $gnusocial_config_file
2016-09-25 12:20:41 +02:00
2017-06-06 15:26:57 +02:00
systemctl restart mariadb
2017-06-01 20:05:15 +02:00
systemctl restart php7.0-fpm
2016-09-25 12:20:41 +02:00
systemctl restart nginx
2016-10-16 14:54:28 +02:00
${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$GNUSOCIAL_DOMAIN_NAME" -g gnusocial --public no
2016-09-25 12:20:41 +02:00
2016-11-19 20:17:33 +01:00
${PROJECT_NAME}-pass -u $MY_USERNAME -a gnusocial -p "$GNUSOCIAL_ADMIN_PASSWORD"
2017-04-21 19:40:45 +02:00
gnusocial_block_user_script
2017-05-03 18:02:50 +02:00
gnusocial_block_domain_script gnusocial "$GNUSOCIAL_DOMAIN_NAME"
2016-10-01 12:55:56 +02:00
2016-10-16 20:50:56 +02:00
set_completion_param "gnusocial domain" "$GNUSOCIAL_DOMAIN_NAME"
2016-09-25 12:20:41 +02:00
2016-09-30 22:38:44 +02:00
install_completed gnusocial_main
2016-07-03 17:13:34 +02:00
}
2016-07-05 21:07:43 +02:00
function install_gnusocial_plugin_sharings {
2016-10-16 14:54:28 +02:00
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
echo $'No local/plugins directory found for the gnusocial'
2016-09-25 12:20:41 +02:00
exit 72945
fi
2016-10-23 20:38:14 +02:00
apt-get -yq install liblocale-msgfmt-perl gettext
2016-09-25 12:20:41 +02:00
# update to the next commit
function_check set_repo_commit
2016-10-16 14:54:28 +02:00
set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO
2016-09-25 12:20:41 +02:00
2016-09-30 22:38:44 +02:00
if [[ $(app_is_installed gnusocial_plugin_sharings) == "1" ]]; then
2016-09-25 12:20:41 +02:00
return
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
2016-09-25 12:20:41 +02:00
function_check git_clone
git_clone $SHARINGS_REPO Sharings
2016-10-16 14:54:28 +02:00
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings ]; then
echo $'Unable to clone gnusocial sharings plugin'
2016-09-25 12:20:41 +02:00
exit 36738
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
2016-09-25 12:20:41 +02:00
git stash
git checkout master
git branch -D $SHARINGS_COMMIT
git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT
# enable the plugin
2016-10-16 14:54:28 +02:00
if ! grep -q "addPlugin('Sharings');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
echo "addPlugin('Sharings');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
2016-09-25 12:20:41 +02:00
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-09-25 12:20:41 +02:00
php scripts/checkschema.php
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
2016-09-25 12:20:41 +02:00
php scripts/seedsharings.php
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2017-04-02 20:34:09 +02:00
php scripts/upgrade.php
2016-09-25 12:20:41 +02:00
php scripts/checkschema.php
# Languages
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES
2016-09-25 12:20:41 +02:00
msgfmt -o Sharings.mo Sharings.po
if [ ! -f Sharings.po ]; then
2016-10-01 21:15:48 +02:00
echo $'English translations for gnusocial sharings plugin were not created'
2016-09-25 12:20:41 +02:00
exit 84352
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES
2016-09-25 12:20:41 +02:00
msgfmt -o Sharings.mo Sharings.po
if [ ! -f Sharings.po ]; then
2016-10-01 21:15:48 +02:00
echo $'English (GB) translations for gnusocial sharings plugin were not created'
2016-09-25 12:20:41 +02:00
exit 84352
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES
2016-09-25 12:20:41 +02:00
msgfmt -o Sharings.mo Sharings.po
if [ ! -f Sharings.po ]; then
2016-10-01 21:15:48 +02:00
echo $'English (US) translations for gnusocial sharings plugin were not created'
2016-09-25 12:20:41 +02:00
exit 84352
fi
2016-10-28 11:41:27 +02:00
# Looks like this update function isn't supported by the current php version
sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/SharingsPlugin.php
2016-10-16 14:54:28 +02:00
chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-09-25 12:20:41 +02:00
2016-10-16 20:50:56 +02:00
set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT"
2016-09-30 22:38:44 +02:00
install_completed gnusocial_plugin_sharings
2016-07-03 17:13:34 +02:00
}
2016-07-05 21:07:43 +02:00
function install_gnusocial_plugin_sharings_theme {
2016-10-16 14:54:28 +02:00
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
echo $'No local/plugins directory found for the gnusocial'
2016-09-25 12:20:41 +02:00
exit 74458
fi
# update to the next commit
function_check set_repo_commit
2016-10-16 14:54:28 +02:00
set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO
2016-09-25 12:20:41 +02:00
2016-09-30 22:38:44 +02:00
if [[ $(app_is_installed gnusocial_plugin_sharings_theme) == "1" ]]; then
2016-09-25 12:20:41 +02:00
return
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
2016-09-25 12:20:41 +02:00
function_check git_clone
git_clone $SHARINGS_THEME_REPO SharingsTheme
2016-10-16 14:54:28 +02:00
if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme ]; then
echo $'Unable to clone gnusocial sharings plugin theme'
2016-09-25 12:20:41 +02:00
exit 639253
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme
2016-09-25 12:20:41 +02:00
git stash
git checkout master
git branch -D $SHARINGS_THEME_COMMIT
git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT
# enable the plugin
2016-10-16 14:54:28 +02:00
if ! grep -q "addPlugin('SharingsTheme');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
echo "addPlugin('SharingsTheme');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
2016-09-25 12:20:41 +02:00
fi
2016-10-16 14:54:28 +02:00
cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-09-25 12:20:41 +02:00
php scripts/checkschema.php
2016-10-16 14:54:28 +02:00
chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-09-25 12:20:41 +02:00
2016-10-17 18:43:29 +02:00
set_completion_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
2016-09-30 22:38:44 +02:00
install_completed gnusocial_plugin_sharings_theme
2016-07-03 17:13:34 +02:00
}
2016-07-05 21:07:43 +02:00
function install_gnusocial_markdown {
2016-10-16 14:54:28 +02:00
GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
2016-07-03 17:13:34 +02:00
2016-09-25 12:20:41 +02:00
# update to the next commit
function_check set_repo_commit
2016-10-16 14:54:28 +02:00
set_repo_commit $GNUSOCIAL_PATH/local/plugins/Markdown "gnusocial Markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT" $GNUSOCIAL_MARKDOWN_REPO
2016-07-03 17:13:34 +02:00
2016-09-30 22:38:44 +02:00
if [[ $(app_is_installed gnusocial_markdown) == "1" ]]; then
2016-09-25 12:20:41 +02:00
return
fi
2016-07-03 17:13:34 +02:00
2016-10-16 14:54:28 +02:00
if [ -d $GNUSOCIAL_PATH/local/plugins/Markdown ]; then
rm -rf $GNUSOCIAL_PATH/local/plugins/Markdown
2016-09-25 12:20:41 +02:00
fi
2016-07-03 17:13:34 +02:00
2016-10-16 14:54:28 +02:00
if [ ! -d $GNUSOCIAL_PATH/local/plugins ]; then
mkdir -p $GNUSOCIAL_PATH/local/plugins
2016-09-25 12:20:41 +02:00
fi
2016-07-03 17:13:34 +02:00
2016-10-16 14:54:28 +02:00
cd $GNUSOCIAL_PATH/local/plugins
2016-09-25 12:20:41 +02:00
function_check git_clone
2016-10-16 14:54:28 +02:00
git_clone $GNUSOCIAL_MARKDOWN_REPO Markdown
cd $GNUSOCIAL_PATH/local/plugins/Markdown
git checkout $GNUSOCIAL_MARKDOWN_COMMIT -b $GNUSOCIAL_MARKDOWN_COMMIT
2016-07-25 20:49:59 +02:00
2016-10-16 14:54:28 +02:00
gnusocial_config_file=$GNUSOCIAL_PATH/config.php
if ! grep -q "addPlugin('Markdown'" $gnusocial_config_file; then
echo "" >> $gnusocial_config_file
echo "// Markdown settings" >> $gnusocial_config_file
echo "addPlugin('Markdown');" >> $gnusocial_config_file
2016-09-25 12:20:41 +02:00
fi
2016-07-03 17:13:34 +02:00
2016-10-17 18:43:29 +02:00
set_completion_param "gnusocial markdown commit" "$GNUSOCIAL_MARKDOWN_COMMIT"
2016-07-03 17:13:34 +02:00
2016-10-16 14:54:28 +02:00
chown -R www-data:www-data $GNUSOCIAL_PATH
2016-07-24 11:48:06 +02:00
2016-09-30 22:38:44 +02:00
install_completed gnusocial_markdown
2016-07-24 11:48:06 +02:00
}
2016-07-05 22:50:11 +02:00
function install_gnusocial {
2016-09-30 21:35:44 +02:00
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
2016-09-25 12:20:41 +02:00
install_gnusocial_main
2017-04-05 12:23:04 +02:00
expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
2017-02-22 21:51:23 +01:00
install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
2016-09-25 12:20:41 +02:00
install_gnusocial_markdown
2017-02-22 21:51:23 +01:00
#install_gnusocial_plugin_sharings
#install_gnusocial_plugin_sharings_theme
2016-10-14 22:53:05 +02:00
2017-04-02 18:15:48 +02:00
# Currently Pleroma won't install on ARM systems
# because it uses node-sass which doesn't support ARM
2017-04-02 18:35:05 +02:00
if [[ "$(arch)" == "arm"* ]]; then
echo -m $'WARNING: Pleroma currently does not support ARM '
echo $'architecture, so it will not be installed'
else
2017-04-02 18:15:48 +02:00
function_check install_nodejs
install_nodejs pleroma-gnusocial
2017-04-15 19:05:22 +02:00
install_pleroma_front_end "gnusocial" "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
2017-04-11 15:20:40 +02:00
install_gnusocial_default_background "gnusocial" "$GNUSOCIAL_DOMAIN_NAME"
2017-04-11 15:23:45 +02:00
sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json
2017-04-02 18:15:48 +02:00
fi
2017-02-22 21:51:23 +01:00
2016-10-14 22:53:05 +02:00
# unleash the daemons!
/etc/cron.hourly/gnusocial-daemons
2017-04-05 14:28:56 +02:00
systemctl restart nginx
2016-10-10 20:11:33 +02:00
APP_INSTALLED=1
2016-07-03 17:13:34 +02:00
}
# NOTE: deliberately there is no "exit 0"