From a6e2b5495066416adb90dc61fda58c3ac1700664 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 7 Jan 2018 14:47:43 +0000 Subject: [PATCH 1/4] Placeholder web user interface --- src/freedombone-utils-setup | 3 +++ src/freedombone-utils-web | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index 51a1ca74..44d0c42d 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -1076,6 +1076,9 @@ function setup_web { function_check install_web_server_access_control install_web_server_access_control + + function_check install_web_local_user_interface + install_web_local_user_interface } function upgrade_apps { diff --git a/src/freedombone-utils-web b/src/freedombone-utils-web index b4a1d461..3095a30b 100755 --- a/src/freedombone-utils-web +++ b/src/freedombone-utils-web @@ -1070,4 +1070,29 @@ function email_install_tls { fi } +function install_web_local_user_interface { + # TODO + # This is intended as a placeholder for a potential local web user interface + # similar to Plinth or the yunohost admin interface + local_hostname=$(cat /etc/avahi/avahi-daemon.conf | grep 'host-name' | awk -F '=' '{print $2}').local + + mkdir -p /var/www/${local_hostname}/htdocs + echo '' > /var/www/${local_hostname}/htdocs/index.html + echo ' ' >> /var/www/${local_hostname}/htdocs/index.html + echo " This is a test on $local_hostname" >> /var/www/${local_hostname}/htdocs/index.html + echo ' ' >> /var/www/${local_hostname}/htdocs/index.html + echo '' >> /var/www/${local_hostname}/htdocs/index.html + chown -R www-data:www-data /var/www/${local_hostname}/htdocs + + nginx_file=/etc/nginx/sites-available/$local_hostname + echo 'server {' > $nginx_file + echo ' listen 80;' >> $nginx_file + echo ' listen [::]:80;' >> $nginx_file + echo " server_name ${local_hostname};" >> $nginx_file + echo " root /var/www/${local_hostname}/htdocs;" >> $nginx_file + echo ' index index.html;' >> $nginx_file + echo '}' >> $nginx_file + nginx_ensite $local_hostname +} + # NOTE: deliberately no exit 0 From ce85662f90a212ee8c02d5ac1d14382ff491a06d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 7 Jan 2018 21:49:36 +0000 Subject: [PATCH 2/4] Change how ghost is installed and limit to 1Gb+ RAM --- src/freedombone-app-ghost | 80 +++++++++------------------------------ 1 file changed, 17 insertions(+), 63 deletions(-) diff --git a/src/freedombone-app-ghost b/src/freedombone-app-ghost index e055a6fa..a5d1f9c8 100755 --- a/src/freedombone-app-ghost +++ b/src/freedombone-app-ghost @@ -14,7 +14,7 @@ # License # ======= # -# Copyright (C) 2016-2017 Bob Mottram +# Copyright (C) 2016-2018 Bob Mottram # # 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 @@ -347,6 +347,8 @@ function remove_ghost { } function install_ghost { + check_ram_availability 900 + if [ ! $ONION_ONLY ]; then ONION_ONLY='no' fi @@ -367,78 +369,26 @@ function install_ghost { function_check install_nodejs install_nodejs ghost - # Some dependencies of ghost - npm install -g jison@0.4.13 --save - npm install moment-timezone@0.5.13 - npm install express@4.15.3 - npm install lodash@4.17.4 - npm install uuid@3.0.1 - npm install bluebird@3.5.0 - npm install chalk@1.1.3 - npm install intl-messageformat@1.3.0 - npm install validator@7.0.0 - npm install express-hbs@1.0.4 - npm install glob@7.1.2 - npm install unidecode@0.1.8 - npm install csv-parser@1.11.0 - npm install archiver@1.3.0 - npm install fs-extra@3.0.1 - npm install extract-zip-fork@1.5.1 - npm install moment@2.18.1 - npm install nodemailer@4.0.1 - npm install html-to-text@3.3.0 - npm install gscan@1.1.0 - npm install body-parser@1.17.2 - npm install compression@1.6.2 - npm install morgan@1.8.2 - npm install semver@5.3.0 - npm install path-match@1.2.4 - npm install downsize@0.0.8 - npm install rss@1.2.2 - npm install cheerio@1.0.0-rc.1 - npm install passport@0.3.2 - npm install xml@1.0.1 - npm install multer@1.3.0 - npm install oauth2orize@1.8.0 - npm install connect-slashes@1.3.1 - npm install cors@2.8.3 - npm install netjet@1.1.3 - npm install jsonpath@0.2.11 - npm install image-size@0.5.4 - npm install passport-oauth2-client-password@0.1.2 - npm install passport-http-bearer@1.0.1 - npm install amperize@0.3.4 - npm install bcryptjs@2.4.3 - npm install knex@0.12.9 - npm install bookshelf@0.10.2 - npm install cookie-session@1.2.0 - npm install ghost-gql@0.0.6 - npm install intl@1.2.5 - npm install sanitize-html@1.14.1 - npm install showdown-ghost@0.3.6 - npm install superagent@3.5.2 - npm install mysql@2.1.1 - npm install mariasql@0.2.6 - npm install debug@2.6.8 - npm install nconf@0.8.4 - - npm install -g knex-migrator - knex-migrator init - # now install ghost itself - npm install -g ghost-cli + npm install -g ghost-cli@1.4.1 GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT}) - ghost install local --port ${GHOST_PORT} + rm -rf /var/www/$GHOST_DOMAIN_NAME/htdocs/* + npm install -g yarn + yarn install --no-emoji --no-progress + yarn cache clean + printf 'y' | ghost install ${GHOST_VERSION} --user ghost --db=sqlite3 --port ${GHOST_PORT} --verbose + adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost + + npm install -g knex-migrator + knex-migrator init ghost_bust # NOTE: this has to be http, not https sed -i "s|\"url\":|\"url\": \"http://${GHOST_DOMAIN_NAME}/\",|g" /var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json - adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost - echo '[Unit]' > /etc/systemd/system/ghost.service echo 'Description=Ghost Blog' >> /etc/systemd/system/ghost.service echo 'After=syslog.target' >> /etc/systemd/system/ghost.service @@ -463,6 +413,9 @@ function install_ghost { chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs + n ${NODEJS_VERSION} + npm upgrade -g npm@${NPM_VERSION} --save + systemctl enable ghost systemctl daemon-reload systemctl start ghost @@ -562,6 +515,7 @@ function install_ghost { else sed -i "s|ghost version.*|ghost version:${GHOST_VERSION}|g" ${COMPLETION_FILE} fi + APP_INSTALLED=1 } From c1ed8a474771bac486194f458d2b5399ac289122 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 8 Jan 2018 12:50:13 +0000 Subject: [PATCH 3/4] Check that ghost cli gets installed --- src/freedombone-app-ghost | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/freedombone-app-ghost b/src/freedombone-app-ghost index a5d1f9c8..86071c9e 100755 --- a/src/freedombone-app-ghost +++ b/src/freedombone-app-ghost @@ -319,6 +319,8 @@ function remove_ghost { rm /etc/systemd/system/ghost.service systemctl daemon-reload + npm uninstall -g ghost-cli + function_check remove_nodejs remove_nodejs ghost @@ -371,6 +373,10 @@ function install_ghost { # now install ghost itself npm install -g ghost-cli@1.4.1 + if [ ! -f /usr/local/bin/ghost ]; then + echo $'ghost was not installed' + exit 738539 + fi GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT}) From 61341e106af1c136246fb00555e54750be86d525 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 8 Jan 2018 17:09:05 +0000 Subject: [PATCH 4/4] Improving ghost install --- src/freedombone-app-ghost | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/freedombone-app-ghost b/src/freedombone-app-ghost index 86071c9e..8248d5a8 100755 --- a/src/freedombone-app-ghost +++ b/src/freedombone-app-ghost @@ -372,7 +372,7 @@ function install_ghost { install_nodejs ghost # now install ghost itself - npm install -g ghost-cli@1.4.1 + npm install -g ghost-cli@latest if [ ! -f /usr/local/bin/ghost ]; then echo $'ghost was not installed' exit 738539 @@ -380,14 +380,30 @@ function install_ghost { GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT}) - rm -rf /var/www/$GHOST_DOMAIN_NAME/htdocs/* npm install -g yarn yarn install --no-emoji --no-progress yarn cache clean - printf 'y' | ghost install ${GHOST_VERSION} --user ghost --db=sqlite3 --port ${GHOST_PORT} --verbose adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost + rm -rf /var/www/$GHOST_DOMAIN_NAME/htdocs/* + printf 'y' | ghost install ${GHOST_VERSION} --user ghost --db=sqlite3 --port ${GHOST_PORT} --verbose + + if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs/versions ]; then + echo $'versions directory was not found' + exit 782523462 + fi + if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then + echo $'content directory was not found' + exit 68352682 + fi npm install -g knex-migrator + if [ ! -f /var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/MigratorConfig.js ]; then + echo $'MigratorConfig.js was not found' + exit 62783538 + fi + cp /var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/MigratorConfig.js /var/www/$GHOST_DOMAIN_NAME/htdocs + chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs + cd /var/www/$GHOST_DOMAIN_NAME/htdocs/current knex-migrator init ghost_bust @@ -419,9 +435,6 @@ function install_ghost { chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs - n ${NODEJS_VERSION} - npm upgrade -g npm@${NPM_VERSION} --save - systemctl enable ghost systemctl daemon-reload systemctl start ghost