#!/bin/bash # # .---. . . # | | | # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-' # ' ' --' --' -' - -' ' ' -' -' -' ' - --' # # Freedom in the Cloud # # Ghost blog # Only works with nodejs version ^6.9.0 # # License # ======= # # Copyright (C) 2016-2017 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 # 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 . VARIANTS="full full-vim writer" IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 GHOST_VERSION=1.6.2 GHOST_DOMAIN_NAME= GHOST_CODE= GHOST_ONION_PORT=8104 GHOST_PORT=2368 ghost_variables=(GHOST_DOMAIN_NAME GHOST_CODE GHOST_ADMIN_PASSWORD ONION_ONLY DDNS_PROVIDER MY_USERNAME) function ghost_bust { # kill the started ghost process kill_pid=$(ps aux | grep "ghost run" | awk -F ' ' '{print $2}' | head -n 1) kill -9 $kill_pid kill_pid=$(ps aux | grep "ghost" | awk -F ' ' '{print $2}' | head -n 1) kill -9 $kill_pid kill_pid=$(ps aux | grep "ghost" | awk -F ' ' '{print $2}' | head -n 1) kill -9 $kill_pid } function logging_on_ghost { echo -n '' } function logging_off_ghost { echo -n '' } function ghost_replace_jquery { curr_domain="https://$GHOST_DOMAIN_NAME" if [[ "$ONION_ONLY" != 'no' ]]; then curr_domain="http://$GHOST_ONION_HOSTNAME" fi sed -i "s|src=\"https://code.jquery.com/jquery-.*|src=\"$curr_domain/jquery-${jquery_version}.js\"|g" current/content/themes/casper/default.hbs sed -i "s|src=\"https://code.jquery.com/jquery-.*|src=\"$curr_domain/jquery-${jquery_version}.js\">|g" current/node_modules/gscan/app/tpl/layouts/default.hbs sed -i "s|http://code.jquery.com/jquery.js|$curr_domain/jquery-${jquery_version}.js|g" current/node_modules/jsdom/README.md sed -i "s|https://code.jquery.com/jquery.js|$curr_domain/jquery-${jquery_version}.js|g" current/node_modules/jsdom/README.md cd /var/www/${GHOST_DOMAIN_NAME}/htdocs/current find ./ -type f -exec sed -i -e 's|https://code.jquery.com|$curr_domain|g' {} \; find ./ -type f -exec sed -i -e 's|http://code.jquery.com|$curr_domain|g' {} \; } function ghost_rss_button { # remove feedly -aaargh! sed -i 's|http://cloud.feedly.com/#subscription/feed/{{@blog.url}}/rss/|{{@blog.url}}/rss/|g' /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/themes/casper/partials/site-nav.hbs sed -i 's|http://cloud.feedly.com/#subscription/feed/{{url absolute="true"}}/rss/|{{url absolute="true"}}rss/|g' /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/themes/casper/author.hbs } function ghost_remove_offsite_links { curr_domain="$GHOST_DOMAIN_NAME" if [[ "$ONION_ONLY" != 'no' ]]; then curr_domain="$GHOST_ONION_HOSTNAME" fi ghost_rss_button # remove google font links cd /var/www/$GHOST_DOMAIN_NAME/htdocs/current find ./ -type f -exec sed -i -e 's/fonts.googleapis.com/$curr_domain/g' {} \; # copy jquery locally previous_jquery_version='1.12.0' jquery_version='1.12.4' if [ ! -f /var/www/$GHOST_DOMAIN_NAME/htdocs/jquery-${jquery_version}.js ]; then cd /var/www/$GHOST_DOMAIN_NAME/htdocs wget https://code.jquery.com/jquery-${jquery_version}.js jquery_hash=$(sha256sum jquery-${jquery_version}.js | awk -F ' ' '{print $1}') if [[ "$jquery_hash" != '430f36f9b5f21aae8cc9dca6a81c4d3d84da5175eaedcf2fdc2c226302cb3575' ]]; then echo $'Unexpected jquery hash value' exit 258442 fi fi ghost_replace_jquery previous_jquery_version='1.11.3' ghost_replace_jquery } function ghost_replace_proprietary_services { replace_file=$1 sed -i 's|Twitter Profile|GNU Social Profile|g' $replace_file sed -i 's|Twitter profile|GNU Social Profile|g' $replace_file sed -i 's|Twitter Username|GNU Social Username|g' $replace_file sed -i 's|twitter.com|quitter.se|g' $replace_file sed -i 's|Facebook Page|Hubzilla Channel|g' $replace_file sed -i 's|Facebook Profile|Hubzilla Channel|g' $replace_file sed -i 's|Facebook profile|Hubzilla Channel|g' $replace_file sed -i 's|www.facebook.com/username|hubzilladomain/username|g' $replace_file sed -i 's|www.facebook.com/ghost|hubzilladomain/username|g' $replace_file sed -i 's|www.facebook.com/testuser|hubzilladomain/username|g' $replace_file sed -i 's|www.facebook.com/testing|hubzilladomain/username|g' $replace_file sed -i 's|www.facebook.com/test|hubzilladomain/username|g' $replace_file sed -i 's|www.facebook.com/yourUsername|hubzilladomain/username|g' $replace_file sed -i 's|www.facebook.com/yourPage|hubzilladomain/username|g' $replace_file sed -i 's|Facebook Username|Hubzilla Channel|g' $replace_file sed -i 's|www.facebook.com|hubzilladomain|g' $replace_file sed -i 's|facebook value|hubzilla value|g' $replace_file sed -i '/