2016-07-03 17:13:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# Hubzilla application
|
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2018-01-25 19:35:39 +01:00
|
|
|
# Copyright (C) 2014-2018 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 social'
|
2016-07-06 17:47:55 +02:00
|
|
|
|
2016-10-21 21:46:33 +02:00
|
|
|
IN_DEFAULT_INSTALL=0
|
2016-10-19 22:23:11 +02:00
|
|
|
SHOW_ON_ABOUT=1
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
HUBZILLA_DOMAIN_NAME=
|
|
|
|
HUBZILLA_CODE=
|
|
|
|
HUBZILLA_ONION_PORT=8085
|
|
|
|
HUBZILLA_REPO="https://github.com/redmatrix/hubzilla.git"
|
2018-02-18 12:37:23 +01:00
|
|
|
HUBZILLA_COMMIT='577da0eb9eb1f90a4cf7a70cfb3582cfb49007ac'
|
2016-07-03 17:13:34 +02:00
|
|
|
HUBZILLA_ADDONS_REPO="https://github.com/redmatrix/hubzilla-addons.git"
|
2018-02-18 12:37:23 +01:00
|
|
|
HUBZILLA_ADDONS_COMMIT='be9dcd044b9326c3bd9301d7c4b375a2c2f54663'
|
2016-07-03 17:13:34 +02:00
|
|
|
HUBZILLA_ADMIN_PASSWORD=
|
|
|
|
|
2016-10-05 23:33:41 +02:00
|
|
|
hubzilla_variables=(ONION_ONLY
|
|
|
|
HUBZILLA_DOMAIN_NAME
|
|
|
|
HUBZILLA_CODE
|
|
|
|
DDNS_PROVIDER
|
|
|
|
MY_USERNAME
|
|
|
|
HUBZILLA_REPO
|
2016-11-24 19:37:10 +01:00
|
|
|
HUBZILLA_ADDONS_REPO)
|
2016-10-05 23:33:41 +02:00
|
|
|
|
2017-07-01 20:14:28 +02:00
|
|
|
function logging_on_hubzilla {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function logging_off_hubzilla {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
2016-11-12 14:59:33 +01:00
|
|
|
function remove_user_hubzilla {
|
|
|
|
remove_username="$1"
|
2018-02-27 15:11:56 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp hubzilla
|
2016-11-12 14:59:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function add_user_hubzilla {
|
|
|
|
if [[ $(app_is_installed hubzilla) == "0" ]]; then
|
|
|
|
echo '0'
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
new_username="$1"
|
|
|
|
new_user_password="$2"
|
2018-02-27 15:11:56 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$new_username" -a hubzilla -p "$new_user_password"
|
2016-11-12 14:59:33 +01:00
|
|
|
echo '0'
|
|
|
|
}
|
|
|
|
|
2016-09-30 14:34:09 +02:00
|
|
|
function hubzilla_renew_cert {
|
|
|
|
dialog --title $"Renew SSL certificate" \
|
|
|
|
--backtitle $"Freedombone Control Panel" \
|
2018-02-27 15:11:56 +01:00
|
|
|
--yesno $"\\nThis will renew a letsencrypt certificate. Select 'yes' to continue" 16 60
|
2016-09-30 14:34:09 +02:00
|
|
|
sel=$?
|
|
|
|
case $sel in
|
|
|
|
1) return;;
|
|
|
|
255) return;;
|
|
|
|
esac
|
2016-10-16 20:50:56 +02:00
|
|
|
HUBZILLA_DOMAIN_NAME=$(get_completion_param "hubzilla domain")
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs" ]; then
|
2016-09-30 14:34:09 +02:00
|
|
|
dialog --title $"Renew SSL certificate" \
|
|
|
|
--msgbox $"Hubzilla install directory not found" 6 40
|
|
|
|
return
|
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
if ! "${PROJECT_NAME}-renew-cert" -h "$HUBZILLA_DOMAIN_NAME" -p 'letsencrypt'; then
|
2016-09-30 14:34:09 +02:00
|
|
|
any_key
|
|
|
|
else
|
|
|
|
dialog --title $"Renew SSL certificate" \
|
|
|
|
--msgbox $"Hubzilla certificate has been renewed" 6 40
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function hubzilla_channel_directory_server {
|
2018-02-27 15:11:56 +01:00
|
|
|
if ! grep -q "hubzilla domain" "$COMPLETION_FILE"; then
|
2016-09-30 14:34:09 +02:00
|
|
|
dialog --title $"Hubzilla channel directory server" \
|
|
|
|
--msgbox $"Hubzilla is not installed on this system" 6 40
|
|
|
|
return
|
|
|
|
fi
|
2016-10-16 20:50:56 +02:00
|
|
|
HUBZILLA_DOMAIN_NAME=$(get_completion_param "hubzilla domain")
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs" ]; then
|
2016-09-30 14:34:09 +02:00
|
|
|
dialog --title $"Hubzilla channel directory server" \
|
|
|
|
--msgbox $"Hubzilla install directory not found" 6 40
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
data=$(mktemp 2>/dev/null)
|
2016-09-30 14:34:09 +02:00
|
|
|
dialog --title $"Hubzilla channel directory server" \
|
|
|
|
--backtitle $"Freedombone Control Panel" \
|
2018-02-27 15:11:56 +01:00
|
|
|
--inputbox $"When you click on 'channel directory' this is where Hubzilla will obtain its list from" 8 60 2>"$data"
|
2016-09-30 14:34:09 +02:00
|
|
|
sel=$?
|
|
|
|
case $sel in
|
|
|
|
0)
|
2018-02-27 15:11:56 +01:00
|
|
|
hubzilla_domain_server=$(<"$data")
|
2016-09-30 14:34:09 +02:00
|
|
|
if [[ $hubzilla_domain_server != *"."* ]]; then
|
2018-02-27 15:11:56 +01:00
|
|
|
rm -f "$data"
|
2016-09-30 14:34:09 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ $hubzilla_domain_server != "https"* ]]; then
|
|
|
|
dialog --title $"Hubzilla channel directory server" \
|
2018-02-27 15:11:56 +01:00
|
|
|
--msgbox $"\\nInvalid domain - include the https://" 7 60
|
|
|
|
rm -f "$data"
|
2016-09-30 14:34:09 +02:00
|
|
|
return
|
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
"./var/www/$HUBZILLA_DOMAIN_NAME/htdocs/util/config" system directory_server "$hubzilla_domain_server"
|
2016-09-30 14:34:09 +02:00
|
|
|
dialog --title $"Hubzilla channel directory server" \
|
2018-02-27 15:11:56 +01:00
|
|
|
--msgbox $"\\nDomain channel directory server changed to\\n\\n $hubzilla_domain_server" 10 60
|
2016-09-30 14:34:09 +02:00
|
|
|
;;
|
|
|
|
esac
|
2018-02-27 15:11:56 +01:00
|
|
|
rm -f "$data"
|
2016-09-30 14:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function configure_interactive_hubzilla {
|
|
|
|
while true
|
|
|
|
do
|
2018-02-27 15:11:56 +01:00
|
|
|
data=$(mktemp 2>/dev/null)
|
2016-09-30 14:34:09 +02:00
|
|
|
dialog --backtitle $"Freedombone Control Panel" \
|
|
|
|
--title $"Hubzilla" \
|
|
|
|
--radiolist $"Choose an operation:" 13 70 4 \
|
|
|
|
1 $"Set channel directory server" off \
|
|
|
|
2 $"Renew SSL certificate" off \
|
2018-02-27 15:11:56 +01:00
|
|
|
3 $"Back to main menu" on 2> "$data"
|
2016-09-30 14:34:09 +02:00
|
|
|
sel=$?
|
|
|
|
case $sel in
|
|
|
|
1) break;;
|
|
|
|
255) break;;
|
|
|
|
esac
|
2018-02-27 15:11:56 +01:00
|
|
|
case $(cat "$data") in
|
2016-09-30 14:34:09 +02:00
|
|
|
1) hubzilla_channel_directory_server;;
|
|
|
|
2) hubzilla_renew_cert;;
|
2018-02-27 15:11:56 +01:00
|
|
|
3) rm -f "$data"
|
|
|
|
break;;
|
2016-09-30 14:34:09 +02:00
|
|
|
esac
|
2018-02-27 15:11:56 +01:00
|
|
|
rm -f "$data"
|
2016-09-30 14:34:09 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-09-30 12:34:39 +02:00
|
|
|
function install_interactive_hubzilla {
|
2018-02-27 15:11:56 +01:00
|
|
|
if [[ "$ONION_ONLY" != "no" ]]; then
|
2016-10-09 19:39:55 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-10-15 19:35:04 +02:00
|
|
|
function_check interactive_site_details
|
|
|
|
interactive_site_details hubzilla
|
|
|
|
|
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_hubzilla {
|
2018-02-27 15:11:56 +01:00
|
|
|
# HUBZILLA_USERNAME="$1"
|
2016-11-20 13:37:13 +01:00
|
|
|
HUBZILLA_PASSWORD="$2"
|
|
|
|
if [ ${#HUBZILLA_PASSWORD} -lt 8 ]; then
|
|
|
|
echo $'Hubzilla password is too short'
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
# TODO: This doesn't actually change the password
|
|
|
|
#${PROJECT_NAME}-pass -u $HUBZILLA_USERNAME -a hubzilla -p "$HUBZILLA_PASSWORD"
|
2016-07-25 21:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function hubzilla_create_database {
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
|
|
|
HUBZILLA_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
2016-11-19 10:37:35 +01:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! "$HUBZILLA_ADMIN_PASSWORD" ]; then
|
|
|
|
HUBZILLA_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a hubzilla -p "$HUBZILLA_ADMIN_PASSWORD"
|
|
|
|
if [ ! "$HUBZILLA_ADMIN_PASSWORD" ]; then
|
2016-08-24 16:36:53 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check create_database
|
|
|
|
create_database hubzilla "$HUBZILLA_ADMIN_PASSWORD"
|
2016-07-25 21:02:21 +02:00
|
|
|
}
|
|
|
|
|
2016-07-09 12:36:12 +02:00
|
|
|
function reconfigure_hubzilla {
|
2016-08-24 16:36:53 +02:00
|
|
|
echo -n ''
|
2016-07-09 12:36:12 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 16:01:28 +02:00
|
|
|
function upgrade_hubzilla {
|
2017-06-12 23:59:25 +02:00
|
|
|
CURR_HUBZILLA_COMMIT=$(get_completion_param "hubzilla commit")
|
|
|
|
if [[ "$CURR_HUBZILLA_COMMIT" == "$HUBZILLA_COMMIT" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-08-24 16:36:53 +02:00
|
|
|
HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
|
|
|
|
|
|
|
|
function_check set_repo_commit
|
2018-02-27 15:11:56 +01:00
|
|
|
set_repo_commit "$HUBZILLA_PATH" "hubzilla commit" "$HUBZILLA_COMMIT" $HUBZILLA_REPO
|
|
|
|
set_repo_commit "$HUBZILLA_PATH/addon" "hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT" $HUBZILLA_ADDONS_REPO
|
|
|
|
if [ -d "$HUBZILLA_PATH/redmatrix-themes1" ]; then
|
|
|
|
cd "$HUBZILLA_PATH/redmatrix-themes1" || exit 246782456
|
2016-11-12 12:06:51 +01:00
|
|
|
git merge --abort
|
2016-08-24 16:36:53 +02:00
|
|
|
git stash
|
|
|
|
git pull
|
2018-03-03 12:49:17 +01:00
|
|
|
cp -r "$HUBZILLA_PATH/redmatrix-themes1/"* "$HUBZILLA_PATH/view/theme/"
|
2018-02-27 15:11:56 +01:00
|
|
|
chown -R www-data:www-data "$HUBZILLA_PATH"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2016-07-06 16:01:28 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_local_hubzilla {
|
2016-10-05 23:33:41 +02:00
|
|
|
hubzilla_path=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ -d "$hubzilla_path" ]; then
|
2016-10-05 23:33:41 +02:00
|
|
|
function_check backup_database_to_usb
|
|
|
|
backup_database_to_usb hubzilla
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
backup_directory_to_usb "$hubzilla_path" hubzilla
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2016-07-06 15:55:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-09 11:40:36 +02:00
|
|
|
function restore_local_hubzilla {
|
2016-10-05 23:33:41 +02:00
|
|
|
temp_restore_dir=/root/temphubzilla
|
|
|
|
hubzilla_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2016-10-05 23:33:41 +02:00
|
|
|
function_check hubzilla_create_database
|
|
|
|
hubzilla_create_database
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
restore_database hubzilla "${HUBZILLA_DOMAIN_NAME}"
|
|
|
|
if [ -d "$USB_MOUNT/backup/hubzilla" ]; then
|
|
|
|
if [ ! -d "$hubzilla_dir/store/[data]/smarty3" ]; then
|
|
|
|
mkdir -p "$hubzilla_dir/store/[data]/smarty3"
|
2016-10-05 23:33:41 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
chmod 1777 "$hubzilla_dir/store/[data]/smarty3"
|
2018-03-03 12:49:17 +01:00
|
|
|
chown -R www-data:www-data "$hubzilla_dir/"*
|
2016-10-05 23:33:41 +02:00
|
|
|
if [ -d $temp_restore_dir ]; then
|
|
|
|
rm -rf $temp_restore_dir
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2017-06-25 21:39:44 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
|
|
|
|
HUBZILLA_PATH="/var/www/$HUBZILLA_DOMAIN_NAME/htdocs"
|
|
|
|
sed -i "s|\$db_pass =.*|\$db_pass = '${MARIADB_PASSWORD}';|g" "$HUBZILLA_PATH/.htconfig.php"
|
2017-06-25 21:39:44 +02:00
|
|
|
MARIADB_PASSWORD=
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2016-07-09 11:40:36 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_remote_hubzilla {
|
2018-02-27 15:11:56 +01:00
|
|
|
temp_backup_dir="/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs"
|
|
|
|
if [ -d "$temp_backup_dir" ]; then
|
|
|
|
suspend_site "${HUBZILLA_DOMAIN_NAME}"
|
2016-10-05 23:33:41 +02:00
|
|
|
backup_database_to_friend hubzilla
|
|
|
|
echo "Backing up Hubzilla installation"
|
2018-02-27 15:11:56 +01:00
|
|
|
backup_directory_to_friend "$temp_backup_dir" hubzilla
|
2016-10-05 23:33:41 +02:00
|
|
|
restart_site
|
|
|
|
echo "Backup of Hubzilla complete"
|
|
|
|
else
|
|
|
|
echo $"Hubzilla domain specified but not found in /var/www/${HUBZILLA_DOMAIN_NAME}"
|
|
|
|
exit 2578
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2016-07-04 22:02:22 +02:00
|
|
|
}
|
|
|
|
|
2016-07-09 11:40:36 +02:00
|
|
|
function restore_remote_hubzilla {
|
2016-10-05 23:33:41 +02:00
|
|
|
function_check restore_database_from_friend
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2016-10-05 23:33:41 +02:00
|
|
|
function_check hubzilla_create_database
|
|
|
|
hubzilla_create_database
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
restore_database_from_friend hubzilla "${HUBZILLA_DOMAIN_NAME}"
|
|
|
|
if [ -d "$SERVER_DIRECTORY/backup/hubzilla" ]; then
|
|
|
|
if [ ! -d "/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3" ]; then
|
|
|
|
mkdir -p "/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
chmod 1777 "/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3"
|
2018-03-03 12:49:17 +01:00
|
|
|
chown -R www-data:www-data "/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/"*
|
2016-10-05 23:33:41 +02:00
|
|
|
fi
|
|
|
|
if [ -d /root/temphubzilla ]; then
|
|
|
|
rm -rf /root/temphubzilla
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2017-06-25 21:39:44 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
|
2017-06-25 21:39:44 +02:00
|
|
|
HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
|
2018-02-27 15:11:56 +01:00
|
|
|
sed -i "s|\$db_pass =.*|\$db_pass = '${MARIADB_PASSWORD}';|g" "$HUBZILLA_PATH/.htconfig.php"
|
2017-06-25 21:39:44 +02:00
|
|
|
MARIADB_PASSWORD=
|
2016-07-09 11:40:36 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 22:40:03 +02:00
|
|
|
function remove_hubzilla {
|
2016-10-09 21:57:06 +02:00
|
|
|
if [ ${#HUBZILLA_DOMAIN_NAME} -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_dissite "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
remove_certs "${HUBZILLA_DOMAIN_NAME}"
|
|
|
|
if [ -d "/var/www/$HUBZILLA_DOMAIN_NAME" ]; then
|
|
|
|
rm -rf "/var/www/$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ -f "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME" ]; then
|
|
|
|
rm "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
|
|
|
function_check drop_database
|
|
|
|
drop_database hubzilla
|
|
|
|
function_check remove_onion_service
|
|
|
|
remove_onion_service hubzilla ${HUBZILLA_ONION_PORT}
|
2018-02-27 15:11:56 +01:00
|
|
|
sed -i '/hubzilla/d' "$COMPLETION_FILE"
|
2016-11-12 15:26:14 +01:00
|
|
|
sed -i '/poller.php/d' /etc/crontab
|
2016-11-06 15:13:00 +01:00
|
|
|
|
|
|
|
function_check remove_ddns_domain
|
2018-02-27 15:11:56 +01:00
|
|
|
remove_ddns_domain "$HUBZILLA_DOMAIN_NAME"
|
2016-07-03 22:40:03 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
function install_hubzilla {
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! "$HUBZILLA_DOMAIN_NAME" ]; then
|
2016-08-24 16:36:53 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [[ "$ONION_ONLY" != "no" ]]; then
|
2017-06-07 21:17:28 +02:00
|
|
|
echo $"Hubzilla won't work on an onion address"
|
|
|
|
exit 529925
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
HUBZILLA_PATH="/var/www/$HUBZILLA_DOMAIN_NAME/htdocs"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
|
|
|
function_check install_mariadb
|
|
|
|
install_mariadb
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ -d "/var/www/$HUBZILLA_DOMAIN_NAME" ]; then
|
2018-02-18 12:44:25 +01:00
|
|
|
remove_hubzilla
|
2018-02-18 12:43:44 +01:00
|
|
|
fi
|
|
|
|
|
2016-08-24 16:36:53 +02:00
|
|
|
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-common php-cli php-curl php-gd php-mysql php-mcrypt git
|
2017-06-03 18:42:22 +02:00
|
|
|
apt-get -yq install php-dev imagemagick php-imagick libfcgi0ldbl
|
2017-06-09 16:10:10 +02:00
|
|
|
apt-get -yq install php-memcached memcached
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME" ]; then
|
|
|
|
mkdir "/var/www/$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -d "$HUBZILLA_PATH" ]; then
|
|
|
|
mkdir -p "$HUBZILLA_PATH"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -f "$HUBZILLA_PATH/index.php" ]; then
|
2017-06-15 13:33:16 +02:00
|
|
|
if [ -d /repos/hubzilla ]; then
|
2018-02-27 15:11:56 +01:00
|
|
|
mkdir "$HUBZILLA_PATH"
|
|
|
|
cp -r -p /repos/hubzilla/. "$HUBZILLA_PATH"
|
|
|
|
cd "$HUBZILLA_PATH" || exit 245672478
|
2017-06-15 13:33:16 +02:00
|
|
|
git pull
|
|
|
|
else
|
|
|
|
function_check git_clone
|
2018-02-27 15:11:56 +01:00
|
|
|
git_clone "$HUBZILLA_REPO" "$HUBZILLA_PATH"
|
2017-06-15 13:33:16 +02:00
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
git checkout "$HUBZILLA_COMMIT" -b "$HUBZILLA_COMMIT"
|
2016-10-16 20:50:56 +02:00
|
|
|
set_completion_param "hubzilla commit" "$HUBZILLA_COMMIT"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2017-06-15 13:33:16 +02:00
|
|
|
if [ -d /repos/hubzilla-addons ]; then
|
2018-02-27 15:11:56 +01:00
|
|
|
mkdir "$HUBZILLA_PATH/addon"
|
|
|
|
cp -r -p /repos/hubzilla-addons/. "$HUBZILLA_PATH/addon"
|
|
|
|
cd "$HUBZILLA_PATH/addon" || exit 24682464
|
2017-06-15 13:33:16 +02:00
|
|
|
git pull
|
|
|
|
else
|
2018-02-27 15:11:56 +01:00
|
|
|
git_clone "$HUBZILLA_ADDONS_REPO" "$HUBZILLA_PATH/addon"
|
2017-06-15 13:33:16 +02:00
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
cd "$HUBZILLA_PATH/addon" || exit 24982468
|
|
|
|
git checkout "$HUBZILLA_ADDONS_COMMIT" -b "$HUBZILLA_ADDONS_COMMIT"
|
2016-10-16 20:50:56 +02:00
|
|
|
set_completion_param "hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
chown -R www-data:www-data "$HUBZILLA_PATH"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -f "$HUBZILLA_PATH/install/schema_mysql.sql" ]; then
|
2018-02-18 13:45:44 +01:00
|
|
|
echo $'No database schema found for hubzilla'
|
|
|
|
exit 252782
|
|
|
|
fi
|
|
|
|
|
2016-08-24 16:36:53 +02:00
|
|
|
HUBZILLA_ONION_HOSTNAME=
|
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
HUBZILLA_ONION_HOSTNAME=$(add_onion_service hubzilla 80 ${HUBZILLA_ONION_PORT})
|
|
|
|
fi
|
|
|
|
|
|
|
|
hubzilla_create_database
|
|
|
|
|
|
|
|
if ! grep -q "$HUBZILLA_PATH" /etc/crontab; then
|
|
|
|
echo "12,22,32,42,52 * * * * root cd $HUBZILLA_PATH; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check add_ddns_domain
|
2018-02-27 15:11:56 +01:00
|
|
|
add_ddns_domain "$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [[ "$ONION_ONLY" == "no" ]]; then
|
2016-08-24 16:36:53 +02:00
|
|
|
function_check nginx_http_redirect
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_http_redirect "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
{ echo 'server {';
|
|
|
|
echo ' listen 443 ssl;';
|
|
|
|
echo ' #listen [::]:443 ssl;';
|
|
|
|
echo " root $HUBZILLA_PATH;";
|
|
|
|
echo " server_name $HUBZILLA_DOMAIN_NAME;";
|
|
|
|
echo " error_log /dev/null;";
|
|
|
|
echo ' index index.php;';
|
|
|
|
echo ' charset utf-8;';
|
|
|
|
echo ' access_log /dev/null;'; } >> "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
function_check nginx_ssl
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_ssl "$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
function_check nginx_disable_sniffing
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_disable_sniffing "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
|
|
|
echo '';
|
|
|
|
echo ' # rewrite to front controller as default rule';
|
|
|
|
echo ' location / {'; } >> "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
2016-10-01 13:18:23 +02:00
|
|
|
function_check nginx_limits
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_limits "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
{ echo " rewrite ^/(.*) /index.php?q=\$uri&\$args last;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # statically serve these file types when possible';
|
|
|
|
echo ' # otherwise fall back to front controller';
|
|
|
|
echo ' # allow browser to cache them';
|
|
|
|
echo ' # added .htm for advanced source code editor library';
|
|
|
|
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {';
|
|
|
|
echo ' expires 30d;';
|
|
|
|
echo " try_files \$uri /index.php?q=\$uri&\$args;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # block these file types';
|
|
|
|
echo ' location ~* \.(tpl|md|tgz|log|out)$ {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000';
|
|
|
|
echo ' # or a unix socket';
|
|
|
|
echo ' location ~* \.php$ {'; } >> "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
2016-10-01 13:18:23 +02:00
|
|
|
function_check nginx_limits
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_limits "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
{ echo ' # Zero-day exploit defense.';
|
|
|
|
echo ' # http://forum.nginx.org/read.php?2,88845,page=3';
|
|
|
|
echo " # Won't work properly (404 error) if the file is not stored on this";
|
|
|
|
echo " # server, which is entirely possible with php-fpm/php-fcgi.";
|
|
|
|
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on";
|
|
|
|
echo " # another machine. And then cross your fingers that you won't get hacked.";
|
|
|
|
echo " try_files \$uri \$uri/ /index.php;";
|
|
|
|
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini';
|
|
|
|
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;';
|
|
|
|
echo ' # With php-cgi alone:';
|
|
|
|
echo ' # fastcgi_pass 127.0.0.1:9000;';
|
|
|
|
echo ' # With php-fpm:';
|
|
|
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
|
|
|
echo ' include fastcgi_params;';
|
|
|
|
echo ' fastcgi_index index.php;';
|
|
|
|
echo " fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;";
|
|
|
|
echo ' fastcgi_read_timeout 300;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # deny access to all dot files';
|
|
|
|
echo ' location ~ /\. {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' location ~ /\.ht {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '}';
|
|
|
|
echo ''; } >> "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
else
|
2018-02-27 15:11:56 +01:00
|
|
|
{ echo 'server {';
|
|
|
|
echo " listen 127.0.0.1:${HUBZILLA_ONION_PORT} default_server;";
|
|
|
|
echo " root $HUBZILLA_PATH;";
|
|
|
|
echo " server_name $HUBZILLA_ONION_HOSTNAME;";
|
|
|
|
echo " error_log /dev/null;";
|
|
|
|
echo ' index index.php;';
|
|
|
|
echo ' charset utf-8;';
|
|
|
|
echo ' access_log /dev/null;';
|
|
|
|
echo ' add_header Strict-Transport-Security max-age=15768000;';
|
|
|
|
echo '';
|
|
|
|
echo ' # rewrite to front controller as default rule';
|
|
|
|
echo ' location / {'; } > "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
|
|
|
nginx_limits "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
nginx_disable_sniffing "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
{ echo " rewrite ^/(.*) /index.php?q=\$uri&\$args last;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # statically serve these file types when possible';
|
|
|
|
echo ' # otherwise fall back to front controller';
|
|
|
|
echo ' # allow browser to cache them';
|
|
|
|
echo ' # added .htm for advanced source code editor library';
|
|
|
|
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {';
|
|
|
|
echo ' expires 30d;';
|
|
|
|
echo " try_files \$uri /index.php?q=\$uri&\$args;";
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # block these file types';
|
|
|
|
echo ' location ~* \.(tpl|md|tgz|log|out)$ {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000';
|
|
|
|
echo ' # or a unix socket';
|
|
|
|
echo ' location ~* \.php$ {'; } >> "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
|
|
|
nginx_limits "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
nginx_disable_sniffing "$HUBZILLA_DOMAIN_NAME"
|
|
|
|
{ echo ' # Zero-day exploit defense.';
|
|
|
|
echo ' # http://forum.nginx.org/read.php?2,88845,page=3';
|
|
|
|
echo " # Won't work properly (404 error) if the file is not stored on this";
|
|
|
|
echo " # server, which is entirely possible with php-fpm/php-fcgi.";
|
|
|
|
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on";
|
|
|
|
echo " # another machine. And then cross your fingers that you won't get hacked.";
|
|
|
|
echo " try_files \$uri \$uri/ /index.php;";
|
|
|
|
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini';
|
|
|
|
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;';
|
|
|
|
echo ' # With php-cgi alone:';
|
|
|
|
echo ' # fastcgi_pass 127.0.0.1:9000;';
|
|
|
|
echo ' # With php-fpm:';
|
|
|
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
|
|
|
echo ' include fastcgi_params;';
|
|
|
|
echo ' fastcgi_index index.php;';
|
|
|
|
echo " fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;";
|
|
|
|
echo ' fastcgi_read_timeout 300;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' # deny access to all dot files';
|
|
|
|
echo ' location ~ /\. {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo ' location ~ /\.ht {';
|
|
|
|
echo ' deny all;';
|
|
|
|
echo ' }';
|
|
|
|
echo '}'; } >> "/etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
function_check configure_php
|
|
|
|
configure_php
|
|
|
|
|
|
|
|
function_check create_site_certificate
|
2018-02-27 15:11:56 +01:00
|
|
|
create_site_certificate "$HUBZILLA_DOMAIN_NAME" 'yes'
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
if [ ! -d "$HUBZILLA_PATH/view/tpl/smarty3" ]; then
|
|
|
|
mkdir "$HUBZILLA_PATH/view/tpl/smarty3"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
|
|
|
if [ ! -d "$HUBZILLA_PATH/store" ]; then
|
|
|
|
mkdir "$HUBZILLA_PATH/store"
|
|
|
|
fi
|
|
|
|
if [ ! -d "$HUBZILLA_PATH/store/[data]" ]; then
|
|
|
|
mkdir "$HUBZILLA_PATH/store/[data]"
|
|
|
|
fi
|
|
|
|
if [ ! -d "$HUBZILLA_PATH/store/[data]/smarty3" ]; then
|
|
|
|
mkdir "$HUBZILLA_PATH/store/[data]/smarty3"
|
2017-04-14 11:59:07 +02:00
|
|
|
chmod 1777 "$HUBZILLA_PATH/store/[data]/smarty3"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
chmod 1777 "$HUBZILLA_PATH/view/tpl"
|
2016-08-24 16:36:53 +02:00
|
|
|
chown -R www-data:www-data "$HUBZILLA_PATH/store"
|
2018-02-27 15:11:56 +01:00
|
|
|
chmod 1777 "$HUBZILLA_PATH/view/tpl/smarty3"
|
2016-08-24 16:36:53 +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 hubzilla
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
chown -R www-data:www-data "$HUBZILLA_PATH"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
|
|
|
function_check nginx_ensite
|
2018-02-27 15:11:56 +01:00
|
|
|
nginx_ensite "$HUBZILLA_DOMAIN_NAME"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
|
|
|
function_check initialise_database
|
2018-02-27 15:11:56 +01:00
|
|
|
initialise_database hubzilla "$HUBZILLA_PATH/install/schema_mysql.sql"
|
2016-08-24 16:36:53 +02:00
|
|
|
|
|
|
|
# create the config file
|
2018-02-27 15:11:56 +01:00
|
|
|
{ echo '<?php';
|
|
|
|
echo "\$db_host = 'localhost';";
|
|
|
|
echo "\$db_port = '0';";
|
|
|
|
echo "\$db_user = 'root';";
|
|
|
|
echo "\$db_pass = '${MARIADB_PASSWORD}';";
|
|
|
|
echo "\$db_data = 'hubzilla';";
|
|
|
|
echo "\$db_type = '0';";
|
|
|
|
echo "\$default_timezone = 'Europe/London';"; } > "$HUBZILLA_PATH/.htconfig.php"
|
|
|
|
if [[ "$ONION_ONLY" == 'no' ]]; then
|
|
|
|
echo "\$a->config['system']['baseurl'] = 'https://${HUBZILLA_DOMAIN_NAME}';" >> "$HUBZILLA_PATH/.htconfig.php"
|
2016-08-24 16:36:53 +02:00
|
|
|
else
|
2018-02-27 15:11:56 +01:00
|
|
|
echo "\$a->config['system']['baseurl'] = 'http://${HUBZILLA_ONION_HOSTNAME}';" >> "$HUBZILLA_PATH/.htconfig.php"
|
2016-08-24 16:36:53 +02:00
|
|
|
fi
|
2018-02-27 15:11:56 +01:00
|
|
|
echo "\$a->config['system']['sitename'] = \"Hubzilla\";" >> "$HUBZILLA_PATH/.htconfig.php"
|
2016-08-24 16:36:53 +02:00
|
|
|
HUBZILLA_LOCATION_HASH="$(create_password 30)"
|
2018-02-27 15:11:56 +01:00
|
|
|
{ echo "\$a->config['system']['location_hash'] = '${HUBZILLA_LOCATION_HASH}';";
|
|
|
|
echo "\$a->config['system']['register_policy'] = REGISTER_OPEN;";
|
|
|
|
echo "\$a->config['system']['register_text'] = '';";
|
|
|
|
echo "\$a->config['system']['admin_email'] = '${MY_EMAIL_ADDRESS}';";
|
|
|
|
echo "\$a->config['system']['verify_email'] = 1;";
|
|
|
|
echo "\$a->config['system']['access_policy'] = ACCESS_PRIVATE;";
|
|
|
|
echo "\$a->config['system']['sellpage'] = '';";
|
|
|
|
echo "\$a->config['system']['max_import_size'] = 200000;";
|
|
|
|
echo "\$a->config['system']['php_path'] = '/usr/bin/php';";
|
|
|
|
echo "\$a->config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;";
|
|
|
|
echo "\$a->config['system']['theme'] = 'redbasic';"; } >> "$HUBZILLA_PATH/.htconfig.php"
|
|
|
|
chown www-data:www-data "$HUBZILLA_PATH/.htconfig.php"
|
|
|
|
chmod 755 "$HUBZILLA_PATH/.htconfig.php"
|
2016-08-24 16:36:53 +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-08-24 16:36:53 +02:00
|
|
|
systemctl restart nginx
|
|
|
|
systemctl restart cron
|
|
|
|
|
2018-02-27 15:11:56 +01:00
|
|
|
"${PROJECT_NAME}-addemail" -u "$MY_USERNAME" -e "noreply@$HUBZILLA_DOMAIN_NAME" -g hubzilla --public no
|
2016-08-24 16:36:53 +02:00
|
|
|
|
2016-10-16 20:50:56 +02:00
|
|
|
set_completion_param "hubzilla domain" "${HUBZILLA_DOMAIN_NAME}"
|
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"
|