This commit is contained in:
Bob Mottram 2016-02-23 16:09:02 +00:00
parent 3fb9e6c4b9
commit 18d5f0971e
1 changed files with 57 additions and 55 deletions

View File

@ -8992,9 +8992,11 @@ function install_hubzilla {
# return
#fi
HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
# update to a new commit if needed
set_repo_commit /var/www/$HUBZILLA_DOMAIN_NAME/htdocs "Hubzilla commit" "$HUBZILLA_COMMIT" $HUBZILLA_REPO
set_repo_commit /var/www/$HUBZILLA_DOMAIN_NAME/htdocs "Hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT" $HUBZILLA_ADDONS_REPO
set_repo_commit $HUBZILLA_PATH "Hubzilla commit" "$HUBZILLA_COMMIT" $HUBZILLA_REPO
set_repo_commit $HUBZILLA_PATH "Hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT" $HUBZILLA_ADDONS_REPO
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
return
@ -9010,11 +9012,11 @@ function install_hubzilla {
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
if [ ! -d $HUBZILLA_PATH ]; then
mkdir $HUBZILLA_PATH
fi
if [ ! -f /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/index.php ]; then
if [ ! -f $HUBZILLA_PATH/index.php ]; then
cd $INSTALL_DIR
git_clone $HUBZILLA_REPO hubzilla
git checkout $HUBZILLA_COMMIT -b $HUBZILLA_COMMIT
@ -9024,11 +9026,11 @@ function install_hubzilla {
sed -i "s/Hubzilla commit.*/Hubzilla commit:$HUBZILLA_COMMIT/g" $COMPLETION_FILE
fi
rm -rf /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
mv hubzilla /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
rm -rf $HUBZILLA_PATH
mv hubzilla $HUBZILLA_PATH
git_clone $HUBZILLA_ADDONS_REPO /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/addon
cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/addon
git_clone $HUBZILLA_ADDONS_REPO $HUBZILLA_PATH/addon
cd $HUBZILLA_PATH/addon
git checkout $HUBZILLA_ADDONS_COMMIT -b $HUBZILLA_ADDONS_COMMIT
if ! grep -q "Hubzilla addons commit" $COMPLETION_FILE; then
echo "Hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT" >> $COMPLETION_FILE
@ -9037,10 +9039,10 @@ function install_hubzilla {
fi
# some extra themes
git_clone $HUBZILLA_THEMES_REPO /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/redmatrix-themes1
cp -r /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/redmatrix-themes1/* view/theme/
git_clone $HUBZILLA_THEMES_REPO $HUBZILLA_PATH/redmatrix-themes1
cp -r $HUBZILLA_PATH/redmatrix-themes1/* view/theme/
chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
chown -R www-data:www-data $HUBZILLA_PATH
fi
get_mariadb_hubzilla_admin_password
@ -9061,8 +9063,8 @@ function install_hubzilla {
create_database hubzilla "$HUBZILLA_ADMIN_PASSWORD"
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 500 /usr/bin/php include/poller.php" >> /etc/crontab
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
# update the dynamic DNS
@ -9073,7 +9075,7 @@ function install_hubzilla {
nginx_http_redirect $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 " root $HUBZILLA_PATH;" >> /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
@ -9145,7 +9147,7 @@ function install_hubzilla {
else
echo 'server {' > /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " listen 127.0.0.1:${HUBZILLA_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " root /var/www/$HUBZILLA_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME
echo " root $HUBZILLA_PATH;" >> /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
@ -9223,22 +9225,22 @@ function install_hubzilla {
fi
fi
if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/view/tpl/smarty3 ]; then
mkdir /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/view/tpl/smarty3
if [ ! -d $HUBZILLA_PATH/view/tpl/smarty3 ]; then
mkdir $HUBZILLA_PATH/view/tpl/smarty3
fi
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store" ]; then
mkdir "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store"
if [ ! -d "$HUBZILLA_PATH/store" ]; then
mkdir "$HUBZILLA_PATH/store"
fi
if [ ! -d "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]" ]; then
mkdir "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]"
if [ ! -d "$HUBZILLA_PATH/store/[data]" ]; then
mkdir "$HUBZILLA_PATH/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"
if [ ! -d "$HUBZILLA_PATH/store/[data]/smarty3" ]; then
mkdir "$HUBZILLA_PATH/store/[data]/smarty3"
chmod 777 "$HUBZILLA_PATH/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
chmod 777 $HUBZILLA_PATH/view/tpl
chown -R www-data:www-data "$HUBZILLA_PATH/store"
chmod 777 $HUBZILLA_PATH/view/tpl/smarty3
# Ensure that the database gets backed up locally, if remote
# backups are not being used
@ -9246,7 +9248,7 @@ function install_hubzilla {
backup_database_local hubzilla
chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
chown -R www-data:www-data $HUBZILLA_PATH
nginx_ensite $HUBZILLA_DOMAIN_NAME
@ -9263,41 +9265,41 @@ function install_hubzilla {
fi
# initialize the database
if [ ! -f /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/install/schema_mysql.sql ]; then
if [ ! -f $HUBZILLA_PATH/install/schema_mysql.sql ]; then
echo $'No database schema found for hubzilla'
exit 252782
fi
mysql -u root --password="$MARIADB_PASSWORD" -D hubzilla < /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/install/schema_mysql.sql
mysql -u root --password="$MARIADB_PASSWORD" -D hubzilla < $HUBZILLA_PATH/install/schema_mysql.sql
# create the config file
echo '<?php' > /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$db_host = 'localhost';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$db_port = '0';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$db_user = 'hubzillaadmin';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$db_pass = '${HUBZILLA_ADMIN_PASSWORD}';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$db_data = 'hubzilla';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$db_type = '0';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$default_timezone = 'Europe/London';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo '<?php' > $HUBZILLA_PATH/.htconfig.php
echo "\$db_host = 'localhost';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$db_port = '0';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$db_user = 'hubzillaadmin';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$db_pass = '${HUBZILLA_ADMIN_PASSWORD}';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$db_data = 'hubzilla';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$db_type = '0';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$default_timezone = 'Europe/London';" >> $HUBZILLA_PATH/.htconfig.php
if [[ $ONION_ONLY == 'no' ]]; then
echo "\$a->config['system']['baseurl'] = 'https://${HUBZILLA_DOMAIN_NAME}';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['baseurl'] = 'https://${HUBZILLA_DOMAIN_NAME}';" >> $HUBZILLA_PATH/.htconfig.php
else
echo "\$a->config['system']['baseurl'] = 'http://${HUBZILLA_ONION_HOSTNAME}';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['baseurl'] = 'http://${HUBZILLA_ONION_HOSTNAME}';" >> $HUBZILLA_PATH/.htconfig.php
fi
echo "\$a->config['system']['sitename'] = \"Hubzilla\";" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['sitename'] = \"Hubzilla\";" >> $HUBZILLA_PATH/.htconfig.php
HUBZILLA_LOCATION_HASH="$(openssl rand -base64 32)"
echo "\$a->config['system']['location_hash'] = '${HUBZILLA_LOCATION_HASH}';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['register_policy'] = REGISTER_OPEN;" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['register_text'] = '';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['admin_email'] = '${MY_EMAIL_ADDRESS}';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['verify_email'] = 1;" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['access_policy'] = ACCESS_PRIVATE;" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['sellpage'] = '';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['max_import_size'] = 200000;" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['php_path'] = '/usr/bin/php';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['theme'] = 'redbasic';" >> /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
chown www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
chmod +x /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/.htconfig.php
echo "\$a->config['system']['location_hash'] = '${HUBZILLA_LOCATION_HASH}';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['register_policy'] = REGISTER_OPEN;" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['register_text'] = '';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['admin_email'] = '${MY_EMAIL_ADDRESS}';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['verify_email'] = 1;" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['access_policy'] = ACCESS_PRIVATE;" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['sellpage'] = '';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['max_import_size'] = 200000;" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['php_path'] = '/usr/bin/php';" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;" >> $HUBZILLA_PATH/.htconfig.php
echo "\$a->config['system']['theme'] = 'redbasic';" >> $HUBZILLA_PATH/.htconfig.php
chown www-data:www-data $HUBZILLA_PATH/.htconfig.php
chmod +x $HUBZILLA_PATH/.htconfig.php
systemctl restart php5-fpm
systemctl restart nginx