|
@@ -36,18 +36,191 @@ SHOW_ON_ABOUT=0
|
36
|
36
|
PELICAN_BLOG_DOMAIN=
|
37
|
37
|
PELICAN_BLOG_CODE=
|
38
|
38
|
|
39
|
|
-STATIC_BLOG_INSTALL_DIR=/etc/staticblog
|
40
|
39
|
PELICAN_THEMES_REPO="https://github.com/getpelican/pelican-themes"
|
41
|
40
|
PELICAN_PLUGINS_REPO="https://github.com/getpelican/pelican-plugins"
|
42
|
41
|
DEFAULT_BLOG_TITLE=$"Freedombone Blog"
|
43
|
42
|
|
|
43
|
+PELICAN_BLOG_INSTALL_DIR=/etc/blog
|
|
44
|
+CURRENT_BLOG_INDEX=$PELICAN_BLOG_INSTALL_DIR/.blog-index
|
|
45
|
+PELICAN_PELICAN_BLOG_INSTALL_DIR=/var/www/$PELICAN_BLOG_DOMAIN/htdocs
|
|
46
|
+
|
44
|
47
|
pelican_variables=(MY_USERNAME
|
45
|
48
|
ONION_ONLY
|
46
|
49
|
PELICAN_BLOG_DOMAIN
|
47
|
50
|
PELICAN_BLOG_CODE)
|
48
|
51
|
|
|
52
|
+function pelican_regenerate_blog {
|
|
53
|
+ clear
|
|
54
|
+ echo ''
|
|
55
|
+ echo $'Regenerating blog...'
|
|
56
|
+
|
|
57
|
+ cd $PELICAN_BLOG_INSTALL_DIR
|
|
58
|
+ make html
|
|
59
|
+}
|
|
60
|
+
|
|
61
|
+function pelican_new_blog {
|
|
62
|
+ DATESTR=$(date "+%Y-%m-%d %H:%M:%S")
|
|
63
|
+
|
|
64
|
+ echo $'Title: Blog Post Title' > $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
65
|
+ echo $"Date: ${DATESTR}" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
66
|
+ echo $"Author: $(toxid --showuser)" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
67
|
+ echo $'Category: default' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
68
|
+ echo $'Tags: blog, tag' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
69
|
+ echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
70
|
+ echo $'Add your text here' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
71
|
+ echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
72
|
+ echo -n $'To include an image copy it into the /etc/blog/content/images directory, ' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
73
|
+ echo $'then link to it with:' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
74
|
+ echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
75
|
+ echo $'' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
76
|
+ echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
77
|
+
|
|
78
|
+ editor $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
|
79
|
+
|
|
80
|
+ if grep -q $"Add your text here" $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry; then
|
|
81
|
+ return
|
|
82
|
+ fi
|
|
83
|
+ if grep -q $"Blog Post Title" $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry; then
|
|
84
|
+ return
|
|
85
|
+ fi
|
|
86
|
+ if [ ! -f $CURRENT_BLOG_INDEX ]; then
|
|
87
|
+ echo '0' > $CURRENT_BLOG_INDEX
|
|
88
|
+ fi
|
|
89
|
+
|
|
90
|
+ # move to the content directory
|
|
91
|
+ CURRENT_INDEX=$(cat $CURRENT_BLOG_INDEX)
|
|
92
|
+ mv $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry $BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.md
|
|
93
|
+
|
|
94
|
+ # increment the index
|
|
95
|
+ CURRENT_INDEX=$((CURRENT_INDEX + 1))
|
|
96
|
+ echo "$CURRENT_INDEX" > $CURRENT_BLOG_INDEX
|
|
97
|
+
|
|
98
|
+ pelican_regenerate_blog
|
|
99
|
+}
|
|
100
|
+
|
|
101
|
+function pelican_edit_blog {
|
|
102
|
+ if [ ! -f $CURRENT_BLOG_INDEX ]; then
|
|
103
|
+ return
|
|
104
|
+ fi
|
|
105
|
+ CURRENT_INDEX=$(cat $CURRENT_BLOG_INDEX)
|
|
106
|
+ PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
|
|
107
|
+ LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
|
|
108
|
+ if [ ! -f $LAST_BLOG_ENTRY ]; then
|
|
109
|
+ return
|
|
110
|
+ fi
|
|
111
|
+ editor $LAST_BLOG_ENTRY
|
|
112
|
+ regenerate_blog
|
|
113
|
+}
|
|
114
|
+
|
|
115
|
+function pelican_delete_blog {
|
|
116
|
+ if [ ! -f $CURRENT_BLOG_INDEX ]; then
|
|
117
|
+ return
|
|
118
|
+ fi
|
|
119
|
+ CURRENT_INDEX=$(cat $CURRENT_BLOG_INDEX)
|
|
120
|
+ PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
|
|
121
|
+ LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
|
|
122
|
+ if [ ! -f $LAST_BLOG_ENTRY ]; then
|
|
123
|
+ return
|
|
124
|
+ fi
|
|
125
|
+
|
|
126
|
+ dialog --title $"Delete the previous blog entry" \
|
|
127
|
+ --backtitle $"Freedombone Mesh" \
|
|
128
|
+ --defaultno \
|
|
129
|
+ --yesno $"\nAre you sure that you wish to delete the previous blog entry?" 8 60
|
|
130
|
+ sel=$?
|
|
131
|
+ case $sel in
|
|
132
|
+ 0) rm $LAST_BLOG_ENTRY
|
|
133
|
+ if [ $CURRENT_INDEX -gt 0 ]; then
|
|
134
|
+ CURRENT_INDEX=$PREVIOUS_INDEX
|
|
135
|
+ echo "$CURRENT_INDEX" > $CURRENT_BLOG_INDEX
|
|
136
|
+ else
|
|
137
|
+ rm -f $CURRENT_BLOG_INDEX
|
|
138
|
+ fi
|
|
139
|
+ pelican_regenerate_blog
|
|
140
|
+ ;;
|
|
141
|
+ esac
|
|
142
|
+}
|
|
143
|
+
|
|
144
|
+function pelican_change_theme {
|
|
145
|
+ THEMES=()
|
|
146
|
+ for d in $PELICAN_BLOG_INSTALL_DIR/themes/*/ ; do
|
|
147
|
+ THEME_NAME=$(echo "$d" | awk -F '/' '{print $6}')
|
|
148
|
+ THEMES+=("$THEME_NAME")
|
|
149
|
+ done
|
|
150
|
+
|
|
151
|
+ themelist=""
|
|
152
|
+ n=1
|
|
153
|
+ theme_index=0
|
|
154
|
+ curr_theme_index=
|
|
155
|
+ if [ -f $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index ]; then
|
|
156
|
+ curr_theme_index=$(cat $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index)
|
|
157
|
+ fi
|
|
158
|
+ for a in "${THEMES[@]}"
|
|
159
|
+ do
|
|
160
|
+ is_selected='off'
|
|
161
|
+ if [ $curr_theme_index ]; then
|
|
162
|
+ if [ $n -eq $curr_theme_index ]; then
|
|
163
|
+ is_selected='on'
|
|
164
|
+ fi
|
|
165
|
+ else
|
|
166
|
+ if [[ "$a" == 'nice-blog' ]]; then
|
|
167
|
+ is_selected='on'
|
|
168
|
+ fi
|
|
169
|
+ fi
|
|
170
|
+
|
|
171
|
+ themelist="$themelist $n $a $is_selected"
|
|
172
|
+ n=$[n+1]
|
|
173
|
+ theme_index=$[theme_index+1]
|
|
174
|
+ done
|
|
175
|
+
|
|
176
|
+ data=$(tempfile 2>/dev/null)
|
|
177
|
+ trap "rm -f $data" 0 1 2 5 15
|
|
178
|
+ dialog --backtitle $"Freedombone Mesh" \
|
|
179
|
+ --title $"Select Blog Theme" \
|
|
180
|
+ --radiolist $'Choose:' \
|
|
181
|
+ 80 40 20 $themelist 2> $data
|
|
182
|
+
|
|
183
|
+ sel=$?
|
|
184
|
+ case $sel in
|
|
185
|
+ 1) exit 1;;
|
|
186
|
+ 255) exit 1;;
|
|
187
|
+ esac
|
|
188
|
+ CHOSEN_THEME_INDEX=$(cat $data)
|
|
189
|
+ echo "$CHOSEN_THEME_INDEX" > $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index
|
|
190
|
+ CHOSEN_THEME_INDEX=$((CHOSEN_THEME_INDEX - 1))
|
|
191
|
+
|
|
192
|
+ CHOSEN_THEME=${THEMES[$CHOSEN_THEME_INDEX]}
|
|
193
|
+ if grep -q "THEME=" $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py; then
|
|
194
|
+ sed -i "s|THEME=.*|THEME='themes/${CHOSEN_THEME}'|g" $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
|
|
195
|
+ else
|
|
196
|
+ echo "THEME='themes/${CHOSEN_THEME}'" >> $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
|
|
197
|
+ fi
|
|
198
|
+ pelican_regenerate_blog
|
|
199
|
+}
|
|
200
|
+
|
49
|
201
|
function configure_interactive_pelican {
|
50
|
|
- echo -n ''
|
|
202
|
+ data=$(tempfile 2>/dev/null)
|
|
203
|
+ trap "rm -f $data" 0 1 2 5 15
|
|
204
|
+ dialog --backtitle $"Freedombone Configuration" \
|
|
205
|
+ --title $"Pelican Blogging" \
|
|
206
|
+ --radiolist $"Choose an operation:" 18 50 11 \
|
|
207
|
+ 1 $"New blog entry" off \
|
|
208
|
+ 2 $"Edit the previous blog entry" off \
|
|
209
|
+ 3 $"Delete the previous blog entry" off \
|
|
210
|
+ 4 $"Change theme" off \
|
|
211
|
+ 5 $"Exit" off 2> $data
|
|
212
|
+ sel=$?
|
|
213
|
+ case $sel in
|
|
214
|
+ 1) exit 1;;
|
|
215
|
+ 255) exit 1;;
|
|
216
|
+ esac
|
|
217
|
+ case $(cat $data) in
|
|
218
|
+ 1) pelican_new_blog;;
|
|
219
|
+ 2) pelican_edit_blog;;
|
|
220
|
+ 3) pelican_delete_blog;;
|
|
221
|
+ 4) pelican_change_theme;;
|
|
222
|
+ 5) break;;
|
|
223
|
+ esac
|
51
|
224
|
}
|
52
|
225
|
|
53
|
226
|
function install_interactive_pelican {
|
|
@@ -252,7 +425,7 @@ function create_pelican_makefile {
|
252
|
425
|
echo '' >> $STATIC_BLOG_FILE
|
253
|
426
|
echo 'BASEDIR=$(CURDIR)' >> $STATIC_BLOG_FILE
|
254
|
427
|
echo 'INPUTDIR=$(BASEDIR)/content' >> $STATIC_BLOG_FILE
|
255
|
|
- echo "OUTPUTDIR=$STATIC_BLOG_PATH" >> $STATIC_BLOG_FILE
|
|
428
|
+ echo "OUTPUTDIR=$PELICAN_BLOG_PATH" >> $STATIC_BLOG_FILE
|
256
|
429
|
echo 'CONFFILE=$(BASEDIR)/pelicanconf.py' >> $STATIC_BLOG_FILE
|
257
|
430
|
echo 'PUBLISHCONF=$(BASEDIR)/publishconf.py' >> $STATIC_BLOG_FILE
|
258
|
431
|
echo '' >> $STATIC_BLOG_FILE
|
|
@@ -413,32 +586,32 @@ function mesh_install_pelican {
|
413
|
586
|
chroot "$rootdir" pip install typogrify
|
414
|
587
|
chroot "$rootdir" pip install pelican
|
415
|
588
|
|
416
|
|
- STATIC_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
|
417
|
|
- STATIC_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
|
|
589
|
+ PELICAN_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
|
|
590
|
+ PELICAN_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
|
418
|
591
|
|
419
|
|
- if [ ! -d $rootdir$STATIC_BLOG_INSTALL_DIR ]; then
|
420
|
|
- mkdir -p $rootdir$STATIC_BLOG_INSTALL_DIR
|
|
592
|
+ if [ ! -d $rootdir$PELICAN_BLOG_INSTALL_DIR ]; then
|
|
593
|
+ mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR
|
421
|
594
|
fi
|
422
|
595
|
|
423
|
|
- if [ ! -d $rootdir$STATIC_BLOG_PATH ]; then
|
424
|
|
- mkdir -p $rootdir$STATIC_BLOG_PATH
|
|
596
|
+ if [ ! -d $rootdir$PELICAN_BLOG_PATH ]; then
|
|
597
|
+ mkdir -p $rootdir$PELICAN_BLOG_PATH
|
425
|
598
|
fi
|
426
|
599
|
|
427
|
|
- if [ ! -d $rootdir$STATIC_BLOG_INSTALL_DIR/content/images ]; then
|
428
|
|
- mkdir -p $rootdir$STATIC_BLOG_INSTALL_DIR/content/images
|
|
600
|
+ if [ ! -d $rootdir$PELICAN_BLOG_INSTALL_DIR/content/images ]; then
|
|
601
|
+ mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR/content/images
|
429
|
602
|
fi
|
430
|
603
|
|
431
|
|
- create_pelican_conf $rootdir$STATIC_BLOG_INSTALL_DIR/pelicanconf.py
|
432
|
|
- create_pelican_makefile $rootdir$STATIC_BLOG_INSTALL_DIR/Makefile
|
433
|
|
- create_pelican_publish_conf $rootdir$STATIC_BLOG_INSTALL_DIR/publishconf.py
|
|
604
|
+ create_pelican_conf $rootdir$PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
|
|
605
|
+ create_pelican_makefile $rootdir$PELICAN_BLOG_INSTALL_DIR/Makefile
|
|
606
|
+ create_pelican_publish_conf $rootdir$PELICAN_BLOG_INSTALL_DIR/publishconf.py
|
434
|
607
|
|
435
|
|
- mkdir -p $rootdir$STATIC_BLOG_INSTALL_DIR/themes
|
436
|
|
- cd $rootdir$STATIC_BLOG_INSTALL_DIR/themes
|
|
608
|
+ mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR/themes
|
|
609
|
+ cd $rootdir$PELICAN_BLOG_INSTALL_DIR/themes
|
437
|
610
|
pelican_themes
|
438
|
611
|
|
439
|
|
- #git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$STATIC_BLOG_INSTALL_DIR/plugins
|
|
612
|
+ #git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$PELICAN_BLOG_INSTALL_DIR/plugins
|
440
|
613
|
|
441
|
|
- chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR
|
|
614
|
+ chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
|
442
|
615
|
chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Public
|
443
|
616
|
}
|
444
|
617
|
|
|
@@ -454,33 +627,32 @@ function install_pelican {
|
454
|
627
|
pip install typogrify
|
455
|
628
|
pip install pelican
|
456
|
629
|
|
457
|
|
- STATIC_BLOG_INSTALL_DIR=/etc/blog
|
458
|
|
- STATIC_BLOG_PATH=/var/www/$PELICAN_BLOG_DOMAIN/htdocs
|
|
630
|
+ PELICAN_BLOG_PATH=/var/www/$PELICAN_BLOG_DOMAIN/htdocs
|
459
|
631
|
|
460
|
|
- if [ ! -d $STATIC_BLOG_INSTALL_DIR ]; then
|
461
|
|
- mkdir -p $STATIC_BLOG_INSTALL_DIR
|
|
632
|
+ if [ ! -d $PELICAN_BLOG_INSTALL_DIR ]; then
|
|
633
|
+ mkdir -p $PELICAN_BLOG_INSTALL_DIR
|
462
|
634
|
fi
|
463
|
635
|
|
464
|
|
- if [ ! -d $STATIC_BLOG_PATH ]; then
|
465
|
|
- mkdir -p $STATIC_BLOG_PATH
|
|
636
|
+ if [ ! -d $PELICAN_BLOG_PATH ]; then
|
|
637
|
+ mkdir -p $PELICAN_BLOG_PATH
|
466
|
638
|
fi
|
467
|
639
|
|
468
|
|
- if [ ! -d $STATIC_BLOG_INSTALL_DIR/content ]; then
|
469
|
|
- mkdir -p $STATIC_BLOG_INSTALL_DIR/content
|
|
640
|
+ if [ ! -d $PELICAN_BLOG_INSTALL_DIR/content ]; then
|
|
641
|
+ mkdir -p $PELICAN_BLOG_INSTALL_DIR/content
|
470
|
642
|
fi
|
471
|
643
|
|
472
|
|
- create_pelican_conf $STATIC_BLOG_INSTALL_DIR/pelicanconf.py
|
473
|
|
- create_pelican_makefile $STATIC_BLOG_INSTALL_DIR/Makefile
|
474
|
|
- create_pelican_publish_conf $STATIC_BLOG_INSTALL_DIR/publishconf.py
|
|
644
|
+ create_pelican_conf $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
|
|
645
|
+ create_pelican_makefile $PELICAN_BLOG_INSTALL_DIR/Makefile
|
|
646
|
+ create_pelican_publish_conf $PELICAN_BLOG_INSTALL_DIR/publishconf.py
|
475
|
647
|
|
476
|
|
- mkdir -p $PELICAN_THEMES_REPO $STATIC_BLOG_INSTALL_DIR/themes
|
477
|
|
- cd $PELICAN_THEMES_REPO $STATIC_BLOG_INSTALL_DIR/themes
|
|
648
|
+ mkdir -p $PELICAN_THEMES_REPO $PELICAN_BLOG_INSTALL_DIR/themes
|
|
649
|
+ cd $PELICAN_THEMES_REPO $PELICAN_BLOG_INSTALL_DIR/themes
|
478
|
650
|
pelican_themes
|
479
|
651
|
|
480
|
|
- #git clone --recursive $PELICAN_PLUGINS_REPO $STATIC_BLOG_INSTALL_DIR/plugins
|
|
652
|
+ #git clone --recursive $PELICAN_PLUGINS_REPO $PELICAN_BLOG_INSTALL_DIR/plugins
|
481
|
653
|
|
482
|
|
- chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR
|
483
|
|
- chown -R www-data:www-data $STATIC_BLOG_PATH
|
|
654
|
+ chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
|
|
655
|
+ chown -R www-data:www-data $PELICAN_BLOG_PATH
|
484
|
656
|
APP_INSTALLED=1
|
485
|
657
|
}
|
486
|
658
|
|