freedombone-app-ghost 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Ghost blog
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. VARIANTS="full full-vim writer"
  31. IN_DEFAULT_INSTALL=0
  32. SHOW_ON_ABOUT=1
  33. GHOST_DOMAIN_NAME=
  34. GHOST_CODE=
  35. GHOST_ONION_PORT=8104
  36. GHOST_VERSION='0.11.3'
  37. GHOST_PORT=2368
  38. ghost_variables=(GHOST_VERSION
  39. GHOST_DOMAIN_NAME
  40. GHOST_CODE
  41. GHOST_ADMIN_PASSWORD
  42. ONION_ONLY
  43. DDNS_PROVIDER
  44. MY_USERNAME)
  45. function ghost_replace_jquery {
  46. sed -i "s|code.jquery.com/jquery-${previous_jquery_version}.min.js|$GHOST_DOMAIN_NAME/jquery-${jquery_version}.js|g" content/themes/casper/default.hbs
  47. sed -i "s|code.jquery.com/jquery-${previous_jquery_version}.min.js|$GHOST_DOMAIN_NAME/jquery-${jquery_version}.js|g" core/server/data/migration/fixtures/004/01-move-jquery-with-alert.js
  48. sed -i "s|code.jquery.com/jquery-${previous_jquery_version}.min.js|$GHOST_DOMAIN_NAME/jquery-${jquery_version}.js|g" node_modules/gscan/app/tpl/layouts/default.hbs
  49. }
  50. function ghost_remove_offsite_links {
  51. cd /var/www/$GHOST_DOMAIN_NAME/htdocs
  52. # remove google font links
  53. # Note that the privacy options in config.js aren't sufficient to remove Google's tentacles
  54. sed -i "s/fonts.googleapis.com/$GHOST_DOMAIN_NAME/g" content/themes/casper/default.hbs
  55. sed -i "s/fonts.googleapis.com/$GHOST_DOMAIN_NAME/g" core/server/apps/amp/lib/views/amp.hbs
  56. # copy jquery locally
  57. previous_jquery_version='1.12.0'
  58. jquery_version='1.12.4'
  59. if [ ! -f /var/www/$GHOST_DOMAIN_NAME/htdocs/jquery-${jquery_version}.js ]; then
  60. wget https://code.jquery.com/jquery-${jquery_version}.js
  61. jquery_hash=$(sha256sum jquery-${jquery_version}.js | awk -F ' ' '{print $1}')
  62. if [[ "$jquery_hash" != '430f36f9b5f21aae8cc9dca6a81c4d3d84da5175eaedcf2fdc2c226302cb3575' ]]; then
  63. echo $'Unexpected jquery hash value'
  64. exit 258442
  65. fi
  66. fi
  67. ghost_replace_jquery
  68. previous_jquery_version='1.11.3'
  69. ghost_replace_jquery
  70. }
  71. function ghost_replace_proprietary_services {
  72. replace_file=$1
  73. sed -i 's|Twitter Profile|GNU Social Profile|g' $replace_file
  74. sed -i 's|Twitter Username|GNU Social Username|g' $replace_file
  75. sed -i 's|twitter.com|quitter.se|g' $replace_file
  76. sed -i 's|Facebook Page|Hubzilla Channel|g' $replace_file
  77. sed -i 's|www.facebook.com/username|hubzilladomain/username|g' $replace_file
  78. sed -i 's|www.facebook.com/ghost|hubzilladomain/username|g' $replace_file
  79. sed -i 's|www.facebook.com/testuser|hubzilladomain/username|g' $replace_file
  80. sed -i 's|www.facebook.com/testing|hubzilladomain/username|g' $replace_file
  81. sed -i 's|www.facebook.com/test|hubzilladomain/username|g' $replace_file
  82. sed -i 's|www.facebook.com/yourUsername|hubzilladomain/username|g' $replace_file
  83. sed -i 's|www.facebook.com/yourPage|hubzilladomain/username|g' $replace_file
  84. sed -i 's|Facebook Username|Hubzilla Channel|g' $replace_file
  85. sed -i 's|www.facebook.com|hubzilladomain|g' $replace_file
  86. sed -i 's|facebook value|hubzilla value|g' $replace_file
  87. sed -i '/<section class="share">/,/<\/section>/d' $replace_file
  88. }
  89. function ghost_replace_services {
  90. ghost_replace_proprietary_services /var/www/${GHOST_DOMAIN_NAME}/htdocs/core/built/assets/ghost.js
  91. ghost_replace_proprietary_services /var/www/${GHOST_DOMAIN_NAME}/htdocs/core/built/assets/ghost.min.js
  92. ghost_replace_proprietary_services /var/www/${GHOST_DOMAIN_NAME}/htdocs/content/themes/casper/post.hbs
  93. }
  94. function remove_user_ghost {
  95. remove_username="$1"
  96. }
  97. function add_user_ghost {
  98. if [[ $(app_is_installed ghost) == "0" ]]; then
  99. echo '0'
  100. return
  101. fi
  102. new_username="$1"
  103. new_user_password="$2"
  104. echo '0'
  105. }
  106. function install_interactive_ghost {
  107. if [ ! $ONION_ONLY ]; then
  108. ONION_ONLY='no'
  109. fi
  110. if [[ $ONION_ONLY != "no" ]]; then
  111. GHOST_DOMAIN_NAME='ghost.local'
  112. write_config_param "GHOST_DOMAIN_NAME" "$GHOST_DOMAIN_NAME"
  113. else
  114. function_check interactive_site_details
  115. interactive_site_details "ghost" "GHOST_DOMAIN_NAME" "GHOST_CODE"
  116. fi
  117. APP_INSTALLED=1
  118. }
  119. function change_password_ghost {
  120. GHOST_USERNAME="$1"
  121. GHOST_PASSWORD="$2"
  122. if [ ${#GHOST_PASSWORD} -lt 8 ]; then
  123. echo $'Ghost password is too short'
  124. return
  125. fi
  126. #${PROJECT_NAME}-pass -u $GHOST_USERNAME -a ghost -p "$GHOST_PASSWORD"
  127. }
  128. function reconfigure_ghost {
  129. echo -n ''
  130. }
  131. function upgrade_ghost {
  132. read_config_param "GHOST_DOMAIN_NAME"
  133. GHOST_PATH=/var/www/$GHOST_DOMAIN_NAME/htdocs
  134. function_check set_repo_commit
  135. set_repo_commit $GHOST_PATH "ghost commit" "$GHOST_COMMIT" $GHOST_REPO
  136. ghost_replace_services
  137. chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs
  138. ghost_remove_offsite_links
  139. systemctl restart ghost
  140. }
  141. function backup_local_ghost {
  142. GHOST_DOMAIN_NAME='ghost.local'
  143. if grep -q "ghost domain" $COMPLETION_FILE; then
  144. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  145. fi
  146. ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs
  147. if [ -d $ghost_path ]; then
  148. function_check backup_database_to_usb
  149. backup_database_to_usb ghost
  150. backup_directory_to_usb $ghost_path ghost
  151. restart_site
  152. fi
  153. }
  154. function restore_local_ghost {
  155. GHOST_DOMAIN_NAME='ghost.local'
  156. if grep -q "ghost domain" $COMPLETION_FILE; then
  157. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  158. fi
  159. if [ $GHOST_DOMAIN_NAME ]; then
  160. function_check ghost_create_database
  161. ghost_create_database
  162. function_check restore_database
  163. restore_database ghost ${GHOST_DOMAIN_NAME}
  164. fi
  165. }
  166. function backup_remote_ghost {
  167. GHOST_DOMAIN_NAME='ghost.local'
  168. if grep -q "ghost domain" $COMPLETION_FILE; then
  169. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  170. fi
  171. temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs
  172. if [ -d $temp_backup_dir ]; then
  173. suspend_site ${GHOST_DOMAIN_NAME}
  174. backup_database_to_friend ghost
  175. backup_directory_to_friend $temp_backup_dir ghost
  176. restart_site
  177. else
  178. echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
  179. exit 2578
  180. fi
  181. }
  182. function restore_remote_ghost {
  183. GHOST_DOMAIN_NAME='ghost.local'
  184. if grep -q "ghost domain" $COMPLETION_FILE; then
  185. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  186. fi
  187. function_check restore_database_from_friend
  188. function_check ghost_create_database
  189. ghost_create_database
  190. restore_database_from_friend ghost ${GHOST_DOMAIN_NAME}
  191. restart_site
  192. chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs/
  193. }
  194. function remove_ghost {
  195. if [ ${#GHOST_DOMAIN_NAME} -eq 0 ]; then
  196. return
  197. fi
  198. systemctl stop ghost
  199. systemctl disable ghost
  200. rm /etc/systemd/system/ghost.service
  201. function_check remove_nodejs
  202. remove_nodejs ghost
  203. drop_database ghost
  204. remove_backup_database_local ghost
  205. read_config_param "GHOST_DOMAIN_NAME"
  206. nginx_dissite $GHOST_DOMAIN_NAME
  207. remove_certs ${GHOST_DOMAIN_NAME}
  208. deluser --remove-all-files ghost
  209. if [ -f /etc/nginx/sites-available/$GHOST_DOMAIN_NAME ]; then
  210. rm -f /etc/nginx/sites-available/$GHOST_DOMAIN_NAME
  211. fi
  212. if [ -d /var/www/$GHOST_DOMAIN_NAME ]; then
  213. rm -rf /var/www/$GHOST_DOMAIN_NAME
  214. fi
  215. remove_config_param GHOST_DOMAIN_NAME
  216. remove_config_param GHOST_CODE
  217. function_check remove_onion_service
  218. remove_onion_service ghost ${GHOST_ONION_PORT}
  219. remove_completion_param "install_ghost"
  220. sed -i '/Ghost/d' $COMPLETION_FILE
  221. sed -i '/ghost/d' $COMPLETION_FILE
  222. function_check remove_ddns_domain
  223. remove_ddns_domain $GHOST_DOMAIN_NAME
  224. }
  225. function ghost_create_config {
  226. ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
  227. echo "var path = require('path')," > $ghost_config
  228. echo ' config;' >> $ghost_config
  229. echo '' >> $ghost_config
  230. echo 'config = {' >> $ghost_config
  231. echo ' production: {' >> $ghost_config
  232. echo ' // This needs to be http and NOT https' >> $ghost_config
  233. echo " url: 'http://${GHOST_DOMAIN_NAME}'," >> $ghost_config
  234. echo ' mail: {' >> $ghost_config
  235. echo " transport: 'SMTP'," >> $ghost_config
  236. echo ' options: {' >> $ghost_config
  237. echo " service: 'Sendmail'," >> $ghost_config
  238. echo ' }' >> $ghost_config
  239. echo ' },' >> $ghost_config
  240. echo ' database: {' >> $ghost_config
  241. echo " client: 'mysql'," >> $ghost_config
  242. echo ' connection: {' >> $ghost_config
  243. echo " host : '127.0.0.1'," >> $ghost_config
  244. echo " user : 'root'," >> $ghost_config
  245. echo " password : '${MARIADB_PASSWORD}'," >> $ghost_config
  246. echo " database : 'ghost'," >> $ghost_config
  247. echo " charset : 'utf8'" >> $ghost_config
  248. echo ' }' >> $ghost_config
  249. echo ' },' >> $ghost_config
  250. echo '' >> $ghost_config
  251. echo ' server: {' >> $ghost_config
  252. echo " host: '127.0.0.1'," >> $ghost_config
  253. echo " port: '${GHOST_PORT}'" >> $ghost_config
  254. echo ' },' >> $ghost_config
  255. echo ' privacy: {' >> $ghost_config
  256. echo ' useTinfoil: true,' >> $ghost_config
  257. echo ' },' >> $ghost_config
  258. echo ' logging: false' >> $ghost_config
  259. echo ' }' >> $ghost_config
  260. echo '};' >> $ghost_config
  261. echo '' >> $ghost_config
  262. echo 'module.exports = config;' >> $ghost_config
  263. chmod 700 $ghost_config
  264. }
  265. function ghost_create_database {
  266. if [ -f ${IMAGE_PASSWORD_FILE} ]; then
  267. GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
  268. else
  269. if [ ! ${GIT_ADMIN_PASSWORD} ]; then
  270. GIT_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
  271. fi
  272. fi
  273. if [ ! $GIT_ADMIN_PASSWORD ]; then
  274. return
  275. fi
  276. function_check create_database
  277. create_database ghost "$GHOST_ADMIN_PASSWORD"
  278. }
  279. function install_ghost {
  280. if [ ! $ONION_ONLY ]; then
  281. ONION_ONLY='no'
  282. fi
  283. if [ ! $GHOST_DOMAIN_NAME ]; then
  284. echo $'The ghost domain name was not specified'
  285. exit 5062
  286. fi
  287. # for the avatar changing command
  288. apt-get -yq install unzip wget
  289. if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs ]; then
  290. mkdir -p /var/www/$GHOST_DOMAIN_NAME/htdocs
  291. fi
  292. cd /var/www/$GHOST_DOMAIN_NAME/htdocs
  293. wget https://ghost.org/zip/ghost-${GHOST_VERSION}.zip
  294. if [ ! -f ghost-${GHOST_VERSION}.zip ]; then
  295. echo $'Unable to download ghost'
  296. rm -rf /var/www/$GHOST_DOMAIN_NAME
  297. exit 63892
  298. fi
  299. unzip ghost-${GHOST_VERSION}.zip
  300. if [ ! -f /var/www/${GHOST_DOMAIN_NAME}/htdocs/index.js ]; then
  301. echo $'ghost failed to unzip'
  302. rm -rf /var/www/$GHOST_DOMAIN_NAME
  303. exit 63835
  304. fi
  305. function_check install_nodejs
  306. install_nodejs ghost
  307. sed -i "/sqlite/d" /var/www/${GHOST_DOMAIN_NAME}/htdocs/package.json
  308. npm install --production
  309. function_check install_mariadb
  310. install_mariadb
  311. function_check get_mariadb_password
  312. get_mariadb_password
  313. function_check ghost_create_database
  314. ghost_create_database
  315. ghost_create_config
  316. adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost
  317. chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs/
  318. echo '[Unit]' > /etc/systemd/system/ghost.service
  319. echo 'Description=Ghost Blog' >> /etc/systemd/system/ghost.service
  320. echo 'After=syslog.target' >> /etc/systemd/system/ghost.service
  321. echo 'After=network.target' >> /etc/systemd/system/ghost.service
  322. echo 'After=mysqld.service' >> /etc/systemd/system/ghost.service
  323. echo '' >> /etc/systemd/system/ghost.service
  324. echo '[Service]' >> /etc/systemd/system/ghost.service
  325. echo 'Type=simple' >> /etc/systemd/system/ghost.service
  326. echo 'User=ghost' >> /etc/systemd/system/ghost.service
  327. echo 'Group=ghost' >> /etc/systemd/system/ghost.service
  328. echo "WorkingDirectory=/var/www/${GHOST_DOMAIN_NAME}/htdocs" >> /etc/systemd/system/ghost.service
  329. echo "ExecStart=/usr/local/bin/node /var/www/${GHOST_DOMAIN_NAME}/htdocs/index.js" >> /etc/systemd/system/ghost.service
  330. echo 'Restart=always' >> /etc/systemd/system/ghost.service
  331. echo 'RestartSec=60' >> /etc/systemd/system/ghost.service
  332. echo "Environment=NODE_ENV=production PORT=${GHOST_PORT}" >> /etc/systemd/system/ghost.service
  333. echo '' >> /etc/systemd/system/ghost.service
  334. echo '[Install]' >> /etc/systemd/system/ghost.service
  335. echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ghost.service
  336. ghost_remove_offsite_links
  337. systemctl enable ghost
  338. systemctl daemon-reload
  339. systemctl start ghost
  340. GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT})
  341. if [[ ${ONION_ONLY} == "no" ]]; then
  342. function_check nginx_http_redirect
  343. nginx_http_redirect ${GHOST_DOMAIN_NAME}
  344. echo 'server {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  345. echo ' listen 443 ssl;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  346. echo ' listen [::]:443 ssl;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  347. echo " root /var/www/${GHOST_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  348. echo " server_name ${GHOST_DOMAIN_NAME};" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  349. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  350. echo " error_log /dev/null;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  351. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  352. function_check nginx_ssl
  353. nginx_ssl ${GHOST_DOMAIN_NAME}
  354. function_check nginx_disable_sniffing
  355. nginx_disable_sniffing ${GHOST_DOMAIN_NAME}
  356. echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  357. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  358. echo ' location / {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  359. function_check nginx_limits
  360. nginx_limits ${GHOST_DOMAIN_NAME} '10G'
  361. echo " proxy_pass http://localhost:${GHOST_PORT};" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  362. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  363. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  364. echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  365. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  366. echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  367. echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  368. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  369. echo ' location = /robots.txt {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  370. echo ' allow all;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  371. echo ' log_not_found off;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  372. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  373. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  374. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  375. nginx_keybase $GHOST_DOMAIN_NAME
  376. echo '}' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  377. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  378. else
  379. echo -n '' > /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  380. fi
  381. echo 'server {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  382. echo " listen 127.0.0.1:${GHOST_ONION_PORT} default_server;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  383. echo " root /var/www/$GHOST_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  384. echo " server_name $GHOST_ONION_HOSTNAME;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  385. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  386. echo " error_log /dev/null;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  387. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  388. function_check nginx_disable_sniffing
  389. nginx_disable_sniffing ${GHOST_DOMAIN_NAME}
  390. echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  391. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  392. echo ' location / {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  393. function_check nginx_limits
  394. nginx_limits ${GHOST_DOMAIN_NAME} '10G'
  395. echo " proxy_pass http://localhost:${GHOST_PORT};" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  396. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  397. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  398. echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  399. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  400. echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  401. echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  402. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  403. echo ' location = /robots.txt {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  404. echo ' allow all;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  405. echo ' log_not_found off;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  406. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  407. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  408. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  409. nginx_keybase ${GHOST_DOMAIN_NAME}
  410. echo '}' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  411. function_check create_site_certificate
  412. create_site_certificate $GHOST_DOMAIN_NAME 'yes'
  413. function_check configure_php
  414. configure_php
  415. if [[ $ONION_ONLY != 'no' ]]; then
  416. sed -i "s|url: .*|url: 'http://${GHOST_ONION_HOSTNAME}',|g" /var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
  417. systemctl restart ghost
  418. fi
  419. ghost_replace_services
  420. function_check nginx_ensite
  421. nginx_ensite $GHOST_DOMAIN_NAME
  422. systemctl restart nginx
  423. ${PROJECT_NAME}-pass -u $MY_USERNAME -a ghost -p "$GHOST_ADMIN_PASSWORD"
  424. function_check add_ddns_domain
  425. add_ddns_domain $GHOST_DOMAIN_NAME
  426. set_completion_param "ghost domain" "$GHOST_DOMAIN_NAME"
  427. APP_INSTALLED=1
  428. }
  429. # NOTE: deliberately no exit 0