freedombone-app-pelican 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Pelican static blog
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2017 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. PELICAN_DOMAIN_NAME=
  34. PELICAN_BLOG_CODE=
  35. PELICAN_ONION_PORT=8113
  36. PELICAN_THEMES_REPO="https://github.com/getpelican/pelican-themes"
  37. PELICAN_PLUGINS_REPO="https://github.com/getpelican/pelican-plugins"
  38. DEFAULT_BLOG_TITLE=$"Freedombone Blog"
  39. PELICAN_BLOG_INSTALL_DIR=/etc/blog
  40. PELICAN_CURRENT_BLOG_INDEX=$PELICAN_BLOG_INSTALL_DIR/.blog-index
  41. pelican_variables=(MY_USERNAME
  42. ONION_ONLY
  43. PELICAN_DOMAIN_NAME
  44. PELICAN_BLOG_CODE)
  45. function pelican_remove_bad_blog_links {
  46. find ./ -type f -name *.css -exec sed -i -e '/googleapi/d' {} \;
  47. find ./ -type f -name *.scss -exec sed -i -e '/googleapi/d' {} \;
  48. find ./ -type f -name *.html -exec sed -i -e '/googleapi/d' {} \;
  49. find ./ -type f -name *.css -exec sed -i -e '/bootstrapcdn/d' {} \;
  50. find ./ -type f -name *.scss -exec sed -i -e '/bootstrapcdn/d' {} \;
  51. find ./ -type f -name *.html -exec sed -i -e '/bootstrapcdn/d' {} \;
  52. }
  53. function logging_on_pelican {
  54. echo -n ''
  55. }
  56. function logging_off_pelican {
  57. echo -n ''
  58. }
  59. function install_pelican_website {
  60. if [[ $ONION_ONLY != 'no' ]]; then
  61. echo -n '' > /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  62. return
  63. fi
  64. function_check nginx_http_redirect
  65. nginx_http_redirect $PELICAN_DOMAIN_NAME
  66. echo 'server {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  67. echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  68. echo ' listen [::]:443 ssl;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  69. echo " root /var/www/${PELICAN_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  70. echo " server_name ${PELICAN_DOMAIN_NAME};" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  71. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  72. echo " error_log /dev/null;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  73. echo ' index index.html;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  74. echo ' charset utf-8;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  75. function_check nginx_ssl
  76. nginx_ssl $PELICAN_DOMAIN_NAME
  77. function_check nginx_disable_sniffing
  78. nginx_disable_sniffing $PELICAN_DOMAIN_NAME
  79. echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  80. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  81. echo ' location / {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  82. function_check nginx_limits
  83. nginx_limits $PELICAN_DOMAIN_NAME
  84. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  85. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  86. echo ' # block these file types' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  87. echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  88. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  89. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  90. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  91. echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  92. echo ' location ~ /\. {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  93. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  94. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  95. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  96. echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  97. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  98. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  99. echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  100. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  101. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  102. echo '}' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  103. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  104. function_check create_site_certificate
  105. create_site_certificate $PELICAN_DOMAIN_NAME 'yes'
  106. }
  107. function install_pelican_website_onion {
  108. echo 'server {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  109. echo " listen 127.0.0.1:${PELICAN_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  110. echo " root /var/www/${PELICAN_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  111. echo " server_name ${PELICAN_DOMAIN_NAME};" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  112. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  113. echo " error_log /dev/null;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  114. echo ' index index.html;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  115. echo ' charset utf-8;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  116. function_check nginx_disable_sniffing
  117. nginx_disable_sniffing $PELICAN_DOMAIN_NAME
  118. echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  119. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  120. echo ' location / {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  121. function_check nginx_limits
  122. nginx_limits $PELICAN_DOMAIN_NAME
  123. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  124. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  125. echo ' # block these file types' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  126. echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  127. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  128. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  129. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  130. echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  131. echo ' location ~ /\. {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  132. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  133. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  134. echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  135. echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  136. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  137. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  138. echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  139. echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  140. echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  141. echo '}' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  142. }
  143. function pelican_editor_config {
  144. if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican ]; then
  145. echo "(add-hook 'before-save-hook 'delete-trailing-whitespace)" > $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  146. echo '(setq org-support-shift-select t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  147. echo '(setq standard-indent 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  148. echo '(setq-default tab-width 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  149. echo '(setq c-basic-offset 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  150. echo '(mouse-wheel-mode t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  151. echo '(setq make-backup-files t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  152. echo '(setq version-control t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  153. echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  154. echo "(setq default-major-mode 'text-mode)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  155. echo "(dolist (hook '(text-mode-hook))" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  156. echo ' (add-hook hook (lambda () (flyspell-mode 1))))' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  157. echo '(setq-default fill-column 72)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  158. echo '(setq auto-fill-mode 0)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  159. echo "(add-hook 'text-mode-hook 'turn-on-auto-fill)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  160. echo "(setq-default auto-fill-function 'do-auto-fill)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
  161. fi
  162. }
  163. function pelican_regenerate_blog {
  164. clear
  165. echo ''
  166. echo $'Regenerating blog...'
  167. cd $PELICAN_BLOG_INSTALL_DIR
  168. make html
  169. cp -r $PELICAN_BLOG_INSTALL_DIR/output/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
  170. chown -R www-data:www-data /var/www/$PELICAN_DOMAIN_NAME/htdocs
  171. }
  172. function pelican_new_blog {
  173. DATESTR=$(date "+%Y-%m-%d %H:%M:%S")
  174. if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry ]; then
  175. echo $'Title: Blog Post Title' > $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  176. echo $"Date: ${DATESTR}" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  177. echo $"Author: $(toxid --showuser)" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  178. echo $'Category: default' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  179. echo $'Tags: blog, tag' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  180. echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  181. echo $'Add your text here' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  182. echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  183. echo -n $'To include an image copy it into the /etc/blog/content/images directory, ' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  184. echo $'then link to it with:' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  185. echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  186. echo $'![My image]({filename}images/myimage.jpg)' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  187. echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  188. fi
  189. if [ -f /usr/bin/emacs ]; then
  190. emacs -q --load $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  191. else
  192. editor $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
  193. fi
  194. if grep -q $"Add your text here" $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry; then
  195. return
  196. fi
  197. if grep -q $"Blog Post Title" $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry; then
  198. return
  199. fi
  200. if [ ! -f $PELICAN_CURRENT_BLOG_INDEX ]; then
  201. echo '0' > $PELICAN_CURRENT_BLOG_INDEX
  202. fi
  203. # move to the content directory
  204. CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
  205. mv $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry $BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.md
  206. # increment the index
  207. CURRENT_INDEX=$((CURRENT_INDEX + 1))
  208. echo "$CURRENT_INDEX" > $PELICAN_CURRENT_BLOG_INDEX
  209. pelican_regenerate_blog
  210. }
  211. function pelican_edit_blog {
  212. if [ ! -f $PELICAN_CURRENT_BLOG_INDEX ]; then
  213. return
  214. fi
  215. CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
  216. PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
  217. LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
  218. if [ ! -f $LAST_BLOG_ENTRY ]; then
  219. return
  220. fi
  221. if [ -f /usr/bin/emacs ]; then
  222. emacs -q --load $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican $LAST_BLOG_ENTRY
  223. else
  224. editor $LAST_BLOG_ENTRY
  225. fi
  226. pelican_regenerate_blog
  227. }
  228. function pelican_delete_blog {
  229. if [ ! -f $PELICAN_CURRENT_BLOG_INDEX ]; then
  230. return
  231. fi
  232. CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
  233. PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
  234. LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
  235. if [ ! -f $LAST_BLOG_ENTRY ]; then
  236. return
  237. fi
  238. dialog --title $"Delete the previous blog entry" \
  239. --backtitle $"Freedombone Mesh" \
  240. --defaultno \
  241. --yesno $"\nAre you sure that you wish to delete the previous blog entry?" 8 60
  242. sel=$?
  243. case $sel in
  244. 0) rm $LAST_BLOG_ENTRY
  245. if [ $CURRENT_INDEX -gt 0 ]; then
  246. CURRENT_INDEX=$PREVIOUS_INDEX
  247. echo "$CURRENT_INDEX" > $PELICAN_CURRENT_BLOG_INDEX
  248. else
  249. rm -f $PELICAN_CURRENT_BLOG_INDEX
  250. fi
  251. pelican_regenerate_blog
  252. ;;
  253. esac
  254. }
  255. function pelican_change_theme {
  256. THEMES=()
  257. for d in $PELICAN_BLOG_INSTALL_DIR/themes/*/ ; do
  258. THEME_NAME=$(echo "$d" | awk -F '/' '{print $6}')
  259. THEMES+=("$THEME_NAME")
  260. done
  261. themelist=""
  262. n=1
  263. theme_index=0
  264. curr_theme_index=
  265. if [ -f $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index ]; then
  266. curr_theme_index=$(cat $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index)
  267. fi
  268. for a in "${THEMES[@]}"
  269. do
  270. is_selected='off'
  271. if [ $curr_theme_index ]; then
  272. if [ $n -eq $curr_theme_index ]; then
  273. is_selected='on'
  274. fi
  275. else
  276. if [[ "$a" == 'nice-blog' ]]; then
  277. is_selected='on'
  278. fi
  279. fi
  280. themelist="$themelist $n $a $is_selected"
  281. n=$[n+1]
  282. theme_index=$[theme_index+1]
  283. done
  284. data=$(tempfile 2>/dev/null)
  285. trap "rm -f $data" 0 1 2 5 15
  286. dialog --backtitle $"Freedombone Mesh" \
  287. --title $"Select Blog Theme" \
  288. --radiolist $'Choose:' \
  289. 80 40 20 $themelist 2> $data
  290. sel=$?
  291. case $sel in
  292. 1) return;;
  293. 255) return;;
  294. esac
  295. CHOSEN_THEME_INDEX=$(cat $data)
  296. echo "$CHOSEN_THEME_INDEX" > $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index
  297. CHOSEN_THEME_INDEX=$((CHOSEN_THEME_INDEX - 1))
  298. CHOSEN_THEME=${THEMES[$CHOSEN_THEME_INDEX]}
  299. cd $PELICAN_BLOG_INSTALL_DIR/themes/$CHOSEN_THEME
  300. pelican_remove_bad_blog_links
  301. if grep -q "THEME=" $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py; then
  302. sed -i "s|THEME=.*|THEME='themes/${CHOSEN_THEME}'|g" $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
  303. else
  304. echo "THEME='themes/${CHOSEN_THEME}'" >> $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
  305. fi
  306. pelican_regenerate_blog
  307. }
  308. function configure_interactive_pelican {
  309. data=$(tempfile 2>/dev/null)
  310. trap "rm -f $data" 0 1 2 5 15
  311. dialog --backtitle $"Freedombone Configuration" \
  312. --title $"Pelican Blogging" \
  313. --radiolist $"Choose an operation:" 18 50 11 \
  314. 1 $"New blog entry" off \
  315. 2 $"Edit the previous blog entry" off \
  316. 3 $"Delete the previous blog entry" off \
  317. 4 $"Change theme" off \
  318. 5 $"Exit" off 2> $data
  319. sel=$?
  320. case $sel in
  321. 1) return;;
  322. 255) return;;
  323. esac
  324. case $(cat $data) in
  325. 1) pelican_new_blog;;
  326. 2) pelican_edit_blog;;
  327. 3) pelican_delete_blog;;
  328. 4) pelican_change_theme;;
  329. 5) break;;
  330. esac
  331. }
  332. function install_interactive_pelican {
  333. if [ ! $ONION_ONLY ]; then
  334. ONION_ONLY='no'
  335. fi
  336. if [[ $ONION_ONLY != "no" ]]; then
  337. PELICAN_DOMAIN_NAME='pelican.local'
  338. else
  339. PELICAN_DETAILS_COMPLETE=
  340. while [ ! $PELICAN_DETAILS_COMPLETE ]
  341. do
  342. data=$(tempfile 2>/dev/null)
  343. trap "rm -f $data" 0 1 2 5 15
  344. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  345. dialog --backtitle $"Freedombone Configuration" \
  346. --title $"Pelican Blog Configuration" \
  347. --form $"\nPlease enter your blog details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
  348. $"Domain:" 1 1 "$(grep 'PELICAN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  349. $"Code:" 2 1 "$(grep 'PELICAN_BLOG_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
  350. 2> $data
  351. else
  352. dialog --backtitle $"Freedombone Configuration" \
  353. --title $"Pelican Blog Configuration" \
  354. --form $"\nPlease enter your GNU Social details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
  355. $"Domain:" 1 1 "$(grep 'PELICAN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
  356. 2> $data
  357. fi
  358. sel=$?
  359. case $sel in
  360. 1) exit 1;;
  361. 255) exit 1;;
  362. esac
  363. PELICAN_DOMAIN_NAME=$(cat $data | sed -n 1p)
  364. if [ $PELICAN_DOMAIN_NAME ]; then
  365. if [[ $PELICAN_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
  366. PELICAN_DOMAIN_NAME=""
  367. fi
  368. TEST_DOMAIN_NAME=$PELICAN_DOMAIN_NAME
  369. validate_domain_name
  370. if [[ $TEST_DOMAIN_NAME != $PELICAN_DOMAIN_NAME ]]; then
  371. PELICAN_DOMAIN_NAME=
  372. dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
  373. else
  374. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  375. PELICAN_BLOG_CODE=$(cat $data | sed -n 2p)
  376. validate_freedns_code "$PELICAN_BLOG_CODE"
  377. if [ ! $VALID_CODE ]; then
  378. PELICAN_DOMAIN_NAME=
  379. fi
  380. fi
  381. fi
  382. fi
  383. if [ $PELICAN_DOMAIN_NAME ]; then
  384. PELICAN_DETAILS_COMPLETE="yes"
  385. fi
  386. done
  387. # save the results in the config file
  388. write_config_param "PELICAN_BLOG_CODE" "$PELICAN_BLOG_CODE"
  389. fi
  390. write_config_param "PELICAN_DOMAIN_NAME" "$PELICAN_DOMAIN_NAME"
  391. APP_INSTALLED=1
  392. }
  393. function reconfigure_pelican {
  394. echo -n ''
  395. }
  396. function upgrade_pelican {
  397. echo -n ''
  398. }
  399. function backup_local_pelican {
  400. source_directory=/etc/blog
  401. if [ -d $source_directory ]; then
  402. dest_directory=pelican
  403. function_check backup_directory_to_usb
  404. backup_directory_to_usb $source_directory $dest_directory
  405. fi
  406. source_directory=/var/www/$PELICAN_DOMAIN_NAME/htdocs
  407. if [ -d $source_directory ]; then
  408. dest_directory=pelican-site
  409. function_check backup_directory_to_usb
  410. backup_directory_to_usb $source_directory $dest_directory
  411. fi
  412. }
  413. function restore_local_pelican {
  414. if [ -d /etc/blog ]; then
  415. if [ -d $USB_MOUNT_DLNA/backup/pelican ]; then
  416. temp_restore_dir=/root/temppelican
  417. function_check restore_directory_from_usb
  418. restore_directory_from_usb $temp_restore_dir pelican
  419. if [ -d $temp_restore_dir/etc/blog ]; then
  420. cp -r $temp_restore_dir/etc/blog/* /etc/blog/
  421. else
  422. cp -r $temp_restore_dir/* /etc/blog/
  423. fi
  424. if [ ! "$?" = "0" ]; then
  425. rm -rf $temp_restore_dir
  426. function_check set_user_permissions
  427. set_user_permissions
  428. function_check backup_unmount_drive
  429. backup_unmount_drive
  430. exit 527942
  431. fi
  432. rm -rf $temp_restore_dir
  433. fi
  434. fi
  435. if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
  436. if [ -d $USB_MOUNT_DLNA/backup/pelican-site ]; then
  437. temp_restore_dir=/root/temppelican-site
  438. function_check restore_directory_from_usb
  439. restore_directory_from_usb $temp_restore_dir pelican-site
  440. if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
  441. cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
  442. else
  443. cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
  444. fi
  445. if [ ! "$?" = "0" ]; then
  446. rm -rf $temp_restore_dir
  447. function_check set_user_permissions
  448. set_user_permissions
  449. function_check backup_unmount_drive
  450. backup_unmount_drive
  451. exit 2946282
  452. fi
  453. rm -rf $temp_restore_dir
  454. fi
  455. fi
  456. }
  457. function backup_remote_pelican {
  458. if [ -d /etc/blog ]; then
  459. backup_directory_to_friend /etc/blog pelican
  460. fi
  461. if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
  462. backup_directory_to_friend /var/www/$PELICAN_DOMAIN_NAME/htdocs pelican-site
  463. fi
  464. }
  465. function restore_remote_pelican {
  466. if [ -d /etc/blog ]; then
  467. if [ -d $SERVER_DIRECTORY/backup/pelican ]; then
  468. temp_restore_dir=/root/temppelican
  469. function_check restore_directory_from_friend
  470. restore_directory_from_friend $temp_restore_dir pelican
  471. if [ -d $temp_restore_dir/etc/blog ]; then
  472. cp -r $temp_restore_dir/etc/blog/* /etc/blog/
  473. else
  474. cp -r $temp_restore_dir/* /etc/blog/
  475. fi
  476. if [ ! "$?" = "0" ]; then
  477. exit 782352
  478. fi
  479. rm -rf $temp_restore_dir
  480. fi
  481. fi
  482. if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
  483. if [ -d $SERVER_DIRECTORY/backup/pelican-site ]; then
  484. temp_restore_dir=/root/temppelican-site
  485. function_check restore_directory_from_friend
  486. restore_directory_from_friend $temp_restore_dir pelican-site
  487. if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
  488. cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
  489. else
  490. cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
  491. fi
  492. if [ ! "$?" = "0" ]; then
  493. exit 76382562
  494. fi
  495. rm -rf $temp_restore_dir
  496. fi
  497. fi
  498. }
  499. function remove_pelican {
  500. if [ -f /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME ]; then
  501. nginx_dissite pelican
  502. rm /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
  503. if [ -d /var/www/$PELICAN_DOMAIN_NAME ]; then
  504. rm -rf /var/www/$PELICAN_DOMAIN_NAME
  505. fi
  506. systemctl reload nginx
  507. fi
  508. pip uninstall pelican
  509. remove_certs $PELICAN_DOMAIN_NAME
  510. function_check remove_onion_service
  511. remove_onion_service pelican ${PELICAN_ONION_PORT}
  512. remove_app pelican
  513. systemctl restart tor
  514. }
  515. function create_pelican_conf {
  516. STATIC_BLOG_FILE=$1
  517. echo '#!/usr/bin/env python' > $STATIC_BLOG_FILE
  518. echo '# -*- coding: utf-8 -*- #' >> $STATIC_BLOG_FILE
  519. echo 'from __future__ import unicode_literals' >> $STATIC_BLOG_FILE
  520. echo '' >> $STATIC_BLOG_FILE
  521. echo "AUTHOR=u\"$MY_USERNAME\"" >> $STATIC_BLOG_FILE
  522. echo "SITENAME=u'$DEFAULT_BLOG_TITLE'" >> $STATIC_BLOG_FILE
  523. echo "SITEURL=''" >> $STATIC_BLOG_FILE
  524. echo "PATH='content'" >> $STATIC_BLOG_FILE
  525. echo 'TIMEZONE=u"Europe/London"' >> $STATIC_BLOG_FILE
  526. echo "DEFAULT_LANG=u'en'" >> $STATIC_BLOG_FILE
  527. echo '' >> $STATIC_BLOG_FILE
  528. echo 'FEED_ALL_ATOM=None' >> $STATIC_BLOG_FILE
  529. echo 'CATEGORY_FEED_ATOM=None' >> $STATIC_BLOG_FILE
  530. echo 'TRANSLATION_FEED_ATOM=None' >> $STATIC_BLOG_FILE
  531. echo 'AUTHOR_FEED_ATOM=None' >> $STATIC_BLOG_FILE
  532. echo 'AUTHOR_FEED_RSS=None' >> $STATIC_BLOG_FILE
  533. echo '' >> $STATIC_BLOG_FILE
  534. echo 'DEFAULT_PAGINATION=False' >> $STATIC_BLOG_FILE
  535. echo 'RELATIVE_URLS=True' >> $STATIC_BLOG_FILE
  536. echo "THEME='themes/nice-blog'" >> $STATIC_BLOG_FILE
  537. }
  538. function create_pelican_makefile {
  539. STATIC_BLOG_FILE=$1
  540. echo 'PY?=python' > $STATIC_BLOG_FILE
  541. echo 'PELICAN?=pelican' >> $STATIC_BLOG_FILE
  542. echo 'PELICANOPTS=' >> $STATIC_BLOG_FILE
  543. echo '' >> $STATIC_BLOG_FILE
  544. echo 'BASEDIR=$(CURDIR)' >> $STATIC_BLOG_FILE
  545. echo 'INPUTDIR=$(BASEDIR)/content' >> $STATIC_BLOG_FILE
  546. echo "OUTPUTDIR=$PELICAN_BLOG_PATH" >> $STATIC_BLOG_FILE
  547. echo 'CONFFILE=$(BASEDIR)/pelicanconf.py' >> $STATIC_BLOG_FILE
  548. echo 'PUBLISHCONF=$(BASEDIR)/publishconf.py' >> $STATIC_BLOG_FILE
  549. echo '' >> $STATIC_BLOG_FILE
  550. echo 'DEBUG ?= 0' >> $STATIC_BLOG_FILE
  551. echo 'ifeq ($(DEBUG), 1)' >> $STATIC_BLOG_FILE
  552. echo -e '\tPELICANOPTS += -D' >> $STATIC_BLOG_FILE
  553. echo 'endif' >> $STATIC_BLOG_FILE
  554. echo '' >> $STATIC_BLOG_FILE
  555. echo 'RELATIVE ?= 0' >> $STATIC_BLOG_FILE
  556. echo 'ifeq ($(RELATIVE), 1)' >> $STATIC_BLOG_FILE
  557. echo -e '\tPELICANOPTS += --relative-urls' >> $STATIC_BLOG_FILE
  558. echo 'endif' >> $STATIC_BLOG_FILE
  559. echo '' >> $STATIC_BLOG_FILE
  560. echo 'html:' >> $STATIC_BLOG_FILE
  561. echo -e '\t$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)' >> $STATIC_BLOG_FILE
  562. echo '' >> $STATIC_BLOG_FILE
  563. echo 'clean:' >> $STATIC_BLOG_FILE
  564. echo -e '\t[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)' >> $STATIC_BLOG_FILE
  565. echo '' >> $STATIC_BLOG_FILE
  566. echo 'regenerate:' >> $STATIC_BLOG_FILE
  567. echo -e '\t$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)' >> $STATIC_BLOG_FILE
  568. echo '' >> $STATIC_BLOG_FILE
  569. echo 'serve:' >> $STATIC_BLOG_FILE
  570. echo 'ifdef PORT' >> $STATIC_BLOG_FILE
  571. echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)' >> $STATIC_BLOG_FILE
  572. echo 'else' >> $STATIC_BLOG_FILE
  573. echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server' >> $STATIC_BLOG_FILE
  574. echo 'endif' >> $STATIC_BLOG_FILE
  575. echo '' >> $STATIC_BLOG_FILE
  576. echo 'serve-global:' >> $STATIC_BLOG_FILE
  577. echo 'ifdef SERVER' >> $STATIC_BLOG_FILE
  578. echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER)' >> $STATIC_BLOG_FILE
  579. echo 'else' >> $STATIC_BLOG_FILE
  580. echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0' >> $STATIC_BLOG_FILE
  581. echo 'endif' >> $STATIC_BLOG_FILE
  582. echo '' >> $STATIC_BLOG_FILE
  583. echo 'devserver:' >> $STATIC_BLOG_FILE
  584. echo 'ifdef PORT' >> $STATIC_BLOG_FILE
  585. echo -e '\t$(BASEDIR)/develop_server.sh restart $(PORT)' >> $STATIC_BLOG_FILE
  586. echo 'else' >> $STATIC_BLOG_FILE
  587. echo -e '\t$(BASEDIR)/develop_server.sh restart' >> $STATIC_BLOG_FILE
  588. echo 'endif' >> $STATIC_BLOG_FILE
  589. echo '' >> $STATIC_BLOG_FILE
  590. echo 'stopserver:' >> $STATIC_BLOG_FILE
  591. echo -e '\t$(BASEDIR)/develop_server.sh stop' >> $STATIC_BLOG_FILE
  592. echo -e '\t@echo "Stopped Pelican and SimpleHTTPServer processes running in background."' >> $STATIC_BLOG_FILE
  593. echo '' >> $STATIC_BLOG_FILE
  594. echo 'publish:' >> $STATIC_BLOG_FILE
  595. echo -e '\t$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)' >> $STATIC_BLOG_FILE
  596. echo '' >> $STATIC_BLOG_FILE
  597. echo '.PHONY: html clean regenerate serve serve-global devserver publish' >> $STATIC_BLOG_FILE
  598. }
  599. function create_pelican_publish_conf {
  600. STATIC_BLOG_FILE=$1
  601. echo '#!/usr/bin/env python' > $STATIC_BLOG_FILE
  602. echo '# -*- coding: utf-8 -*- #' >> $STATIC_BLOG_FILE
  603. echo 'from __future__ import unicode_literals' >> $STATIC_BLOG_FILE
  604. echo '' >> $STATIC_BLOG_FILE
  605. echo 'import os' >> $STATIC_BLOG_FILE
  606. echo 'import sys' >> $STATIC_BLOG_FILE
  607. echo 'sys.path.append(os.curdir)' >> $STATIC_BLOG_FILE
  608. echo 'from pelicanconf import *' >> $STATIC_BLOG_FILE
  609. echo '' >> $STATIC_BLOG_FILE
  610. echo "SITEURL = ''" >> $STATIC_BLOG_FILE
  611. echo 'RELATIVE_URLS = True' >> $STATIC_BLOG_FILE
  612. echo '' >> $STATIC_BLOG_FILE
  613. echo "FEED_ALL_ATOM = 'feeds/all.atom.xml'" >> $STATIC_BLOG_FILE
  614. echo "CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'" >> $STATIC_BLOG_FILE
  615. echo '' >> $STATIC_BLOG_FILE
  616. echo 'DELETE_OUTPUT_DIRECTORY = True' >> $STATIC_BLOG_FILE
  617. }
  618. function pelican_themes {
  619. # Clone themes separately because the themes repo sometimes has bad refs
  620. git clone https://github.com/KenMercusLai/BT3-Flat
  621. git clone https://github.com/abr4xas/Casper2Pelican
  622. git clone https://github.com/alexandrevicenzi/Flex
  623. git clone https://github.com/allenskd/Nuja
  624. git clone https://github.com/ir193/Responsive-Pelican
  625. git clone https://github.com/nairobilug/pelican-alchemy
  626. git clone https://github.com/livibetter-backup/apricot
  627. git clone https://github.com/jody-frankowski/blue-penguin
  628. git clone https://github.com/gregseth/pelican-bgh
  629. git clone https://github.com/blueicefield/pelican-blueidea
  630. git clone https://github.com/demianbrecht/pelican-bold
  631. git clone https://github.com/fly/burrito
  632. git clone https://github.com/yuex/pelican-iliork
  633. git clone https://github.com/tbunnyman/pelican-chunk
  634. git clone https://github.com/hdra/Pelican-Cid
  635. git clone https://github.com/gilsondev/pelican-clean-blog
  636. git clone https://github.com/porterjamesj/crowsfoot
  637. git clone https://github.com/22decembre/dev-random3.git
  638. git clone https://github.com/kura/eevee
  639. git clone https://github.com/talha131/pelican-elegant.git
  640. git clone https://github.com/callmefish/pelican-free-agent
  641. git clone https://github.com/jsliang/pelican-fresh
  642. git clone https://github.com/vaiski/genus
  643. git clone https://github.com/PierrePaul/html5-dopetrope
  644. git clone https://github.com/jvanz/pelican-hyde
  645. git clone https://github.com/erfaan/pelican-theme-irfan
  646. git clone https://github.com/slok/iris
  647. git clone https://github.com/badele/pelican-theme-jesuislibre
  648. git clone https://github.com/mothsART/pelican-lab
  649. git clone https://github.com/siovene/lannisport
  650. git clone https://github.com/lazycoder-ru/lazystrap
  651. git clone https://github.com/chdoig/pelican-bootstrap3-lovers
  652. git clone https://github.com/kplaube/maggner-pelican
  653. git clone https://github.com/cpaulik/martin-pelican
  654. git clone https://github.com/greizgh/pelican-material
  655. git clone https://github.com/eswarm/materialistic-pelican
  656. git clone https://github.com/cprieto/pelican-mediumfox
  657. git clone https://github.com/onuraslan/medius
  658. git clone https://github.com/lucachr/pelican-mg
  659. git clone https://github.com/BYK/pelican-neat
  660. git clone https://github.com/molivier/nest
  661. git clone https://github.com/guilherme-toti/nice-blog
  662. git clone https://github.com/gunchu/nikhil-theme
  663. git clone https://github.com/wilbur-ma/niu-x2
  664. git clone https://github.com/duilio/pelican-octopress-theme
  665. git clone https://github.com/Parbhat/pelican-blue
  666. git clone https://github.com/hdra/pelican-cait
  667. git clone https://github.com/laughk/pelican-hss
  668. git clone https://github.com/wrl/pelican-mockingbird
  669. git clone https://github.com/fle/pelican-simplegrey
  670. git clone https://github.com/fle/pelican-sober
  671. git clone https://github.com/ingwinlu/pelican-twitchy
  672. git clone https://github.com/badele/pelicanthemes-generator
  673. git clone https://github.com/jjimenezlopez/pelipress
  674. git clone https://github.com/xm3ron/pjport
  675. git clone https://github.com/kdeldycke/plumage
  676. git clone https://github.com/habibillah/pujangga
  677. git clone https://github.com/danclaudiupop/pure
  678. git clone https://github.com/wamonite/relapse
  679. git clone https://github.com/ellisonleao/pelican-semantic-ui
  680. git clone https://github.com/kdheepak89/pelican-smoothie
  681. git clone https://github.com/if1live/pelican-sora
  682. git clone https://github.com/redVi/storm
  683. git clone https://github.com/keningle/pelican-sundown
  684. git clone https://github.com/giulivo/pelican-svbhack
  685. git clone https://github.com/wting/pelican-svbtle
  686. git clone https://github.com/frankV/twenty-pelican-html5up
  687. git clone https://github.com/robulouski/voidy-bootstrap
  688. git clone https://github.com/samael500/w3-personal-blog
  689. git clone https://github.com/jarv/water-iris
  690. git clone https://github.com/kplaube/yapeme
  691. pelican_remove_bad_blog_links
  692. }
  693. function mesh_install_pelican {
  694. if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" && $VARIANT != "usb" ]]; then
  695. return
  696. fi
  697. chroot "$rootdir" apt-get -yq install python-pip
  698. chroot "$rootdir" pip install ipython
  699. chroot "$rootdir" pip install Markdown
  700. chroot "$rootdir" pip install typogrify
  701. chroot "$rootdir" pip install pelican
  702. PELICAN_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
  703. PELICAN_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
  704. if [ ! -d $rootdir$PELICAN_BLOG_INSTALL_DIR ]; then
  705. mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR
  706. fi
  707. if [ ! -d $rootdir$PELICAN_BLOG_PATH ]; then
  708. mkdir -p $rootdir$PELICAN_BLOG_PATH
  709. fi
  710. if [ ! -d $rootdir$PELICAN_BLOG_INSTALL_DIR/content/images ]; then
  711. mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR/content/images
  712. fi
  713. create_pelican_conf $rootdir$PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
  714. create_pelican_makefile $rootdir$PELICAN_BLOG_INSTALL_DIR/Makefile
  715. create_pelican_publish_conf $rootdir$PELICAN_BLOG_INSTALL_DIR/publishconf.py
  716. mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR/themes
  717. cd $rootdir$PELICAN_BLOG_INSTALL_DIR/themes
  718. pelican_themes
  719. #git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$PELICAN_BLOG_INSTALL_DIR/plugins
  720. chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
  721. chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Public
  722. }
  723. function install_pelican {
  724. if [ $INSTALLING_MESH ]; then
  725. mesh_install_pelican
  726. return
  727. fi
  728. apt-get -yq install python-pip
  729. pip install ipython
  730. pip install Markdown
  731. pip install typogrify
  732. pip install pelican
  733. PELICAN_BLOG_PATH=/var/www/$PELICAN_DOMAIN_NAME/htdocs
  734. if [ ! -d $PELICAN_BLOG_INSTALL_DIR ]; then
  735. mkdir -p $PELICAN_BLOG_INSTALL_DIR
  736. fi
  737. if [ ! -d $PELICAN_BLOG_PATH ]; then
  738. mkdir -p $PELICAN_BLOG_PATH
  739. fi
  740. if [ ! -d $PELICAN_BLOG_INSTALL_DIR/content ]; then
  741. mkdir -p $PELICAN_BLOG_INSTALL_DIR/content
  742. fi
  743. create_pelican_conf $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
  744. create_pelican_makefile $PELICAN_BLOG_INSTALL_DIR/Makefile
  745. create_pelican_publish_conf $PELICAN_BLOG_INSTALL_DIR/publishconf.py
  746. mkdir -p $PELICAN_THEMES_REPO $PELICAN_BLOG_INSTALL_DIR/themes
  747. cd $PELICAN_THEMES_REPO $PELICAN_BLOG_INSTALL_DIR/themes
  748. pelican_themes
  749. #git clone --recursive $PELICAN_PLUGINS_REPO $PELICAN_BLOG_INSTALL_DIR/plugins
  750. chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
  751. chown -R www-data:www-data $PELICAN_BLOG_PATH
  752. pelican_editor_config
  753. PELICAN_ONION_HOSTNAME=$(add_onion_service pelican 80 ${PELICAN_ONION_PORT})
  754. set_completion_param "pelican onion domain" "$PELICAN_ONION_HOSTNAME"
  755. install_pelican_website
  756. install_pelican_website_onion
  757. pelican_regenerate_blog
  758. if [ ! -d $PELICAN_BLOG_INSTALL_DIR/output ]; then
  759. echo $'Failed to generate pelican blog'
  760. exit 521892
  761. fi
  762. function_check nginx_ensite
  763. nginx_ensite $PELICAN_DOMAIN_NAME
  764. systemctl restart nginx
  765. APP_INSTALLED=1
  766. }
  767. # NOTE: deliberately no exit 0