Preparing for hubzilla

This commit is contained in:
Bob Mottram 2015-09-06 22:24:56 +01:00
parent 14838112eb
commit 7b68fa1847
1 changed files with 566 additions and 20 deletions

View File

@ -154,6 +154,13 @@ REDMATRIX_REPO="https://github.com/redmatrix/redmatrix.git"
REDMATRIX_ADDONS_REPO="https://github.com/redmatrix/redmatrix-addons.git"
REDMATRIX_ADMIN_PASSWORD=
# Domain name for hubzilla installation
HUBZILLA_DOMAIN_NAME=
HUBZILLA_CODE=
HUBZILLA_REPO="https://github.com/redmatrix/hubzilla.git"
HUBZILLA_ADDONS_REPO="https://github.com/redmatrix/hubzilla-addons.git"
HUBZILLA_ADMIN_PASSWORD=
# Domain name for git hosting installation
GIT_DOMAIN_NAME=
GIT_CODE=
@ -439,6 +446,7 @@ function show_help {
echo ' --blogdomain Blog domain name'
echo ' --ownclouddomain Owncloud domain name'
echo ' --redmatrixdomain Redmatrix domain name'
echo ' --hubzilladomain Hubzilla domain name'
echo ' --gitdomain Git hosting domain name'
echo ' -t --time Domain used as a TLS time source'
echo ' --ssh ssh port number'
@ -591,6 +599,11 @@ else
shift
REDMATRIX_DOMAIN_NAME="$1"
;;
# hubzilla domain name
--hubzilladomain)
shift
HUBZILLA_DOMAIN_NAME="$1"
;;
# git hosting domain name
--gitdomain)
shift
@ -979,6 +992,12 @@ function read_configuration {
if grep -q "REDMATRIX_CODE" $CONFIGURATION_FILE; then
REDMATRIX_CODE=$(grep "REDMATRIX_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "OWNCLOUD_DOMAIN_NAME" $CONFIGURATION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(grep "OWNCLOUD_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
@ -1047,106 +1066,151 @@ function check_domains {
if [ $WIKI_DOMAIN_NAME ]; then
test_domain_name "$WIKI_DOMAIN_NAME"
if [[ "$WIKI_DOMAIN_NAME" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
echo 'Wiki domain name is the same as Owncloud domain name. They must be different'
exit 73863
fi
if [[ "$WIKI_DOMAIN_NAME" == "$FULLBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
echo 'Wiki domain name is the same as blog domain name. They must be different'
exit 97326
fi
if [[ "$WIKI_DOMAIN_NAME" == "$MICROBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
echo 'Wiki domain name is the same as microblog domain name. They must be different'
exit 36827
fi
if [[ "$WIKI_DOMAIN_NAME" == "$REDMATRIX_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$REDMATRIX_DOMAIN_NAME" ]]; then
echo 'Wiki domain name is the same as redmatrix domain name. They must be different'
exit 93637
fi
if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
echo 'Wiki domain name is the same as hubzilla domain name. They must be different'
exit 65848
fi
fi
if [ $OWNCLOUD_DOMAIN_NAME ]; then
test_domain_name "$OWNCLOUD_DOMAIN_NAME"
if [[ "$OWNCLOUD_DOMAIN_NAME" == "$WIKI_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
echo 'Owncloud domain name is the same as wiki domain name. They must be different'
exit 37994
fi
if [[ "$OWNCLOUD_DOMAIN_NAME" == "$FULLBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
echo 'Owncloud domain name is the same as blog domain name. They must be different'
exit 37936
fi
if [[ "$OWNCLOUD_DOMAIN_NAME" == "$MICROBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
echo 'Owncloud domain name is the same as microblog domain name. They must be different'
exit 36896
fi
if [[ "$OWNCLOUD_DOMAIN_NAME" == "$REDMATRIX_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$REDMATRIX_DOMAIN_NAME" ]]; then
echo 'Owncloud domain name is the same as redmatrix domain name. They must be different'
exit 79362
fi
if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
echo 'Owncloud domain name is the same as hubzilla domain name. They must be different'
exit 68365
fi
fi
if [ $FULLBLOG_DOMAIN_NAME ]; then
test_domain_name "$FULLBLOG_DOMAIN_NAME"
if [[ "$FULLBLOG_DOMAIN_NAME" == "$WIKI_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
echo 'Blog domain name is the same as wiki domain name. They must be different'
exit 62348
fi
if [[ "$FULLBLOG_DOMAIN_NAME" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
echo 'Blog domain name is the same as Owncloud domain name. They must be different'
exit 84682
fi
if [[ "$FULLBLOG_DOMAIN_NAME" == "$MICROBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
echo 'Blog domain name is the same as microblog domain name. They must be different'
exit 38236
fi
if [[ "$FULLBLOG_DOMAIN_NAME" == "$REDMATRIX_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$REDMATRIX_DOMAIN_NAME" ]]; then
echo 'Blog domain name is the same as redmatrix domain name. They must be different'
exit 36813
fi
if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
echo 'Blog domain name is the same as hubzilla domain name. They must be different'
exit 35483
fi
fi
if [ $MICROBLOG_DOMAIN_NAME ]; then
test_domain_name "$MICROBLOG_DOMAIN_NAME"
if [[ "$MICROBLOG_DOMAIN_NAME" == "$WIKI_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
echo 'Microblog domain name is the same as wiki domain name. They must be different'
exit 73924
fi
if [[ "$MICROBLOG_DOMAIN_NAME" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
echo 'Microblog domain name is the same as Owncloud domain name. They must be different'
exit 73683
fi
if [[ "$MICROBLOG_DOMAIN_NAME" == "$FULLBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
echo 'Microblog domain name is the same as blog domain name. They must be different'
exit 26832
fi
if [[ "$MICROBLOG_DOMAIN_NAME" == "$REDMATRIX_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$REDMATRIX_DOMAIN_NAME" ]]; then
echo 'Microblog domain name is the same as redmatrix domain name. They must be different'
exit 36373
fi
if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
echo 'Microblog domain name is the same as hubzilla domain name. They must be different'
exit 678382
fi
fi
if [ $REDMATRIX_DOMAIN_NAME ]; then
test_domain_name "$REDMATRIX_DOMAIN_NAME"
if [[ "$REDMATRIX_DOMAIN_NAME" == "$WIKI_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as wiki domain name. They must be different'
exit 83682
fi
if [[ "$REDMATRIX_DOMAIN_NAME" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as Owncloud domain name. They must be different'
exit 65192
fi
if [[ "$REDMATRIX_DOMAIN_NAME" == "$FULLBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as blog domain name. They must be different'
exit 74817
fi
if [[ "$REDMATRIX_DOMAIN_NAME" == "$MICROBLOG_DOMAIN_NAME" ]]; then
if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as microblog domain name. They must be different'
exit 83683
fi
if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as hubzilla domain name. They must be different'
exit 82672
fi
fi
if [ $HUBZILLA_DOMAIN_NAME ]; then
test_domain_name "$HUBZILLA_DOMAIN_NAME"
if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as wiki domain name. They must be different'
exit 83682
fi
if [[ "$test_domain_name" == "$OWNCLOUD_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as Owncloud domain name. They must be different'
exit 65192
fi
if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as blog domain name. They must be different'
exit 74817
fi
if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as microblog domain name. They must be different'
exit 83683
fi
if [[ "$test_domain_name" == "$REDMATRIX_DOMAIN_NAME" ]]; then
echo 'RedMatrix domain name is the same as redmatrix domain name. They must be different'
exit 82672
fi
fi
}
@ -2404,6 +2468,14 @@ function get_mariadb_redmatrix_admin_password {
fi
}
function get_mariadb_hubzilla_admin_password {
if [ -f /home/$MY_USERNAME/README ]; then
if grep -q "MariaDB Hubzilla admin password" /home/$MY_USERNAME/README; then
HUBZILLA_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB Hubzilla admin password" | awk -F ':' '{print $2}' | sed 's/^ *//')
fi
fi
}
function get_mariadb_owncloud_admin_password {
if [ -f /home/$MY_USERNAME/README ]; then
if grep -q "Owncloud database password" /home/$MY_USERNAME/README; then
@ -2422,6 +2494,7 @@ function create_backup_script {
get_mariadb_password
get_mariadb_gnusocial_admin_password
get_mariadb_redmatrix_admin_password
get_mariadb_hubzilla_admin_password
get_mariadb_owncloud_admin_password
get_mariadb_git_admin_password
@ -2574,6 +2647,47 @@ function create_backup_script {
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
BACKUP_INCLUDES_DATABASES="yes"
echo "if [ ! -d $USB_MOUNT/backup/hubzilla ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/hubzilla" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d $USB_MOUNT/backup/hubzilladata ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/hubzilladata" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -d /root/temphubzilladata ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /root/temphubzilladata" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Obtaining Red Matrix database backup"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'mysqldump --password=$DATABASE_PASSWORD hubzilla > /root/temphubzilladata/hubzilla.sql' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ ! -s /root/temphubzilladata/hubzilla.sql ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Red Matrix database could not be saved"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! $DATABASE_PASSWORD ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " echo 'No MariaDB password was given'" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " fi" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' shred -zu /root/temphubzilladata/*' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 378' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "fi" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "rsyncrypto -v -r /root/temphubzilladata $USB_MOUNT/backup/hubzilladata $USB_MOUNT/backup/hubzilladata.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 285' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'shred -zu /root/temphubzilladata/*' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'rm -rf /root/temphubzilladata' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'echo "Backing up Red Matrix installation"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "rsyncrypto -v -r /var/www/$HUBZILLA_DOMAIN_NAME/htdocs $USB_MOUNT/backup/hubzilla $USB_MOUNT/backup/hubzilla.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 593' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
BACKUP_INCLUDES_DATABASES="yes"
echo "if [ ! -d $USB_MOUNT/backup/owncloud ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -3081,6 +3195,7 @@ function create_restore_script {
get_mariadb_password
get_mariadb_gnusocial_admin_password
get_mariadb_redmatrix_admin_password
get_mariadb_hubzilla_admin_password
get_mariadb_owncloud_admin_password
get_mariadb_git_admin_password
@ -3496,6 +3611,56 @@ function create_restore_script {
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
echo "if [ -d $USB_MOUNT/backup/hubzilla ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Red Matrix database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /root/temphubzilladata ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/temphubzilladata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/hubzilladata /root/temphubzilladata $USB_MOUNT/backup/hubzilladata.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -f /root/temphubzilladata/usb/backup/hubzilladata/temphubzilladata/hubzilla.sql ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Unable to restore Red Matrix database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 504' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD hubzilla -o < /root/temphubzilladata/usb/backup/hubzilladata/temphubzilladata/hubzilla.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 965' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' shred -zu /root/temphubzilladata/usb/backup/hubzilladata/temphubzilladata/*' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Red Matrix installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /root/temphubzilla ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/temphubzilla' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/hubzilla /root/temphubzilla $USB_MOUNT/backup/hubzilla.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf /var/www/$HUBZILLA_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -r /root/temphubzilla/usb/backup/hubzilla/www/$HUBZILLA_DOMAIN_NAME/htdocs/* /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' else' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mv /root/temphubzilla/usb/backup/hubzilla/www/$HUBZILLA_DOMAIN_NAME/htdocs /var/www/$HUBZILLA_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 759' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temphubzilla' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$HUBZILLA_DOMAIN_NAME.crt|$HUBZILLA_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " chmod 777 /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/*" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
fi
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
@ -3842,6 +4007,12 @@ function create_freedns_updater {
echo "$FREEDNS_WGET$REDMATRIX_CODE=" >> /usr/bin/dynamicdns
fi
fi
if [ $HUBZILLA_CODE ]; then
if [[ $HUBZILLA_CODE != "$DEFAULT_DOMAIN_CODE" ]]; then
echo "# $HUBZILLA_DOMAIN_NAME" >> /usr/bin/dynamicdns
echo "$FREEDNS_WGET$HUBZILLA_CODE=" >> /usr/bin/dynamicdns
fi
fi
if [ $OWNCLOUD_CODE ]; then
if [[ $OWNCLOUD_CODE != "$DEFAULT_DOMAIN_CODE" ]]; then
echo "# $OWNCLOUD_DOMAIN_NAME" >> /usr/bin/dynamicdns
@ -3891,6 +4062,7 @@ function backup_to_friends_servers {
get_mariadb_password
get_mariadb_gnusocial_admin_password
get_mariadb_redmatrix_admin_password
get_mariadb_hubzilla_admin_password
get_mariadb_owncloud_admin_password
get_mariadb_git_admin_password
@ -4044,6 +4216,53 @@ function backup_to_friends_servers {
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
BACKUP_INCLUDES_DATABASES="yes"
echo 'if [ ! -d $SERVER_DIRECTORY/backup/hubzilla ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/hubzilla' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'if [ ! -d $SERVER_DIRECTORY/backup/hubzilladata ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/hubzilladata' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ ! -d /root/temphubzilladata ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /root/temphubzilladata" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'echo "Obtaining Red Matrix database backup"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'mysqldump --password=$DATABASE_PASSWORD hubzilla > /root/temphubzilladata/hubzilla.sql' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ ! -s /root/temphubzilladata/hubzilla.sql ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Red Matrix database could not be saved"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! $DATABASE_PASSWORD ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " echo 'No MariaDB password was given'" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " fi" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' echo "Unable to export hubzilla database" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' exit 378' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "fi" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n 'rsyncrypto -v -r /root/temphubzilladata $SERVER_DIRECTORY/backup/hubzilladata $SERVER_DIRECTORY/backup/hubzilladata.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' shred -zu /root/temphubzilladata/*' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' echo "Unable to encrypt hubzilla database" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' exit 285' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'shred -zu /root/temphubzilladata/*' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'rm -rf /root/temphubzilladata' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'echo "Backing up Red Matrix installation"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n "rsyncrypto -v -r /var/www/$HUBZILLA_DOMAIN_NAME/htdocs " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/hubzilla $SERVER_DIRECTORY/backup/hubzilla.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' echo "Unable to encrypt hubzilla installation" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' exit 593' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
fi
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
BACKUP_INCLUDES_DATABASES="yes"
echo 'if [ ! -d $SERVER_DIRECTORY/backup/owncloud ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -4703,6 +4922,7 @@ function restore_from_friend {
get_mariadb_password
get_mariadb_gnusocial_admin_password
get_mariadb_redmatrix_admin_password
get_mariadb_hubzilla_admin_password
get_mariadb_owncloud_admin_password
get_mariadb_git_admin_password
@ -5087,6 +5307,52 @@ function restore_from_friend {
echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
echo 'if [ -d $SERVER_DIRECTORY/backup/hubzilla ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring Red Matrix database"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /root/temphubzilladata ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' mkdir /root/temphubzilladata' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/hubzilladata /root/temphubzilladata $SERVER_DIRECTORY/backup/hubzilladata.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -f /root/temphubzilladata/remoterestore/backup/hubzilladata/temphubzilladata/hubzilla.sql ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Unable to restore Red Matrix database"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 504' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD hubzilla -o < /root/temphubzilladata/remoterestore/backup/hubzilladata/temphubzilladata/hubzilla.sql)' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 965' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' shred -zu /root/temphubzilladata/remoterestore/backup/hubzilladata/temphubzilladata/*' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring Red Matrix installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /root/temphubzilla ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' mkdir /root/temphubzilla' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/hubzilla /root/temphubzilla $SERVER_DIRECTORY/backup/hubzilla.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " rm -rf /var/www/$HUBZILLA_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -r /root/temphubzilla/remoterestore/backup/hubzilla/www/$HUBZILLA_DOMAIN_NAME/htdocs/* /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' else' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " mv /root/temphubzilla/remoterestore/backup/hubzilla/www/$HUBZILLA_DOMAIN_NAME/htdocs /var/www/$HUBZILLA_DOMAIN_NAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 759' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/temphubzilla' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " sed -i 's|$HUBZILLA_DOMAIN_NAME.crt|$HUBZILLA_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " chmod 777 /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/*" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
fi
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
@ -9859,6 +10125,272 @@ quit" > $INSTALL_DIR/batch.sql
echo 'install_redmatrix' >> $COMPLETION_FILE
}
function install_hubzilla {
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
return
fi
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
return
fi
if [ ! $HUBZILLA_DOMAIN_NAME ]; then
return
fi
install_mariadb
get_mariadb_password
repair_databases_script
apt-get -y install php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt git
if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME ]; then
mkdir /var/www/$HUBZILLA_DOMAIN_NAME
fi
if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
mkdir /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
fi
if [ ! -f /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/index.php ]; then
cd $INSTALL_DIR
git clone $HUBZILLA_REPO hubzilla
rm -rf /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
mv hubzilla /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
git clone $HUBZILLA_ADDONS_REPO /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/addon
# some extra themes
git clone https://github.com/DeadSuperHero/hubzilla-themes /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/hubzilla-themes1
cp -r /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/hubzilla-themes1/* view/theme/
fi
get_mariadb_hubzilla_admin_password
if [ ! $HUBZILLA_ADMIN_PASSWORD ]; then
HUBZILLA_ADMIN_PASSWORD="$(openssl rand -base64 32)"
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo 'Hubzilla' >> /home/$MY_USERNAME/README
echo '==========' >> /home/$MY_USERNAME/README
echo "Your MariaDB Hubzilla admin password is: $HUBZILLA_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
fi
echo "create database hubzilla;
CREATE USER 'hubzillaadmin'@'localhost' IDENTIFIED BY '$HUBZILLA_ADMIN_PASSWORD';
GRANT ALL PRIVILEGES ON hubzilla.* TO 'hubzillaadmin'@'localhost';
quit" > $INSTALL_DIR/batch.sql
chmod 600 $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
if ! grep -q "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs" /etc/crontab; then
echo "12,22,32,42,52 * * * * root cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs; /usr/bin/timeout 240 /usr/bin/php include/poller.php" >> /etc/crontab
fi
# update the dynamic DNS
CURRENT_DDNS_DOMAIN=$HUBZILLA_DOMAIN_NAME
add_ddns_domain
echo 'server {' > /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' listen 80;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " server_name $HUBZILLA_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " root /var/www/$HUBZILLA_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " error_log /var/log/nginx/$HUBZILLA_DOMAIN_NAME_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' limit_conn conn_limit_per_ip 10;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' limit_req zone=req_limit_per_ip burst=10 nodelay;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' rewrite ^ https://$server_name$request_uri? permanent;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo 'server {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " root /var/www/$HUBZILLA_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " server_name $HUBZILLA_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " error_log /var/log/nginx/$HUBZILLA_DOMAIN_NAME_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' charset utf-8;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' client_max_body_size 20m;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' client_body_buffer_size 128k;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' access_log off;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' limit_conn conn_limit_per_ip 10;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' limit_req zone=req_limit_per_ip burst=10 nodelay;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' ssl on;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " ssl_certificate /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.crt;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " ssl_certificate_key /etc/ssl/private/$HUBZILLA_DOMAIN_NAME.key;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " ssl_dhparam /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.dhparam;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' ssl_session_timeout 5m;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' ssl_prefer_server_ciphers on;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' ssl_session_cache builtin:1000 shared:SSL:10m;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " ssl_protocols $SSL_PROTOCOLS; # not possible to do exclusive" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " ssl_ciphers '$SSL_CIPHERS';" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' add_header X-Frame-Options DENY;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' add_header X-Content-Type-Options nosniff;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location / {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' allow all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # statically serve these file types when possible' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # allow browser to cache them' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' expires 30d;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # block these file types' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # or a unix socket' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location ~* \.php$ {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # With php5-cgi alone:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # With php5-fpm:' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' include fastcgi_params;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' fastcgi_index index.php;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' deny all;' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo ' }' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo '}' >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
configure_php
if [ ! -f /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.dhparam ]; then
freedombone-addcert -h $HUBZILLA_DOMAIN_NAME --dhkey $DH_KEYLENGTH
check_certificates $HUBZILLA_DOMAIN_NAME
fi
if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/view/tpl/smarty3 ]; then
mkdir /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/view/tpl/smarty3
fi
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store" ]; then
mkdir "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store"
fi
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]" ]; then
mkdir "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]"
fi
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" ]; then
mkdir "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3"
chmod 777 "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3"
fi
chmod 777 /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/view/tpl
chown -R www-data:www-data "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store"
chmod 777 /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/view/tpl/smarty3
# Ensure that the database gets backed up locally, if remote
# backups are not being used
backup_databases_script_header
echo '' >> /usr/bin/backupdatabases
echo '# Backup the Hubzilla database' >> /usr/bin/backupdatabases
echo 'TEMPFILE=/root/hubzilla.sql' >> /usr/bin/backupdatabases
echo 'DAILYFILE=/var/backups/hubzilla_daily.sql' >> /usr/bin/backupdatabases
echo 'mysqldump --password="$MYSQL_PASSWORD" hubzilla > $TEMPFILE' >> /usr/bin/backupdatabases
echo 'FILESIZE=$(stat -c%s $TEMPFILE)' >> /usr/bin/backupdatabases
echo 'if [ "$FILESIZE" -lt "1024" ]; then' >> /usr/bin/backupdatabases
echo ' if [ -f $DAILYFILE ]; then' >> /usr/bin/backupdatabases
echo ' cp $DAILYFILE $TEMPFILE' >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo ' # try to restore yesterdays database' >> /usr/bin/backupdatabases
echo ' mysql -u root --password="$MYSQL_PASSWORD" hubzilla -o < $DAILYFILE' >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo ' # Send a warning email' >> /usr/bin/backupdatabases
echo ' echo "Unable to create a backup of the Hubzilla database. Attempted to restore from yesterdays backup" | mail -s "Hubzilla backup" $EMAIL' >> /usr/bin/backupdatabases
echo ' else' >> /usr/bin/backupdatabases
echo ' # Send a warning email' >> /usr/bin/backupdatabases
echo ' echo "Unable to create a backup of the Hubzilla database." | mail -s "Hubzilla backup" $EMAIL' >> /usr/bin/backupdatabases
echo ' fi' >> /usr/bin/backupdatabases
echo 'else' >> /usr/bin/backupdatabases
echo ' chmod 600 $TEMPFILE' >> /usr/bin/backupdatabases
echo ' mv $TEMPFILE $DAILYFILE' >> /usr/bin/backupdatabases
echo '' >> /usr/bin/backupdatabases
echo ' # Make the backup readable only by root' >> /usr/bin/backupdatabases
echo ' chmod 600 $DAILYFILE' >> /usr/bin/backupdatabases
echo 'fi' >> /usr/bin/backupdatabases
echo '' >> /etc/cron.weekly/backupdatabasesweekly
echo '# Hubzilla' >> /etc/cron.weekly/backupdatabasesweekly
echo 'if [ -f /var/backups/hubzilla_weekly.sql ]; then' >> /etc/cron.weekly/backupdatabasesweekly
echo ' cp -f /var/backups/hubzilla_weekly.sql /var/backups/hubzilla_2weekly.sql' >> /etc/cron.weekly/backupdatabasesweekly
echo 'fi' >> /etc/cron.weekly/backupdatabasesweekly
echo 'if [ -f /var/backups/hubzilla_daily.sql ]; then' >> /etc/cron.weekly/backupdatabasesweekly
echo ' cp -f /var/backups/hubzilla_daily.sql /var/backups/hubzilla_weekly.sql' >> /etc/cron.weekly/backupdatabasesweekly
echo 'fi' >> /etc/cron.weekly/backupdatabasesweekly
echo '' >> /etc/cron.monthly/backupdatabasesmonthly
echo '# Hubzilla' >> /etc/cron.monthly/backupdatabasesmonthly
echo 'if [ -f /var/backups/hubzilla_monthly.sql ]; then' >> /etc/cron.monthly/backupdatabasesmonthly
echo ' cp -f /var/backups/hubzilla_monthly.sql /var/backups/hubzilla_2monthly.sql' >> /etc/cron.monthly/backupdatabasesmonthly
echo 'fi' >> /etc/cron.monthly/backupdatabasesmonthly
echo 'if [ -f /var/backups/hubzilla_weekly.sql ]; then' >> /etc/cron.monthly/backupdatabasesmonthly
echo ' cp -f /var/backups/hubzilla_weekly.sql /var/backups/hubzilla_monthly.sql' >> /etc/cron.monthly/backupdatabasesmonthly
echo 'fi' >> /etc/cron.monthly/backupdatabasesmonthly
echo '/usr/bin/repairdatabase hubzilla' >> /etc/cron.hourly/repair
nginx_ensite $HUBZILLA_DOMAIN_NAME
service php5-fpm restart
service nginx restart
service cron restart
# some post-install instructions for the user
if ! grep -q "To set up your Hubzilla" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo "To set up your Hubzilla site go to" >> /home/$MY_USERNAME/README
echo "https://$HUBZILLA_DOMAIN_NAME" >> /home/$MY_USERNAME/README
echo 'You will need to have a non self-signed SSL certificate in order' >> /home/$MY_USERNAME/README
echo "to use Hubzilla. Put the public certificate in /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.crt" >> /home/$MY_USERNAME/README
echo "and the private certificate in /etc/ssl/private/$HUBZILLA_DOMAIN_NAME.key." >> /home/$MY_USERNAME/README
echo 'If there is an intermediate certificate needed (such as with StartSSL) then' >> /home/$MY_USERNAME/README
echo 'this will need to be concatenated onto the end of the crt file, like this:' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo " cat /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.crt /etc/ssl/chains/startssl-sub.class1.server.ca.pem > /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.bundle.crt" >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo "Then change ssl_certificate to /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.bundle.crt" >> /home/$MY_USERNAME/README
echo "within /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME" >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
fi
echo 'install_hubzilla' >> $COMPLETION_FILE
}
function script_for_attaching_usb_drive {
if grep -Fxq "script_for_attaching_usb_drive" $COMPLETION_FILE; then
return
@ -10140,6 +10672,19 @@ function create_upgrade_script {
echo 'git pull' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo "chown -R www-data:www-data /var/www/$REDMATRIX_DOMAIN_NAME/htdocs" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo '# Hubzilla' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo "cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'git stash' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'git stash drop' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'git pull' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo "cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/addon" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'git stash' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'git stash drop' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo 'git pull' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo "chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs" >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
fi
if grep -Fxq "install_gnu_social" $COMPLETION_FILE; then
echo '' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
echo '# GNU Social' >> /etc/cron.weekly/$UPGRADE_SCRIPT_NAME
@ -10714,6 +11259,7 @@ install_wiki
install_blog
install_gnu_social
install_redmatrix
#install_hubzilla
install_dlna_server
configure_firewall_for_dlna
install_mediagoblin