freedombone-app-pelican 35KB

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