freedombone-app-ghost 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. emacs#!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Ghost blog
  12. # Only works with nodejs version ^6.9.0
  13. #
  14. # License
  15. # =======
  16. #
  17. # Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
  18. #
  19. # This program is free software: you can redistribute it and/or modify
  20. # it under the terms of the GNU Affero General Public License as published by
  21. # the Free Software Foundation, either version 3 of the License, or
  22. # (at your option) any later version.
  23. #
  24. # This program is distributed in the hope that it will be useful,
  25. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. # GNU Affero General Public License for more details.
  28. #
  29. # You should have received a copy of the GNU Affero General Public License
  30. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. VARIANTS="full full-vim writer"
  32. IN_DEFAULT_INSTALL=0
  33. SHOW_ON_ABOUT=1
  34. GHOST_DOMAIN_NAME=
  35. GHOST_CODE=
  36. GHOST_ONION_PORT=8104
  37. GHOST_PORT=2368
  38. ghost_variables=(GHOST_DOMAIN_NAME
  39. GHOST_CODE
  40. GHOST_ADMIN_PASSWORD
  41. ONION_ONLY
  42. DDNS_PROVIDER
  43. MY_USERNAME)
  44. function logging_on_ghost {
  45. echo -n ''
  46. }
  47. function logging_off_ghost {
  48. echo -n ''
  49. }
  50. function ghost_replace_jquery {
  51. curr_domain="https://$GHOST_DOMAIN_NAME"
  52. if [[ "$ONION_ONLY" != 'no' ]]; then
  53. curr_domain="http://$GHOST_ONION_HOSTNAME"
  54. fi
  55. sed -i "s|src=\"https://code.jquery.com/jquery-.*|src=\"$curr_domain/jquery-${jquery_version}.js\"|g" current/content/themes/casper/default.hbs
  56. sed -i "s|src=\"https://code.jquery.com/jquery-.*|src=\"$curr_domain/jquery-${jquery_version}.js\"></script>|g" current/node_modules/gscan/app/tpl/layouts/default.hbs
  57. sed -i "s|http://code.jquery.com/jquery.js|$curr_domain/jquery-${jquery_version}.js|g" current/node_modules/jsdom/README.md
  58. sed -i "s|https://code.jquery.com/jquery.js|$curr_domain/jquery-${jquery_version}.js|g" current/node_modules/jsdom/README.md
  59. cd /var/www/${GHOST_DOMAIN_NAME}/htdocs/current
  60. find ./ -type f -exec sed -i -e 's|https://code.jquery.com|$curr_domain|g' {} \;
  61. find ./ -type f -exec sed -i -e 's|http://code.jquery.com|$curr_domain|g' {} \;
  62. }
  63. function ghost_remove_offsite_links {
  64. curr_domain="$GHOST_DOMAIN_NAME"
  65. if [[ "$ONION_ONLY" != 'no' ]]; then
  66. curr_domain="$GHOST_ONION_HOSTNAME"
  67. fi
  68. # remove google font links
  69. cd /var/www/$GHOST_DOMAIN_NAME/htdocs/current
  70. find ./ -type f -exec sed -i -e 's/fonts.googleapis.com/$curr_domain/g' {} \;
  71. # copy jquery locally
  72. previous_jquery_version='1.12.0'
  73. jquery_version='1.12.4'
  74. if [ ! -f /var/www/$GHOST_DOMAIN_NAME/htdocs/jquery-${jquery_version}.js ]; then
  75. cd /var/www/$GHOST_DOMAIN_NAME/htdocs
  76. wget https://code.jquery.com/jquery-${jquery_version}.js
  77. jquery_hash=$(sha256sum jquery-${jquery_version}.js | awk -F ' ' '{print $1}')
  78. if [[ "$jquery_hash" != '430f36f9b5f21aae8cc9dca6a81c4d3d84da5175eaedcf2fdc2c226302cb3575' ]]; then
  79. echo $'Unexpected jquery hash value'
  80. exit 258442
  81. fi
  82. fi
  83. ghost_replace_jquery
  84. previous_jquery_version='1.11.3'
  85. ghost_replace_jquery
  86. }
  87. function ghost_replace_proprietary_services {
  88. replace_file=$1
  89. sed -i 's|Twitter Profile|GNU Social Profile|g' $replace_file
  90. sed -i 's|Twitter profile|GNU Social Profile|g' $replace_file
  91. sed -i 's|Twitter Username|GNU Social Username|g' $replace_file
  92. sed -i 's|twitter.com|quitter.se|g' $replace_file
  93. sed -i 's|Facebook Page|Hubzilla Channel|g' $replace_file
  94. sed -i 's|Facebook Profile|Hubzilla Channel|g' $replace_file
  95. sed -i 's|Facebook profile|Hubzilla Channel|g' $replace_file
  96. sed -i 's|www.facebook.com/username|hubzilladomain/username|g' $replace_file
  97. sed -i 's|www.facebook.com/ghost|hubzilladomain/username|g' $replace_file
  98. sed -i 's|www.facebook.com/testuser|hubzilladomain/username|g' $replace_file
  99. sed -i 's|www.facebook.com/testing|hubzilladomain/username|g' $replace_file
  100. sed -i 's|www.facebook.com/test|hubzilladomain/username|g' $replace_file
  101. sed -i 's|www.facebook.com/yourUsername|hubzilladomain/username|g' $replace_file
  102. sed -i 's|www.facebook.com/yourPage|hubzilladomain/username|g' $replace_file
  103. sed -i 's|Facebook Username|Hubzilla Channel|g' $replace_file
  104. sed -i 's|www.facebook.com|hubzilladomain|g' $replace_file
  105. sed -i 's|facebook value|hubzilla value|g' $replace_file
  106. sed -i '/<section class="share">/,/<\/section>/d' $replace_file
  107. }
  108. function ghost_replace_services {
  109. ghost_replace_proprietary_services /var/www/${GHOST_DOMAIN_NAME}/htdocs/content/themes/casper/post.hbs
  110. }
  111. function remove_user_ghost {
  112. remove_username="$1"
  113. }
  114. function add_user_ghost {
  115. if [[ $(app_is_installed ghost) == "0" ]]; then
  116. echo '0'
  117. return
  118. fi
  119. new_username="$1"
  120. new_user_password="$2"
  121. echo '0'
  122. }
  123. function install_interactive_ghost {
  124. if [ ! $ONION_ONLY ]; then
  125. ONION_ONLY='no'
  126. fi
  127. if [[ $ONION_ONLY != "no" ]]; then
  128. GHOST_DOMAIN_NAME='ghost.local'
  129. write_config_param "GHOST_DOMAIN_NAME" "$GHOST_DOMAIN_NAME"
  130. else
  131. function_check interactive_site_details
  132. interactive_site_details "ghost" "GHOST_DOMAIN_NAME" "GHOST_CODE"
  133. fi
  134. APP_INSTALLED=1
  135. }
  136. function change_password_ghost {
  137. GHOST_USERNAME="$1"
  138. GHOST_PASSWORD="$2"
  139. if [ ${#GHOST_PASSWORD} -lt 8 ]; then
  140. echo $'Ghost password is too short'
  141. return
  142. fi
  143. #${PROJECT_NAME}-pass -u $GHOST_USERNAME -a ghost -p "$GHOST_PASSWORD"
  144. }
  145. function reconfigure_ghost {
  146. echo -n ''
  147. }
  148. function upgrade_ghost {
  149. if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs ]; then
  150. return
  151. fi
  152. cd /var/www/$GHOST_DOMAIN_NAME/htdocs
  153. npm i -g ghost-cli
  154. /usr/local/bin/ghost update
  155. ghost_replace_services
  156. ghost_remove_offsite_links
  157. chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs
  158. systemctl restart ghost
  159. }
  160. function backup_local_ghost {
  161. GHOST_DOMAIN_NAME='ghost.local'
  162. if grep -q "ghost domain" $COMPLETION_FILE; then
  163. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  164. fi
  165. ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
  166. if [ -d $ghost_path ]; then
  167. suspend_site ${GHOST_DOMAIN_NAME}
  168. systemctl stop ghost
  169. backup_directory_to_usb $ghost_path ghostcontent
  170. systemctl start ghost
  171. restart_site
  172. fi
  173. }
  174. function restore_local_ghost {
  175. GHOST_DOMAIN_NAME='ghost.local'
  176. if grep -q "ghost domain" $COMPLETION_FILE; then
  177. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  178. fi
  179. if [ $GHOST_DOMAIN_NAME ]; then
  180. suspend_site ${GHOST_DOMAIN_NAME}
  181. systemctl stop ghost
  182. temp_restore_dir=/root/tempghostcontent
  183. function_check restore_directory_from_usb
  184. restore_directory_from_usb $temp_restore_dir ghostcontent
  185. if [ -d $temp_restore_dir ]; then
  186. cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
  187. chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
  188. rm -rf $temp_restore_dir
  189. fi
  190. systemctl start ghost
  191. restart_site
  192. fi
  193. }
  194. function backup_remote_ghost {
  195. GHOST_DOMAIN_NAME='ghost.local'
  196. if grep -q "ghost domain" $COMPLETION_FILE; then
  197. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  198. fi
  199. temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
  200. if [ -d $temp_backup_dir ]; then
  201. suspend_site ${GHOST_DOMAIN_NAME}
  202. backup_directory_to_friend $temp_backup_dir ghostcontent
  203. restart_site
  204. else
  205. echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
  206. exit 2578
  207. fi
  208. }
  209. function restore_remote_ghost {
  210. GHOST_DOMAIN_NAME='ghost.local'
  211. if grep -q "ghost domain" $COMPLETION_FILE; then
  212. GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
  213. fi
  214. suspend_site ${GHOST_DOMAIN_NAME}
  215. systemctl stop ghost
  216. temp_restore_dir=/root/tempghostcontent
  217. function_check restore_directory_from_friend
  218. restore_directory_from_friend $temp_restore_dir ghostcontent
  219. if [ -d $temp_restore_dir ]; then
  220. cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
  221. chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
  222. rm -rf $temp_restore_dir
  223. fi
  224. systemctl start ghost
  225. restart_site
  226. }
  227. function remove_ghost {
  228. if [ ${#GHOST_DOMAIN_NAME} -eq 0 ]; then
  229. return
  230. fi
  231. systemctl stop ghost
  232. systemctl disable ghost
  233. rm /etc/systemd/system/ghost.service
  234. systemctl daemon-reload
  235. function_check remove_nodejs
  236. remove_nodejs ghost
  237. read_config_param "GHOST_DOMAIN_NAME"
  238. nginx_dissite $GHOST_DOMAIN_NAME
  239. remove_certs ${GHOST_DOMAIN_NAME}
  240. if [ -f /etc/nginx/sites-available/$GHOST_DOMAIN_NAME ]; then
  241. rm -f /etc/nginx/sites-available/$GHOST_DOMAIN_NAME
  242. fi
  243. if [ -d /var/www/$GHOST_DOMAIN_NAME ]; then
  244. rm -rf /var/www/$GHOST_DOMAIN_NAME
  245. fi
  246. remove_config_param GHOST_DOMAIN_NAME
  247. remove_config_param GHOST_CODE
  248. function_check remove_onion_service
  249. remove_onion_service ghost ${GHOST_ONION_PORT}
  250. remove_completion_param "install_ghost"
  251. sed -i '/Ghost/d' $COMPLETION_FILE
  252. sed -i '/ghost/d' $COMPLETION_FILE
  253. groupdel -f ghost
  254. userdel -r ghost
  255. function_check remove_ddns_domain
  256. remove_ddns_domain $GHOST_DOMAIN_NAME
  257. }
  258. function install_ghost {
  259. if [ ! $ONION_ONLY ]; then
  260. ONION_ONLY='no'
  261. fi
  262. if [ ! $GHOST_DOMAIN_NAME ]; then
  263. echo $'The ghost domain name was not specified'
  264. exit 5062
  265. fi
  266. # for the avatar changing command
  267. apt-get -yq install unzip wget
  268. if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs ]; then
  269. mkdir -p /var/www/$GHOST_DOMAIN_NAME/htdocs
  270. fi
  271. cd /var/www/$GHOST_DOMAIN_NAME/htdocs
  272. function_check install_nodejs
  273. install_nodejs ghost
  274. # Some dependencies of ghost
  275. npm install -g jison@0.4.13 --save
  276. npm install moment-timezone@0.5.13
  277. npm install express@4.15.3
  278. npm install lodash@4.17.4
  279. npm install uuid@3.0.1
  280. npm install bluebird@3.5.0
  281. npm install chalk@1.1.3
  282. npm install intl-messageformat@1.3.0
  283. npm install validator@7.0.0
  284. npm install express-hbs@1.0.4
  285. npm install glob@7.1.2
  286. npm install unidecode@0.1.8
  287. npm install csv-parser@1.11.0
  288. npm install archiver@1.3.0
  289. npm install fs-extra@3.0.1
  290. npm install extract-zip-fork@1.5.1
  291. npm install moment@2.18.1
  292. npm install nodemailer@4.0.1
  293. npm install html-to-text@3.3.0
  294. npm install gscan@1.1.0
  295. npm install body-parser@1.17.2
  296. npm install compression@1.6.2
  297. npm install morgan@1.8.2
  298. npm install semver@5.3.0
  299. npm install path-match@1.2.4
  300. npm install downsize@0.0.8
  301. npm install rss@1.2.2
  302. npm install cheerio@1.0.0-rc.1
  303. npm install passport@0.3.2
  304. npm install xml@1.0.1
  305. npm install multer@1.3.0
  306. npm install oauth2orize@1.8.0
  307. npm install connect-slashes@1.3.1
  308. npm install cors@2.8.3
  309. npm install netjet@1.1.3
  310. npm install jsonpath@0.2.11
  311. npm install image-size@0.5.4
  312. npm install passport-oauth2-client-password@0.1.2
  313. npm install passport-http-bearer@1.0.1
  314. npm install amperize@0.3.4
  315. npm install bcryptjs@2.4.3
  316. npm install knex@0.12.9
  317. npm install bookshelf@0.10.2
  318. npm install cookie-session@1.2.0
  319. npm install ghost-gql@0.0.6
  320. npm install intl@1.2.5
  321. npm install sanitize-html@1.14.1
  322. npm install showdown-ghost@0.3.6
  323. npm install superagent@3.5.2
  324. npm install mysql@2.1.1
  325. npm install mariasql@0.2.6
  326. npm install debug@2.6.8
  327. npm install nconf@0.8.4
  328. npm install -g knex-migrator
  329. knex-migrator init
  330. # now install ghost itself
  331. npm install -g ghost-cli
  332. GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT})
  333. ghost install local --port ${GHOST_PORT}
  334. # kill the started ghost process
  335. kill_pid=$(ps aux | grep "ghost run" | awk -F ' ' '{print $2}' | head -n 1)
  336. kill $kill_pid
  337. # NOTE: this has to be http, not https
  338. sed -i "s|\"url\":|\"url\": \"http://${GHOST_DOMAIN_NAME}/\",|g" /var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json
  339. adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost
  340. echo '[Unit]' > /etc/systemd/system/ghost.service
  341. echo 'Description=Ghost Blog' >> /etc/systemd/system/ghost.service
  342. echo 'After=syslog.target' >> /etc/systemd/system/ghost.service
  343. echo 'After=network.target' >> /etc/systemd/system/ghost.service
  344. echo '' >> /etc/systemd/system/ghost.service
  345. echo '[Service]' >> /etc/systemd/system/ghost.service
  346. echo 'Type=simple' >> /etc/systemd/system/ghost.service
  347. echo 'User=ghost' >> /etc/systemd/system/ghost.service
  348. echo 'Group=ghost' >> /etc/systemd/system/ghost.service
  349. echo "WorkingDirectory=/var/www/${GHOST_DOMAIN_NAME}/htdocs" >> /etc/systemd/system/ghost.service
  350. echo "ExecStart=/usr/local/bin/ghost run -D" >> /etc/systemd/system/ghost.service
  351. echo "ExecStop=/usr/local/bin/ghost stop" >> /etc/systemd/system/ghost.service
  352. echo "ExecRestart=/usr/local/bin/ghost restart" >> /etc/systemd/system/ghost.service
  353. echo 'Restart=always' >> /etc/systemd/system/ghost.service
  354. echo 'RestartSec=60' >> /etc/systemd/system/ghost.service
  355. echo "Environment=NODE_ENV=development PORT=${GHOST_PORT}" >> /etc/systemd/system/ghost.service
  356. echo '' >> /etc/systemd/system/ghost.service
  357. echo '[Install]' >> /etc/systemd/system/ghost.service
  358. echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ghost.service
  359. ghost_remove_offsite_links
  360. chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs
  361. systemctl enable ghost
  362. systemctl daemon-reload
  363. systemctl start ghost
  364. if [[ ${ONION_ONLY} == "no" ]]; then
  365. function_check nginx_http_redirect
  366. nginx_http_redirect ${GHOST_DOMAIN_NAME}
  367. echo 'server {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  368. echo ' listen 443 ssl;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  369. echo ' listen [::]:443 ssl;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  370. echo " root /var/www/${GHOST_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  371. echo " server_name ${GHOST_DOMAIN_NAME};" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  372. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  373. echo " error_log /dev/null;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  374. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  375. function_check nginx_ssl
  376. nginx_ssl ${GHOST_DOMAIN_NAME}
  377. function_check nginx_disable_sniffing
  378. nginx_disable_sniffing ${GHOST_DOMAIN_NAME}
  379. echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  380. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  381. echo ' location / {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  382. function_check nginx_limits
  383. nginx_limits ${GHOST_DOMAIN_NAME} '10G'
  384. echo " proxy_pass http://localhost:${GHOST_PORT};" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  385. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  386. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  387. echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  388. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  389. echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  390. echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  391. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  392. echo ' location = /robots.txt {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  393. echo ' allow all;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  394. echo ' log_not_found off;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  395. echo ' access_log /dev/null;' >> /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. nginx_keybase $GHOST_DOMAIN_NAME
  399. echo '}' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  400. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  401. else
  402. echo -n '' > /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  403. fi
  404. echo 'server {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  405. echo " listen 127.0.0.1:${GHOST_ONION_PORT} default_server;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  406. echo " root /var/www/$GHOST_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  407. echo " server_name $GHOST_ONION_HOSTNAME;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  408. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  409. echo " error_log /dev/null;" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  410. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  411. function_check nginx_disable_sniffing
  412. nginx_disable_sniffing ${GHOST_DOMAIN_NAME}
  413. echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  414. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  415. echo ' location / {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  416. function_check nginx_limits
  417. nginx_limits ${GHOST_DOMAIN_NAME} '10G'
  418. echo " proxy_pass http://localhost:${GHOST_PORT};" >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  419. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  420. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  421. echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  422. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  423. echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  424. echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  425. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  426. echo ' location = /robots.txt {' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  427. echo ' allow all;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  428. echo ' log_not_found off;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  429. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  430. echo ' }' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  431. echo '' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  432. nginx_keybase ${GHOST_DOMAIN_NAME}
  433. echo '}' >> /etc/nginx/sites-available/${GHOST_DOMAIN_NAME}
  434. function_check create_site_certificate
  435. create_site_certificate $GHOST_DOMAIN_NAME 'yes'
  436. ghost_replace_services
  437. function_check nginx_ensite
  438. nginx_ensite $GHOST_DOMAIN_NAME
  439. systemctl restart nginx
  440. ${PROJECT_NAME}-pass -u $MY_USERNAME -a ghost -p "$GHOST_ADMIN_PASSWORD"
  441. function_check add_ddns_domain
  442. add_ddns_domain $GHOST_DOMAIN_NAME
  443. chown -R ghost: /var/www/${GHOST_DOMAIN_NAME}/htdocs
  444. set_completion_param "ghost domain" "$GHOST_DOMAIN_NAME"
  445. if ! grep -q "ghost version:" ${COMPLETION_FILE}; then
  446. echo "ghost version:${GHOST_VERSION}" >> ${COMPLETION_FILE}
  447. else
  448. sed -i "s|ghost version.*|ghost version:${GHOST_VERSION}|g" ${COMPLETION_FILE}
  449. fi
  450. APP_INSTALLED=1
  451. }
  452. # NOTE: deliberately no exit 0