ソースを参照

Rename blog to htmly

To avoid confusion with other blog apps
Bob Mottram 8 年 前
コミット
6fef19ad28
共有7 個のファイルを変更した692 個の追加817 個の削除を含む
  1. 0
    623
      src/freedombone-app-blog
  2. 661
    0
      src/freedombone-app-htmly
  3. 0
    163
      src/freedombone-blog
  4. 3
    3
      src/freedombone-config
  5. 24
    24
      src/freedombone-sec
  6. 3
    3
      src/freedombone-utils-onion
  7. 1
    1
      src/freedombone-utils-upgrade

+ 0
- 623
src/freedombone-app-blog ファイルの表示

@@ -1,623 +0,0 @@
1
-#!/bin/bash
2
-#
3
-# .---.                  .              .
4
-# |                      |              |
5
-# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
-# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
-# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
-#
9
-#                    Freedom in the Cloud
10
-#
11
-# Blog functions
12
-#
13
-# License
14
-# =======
15
-#
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
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
-
31
-VARIANTS="full full-vim writer"
32
-
33
-FULLBLOG_DOMAIN_NAME=
34
-FULLBLOG_CODE=
35
-FULLBLOG_ONION_PORT=8086
36
-FULLBLOG_REPO="https://github.com/danpros/htmly"
37
-FULLBLOG_COMMIT='bf5fe9486160be4da86d8987d3e5c977e1dc6d32'
38
-MY_BLOG_TITLE="My Blog"
39
-MY_BLOG_SUBTITLE="Another ${PROJECT_NAME} Blog"
40
-
41
-blog_variables=(FULLBLOG_REPO
42
-                FULLBLOG_COMMIT
43
-                FULLBLOG_DOMAIN_NAME
44
-                FULLBLOG_CODE
45
-                MY_BLOG_TITLE
46
-                MY_BLOG_SUBTITLE
47
-                ONION_ONLY
48
-                DDNS_PROVIDER
49
-                MY_USERNAME)
50
-
51
-function remove_user_blog {
52
-    remove_username="$1"
53
-
54
-    if [ -f /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini ]; then
55
-        rm /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini
56
-    fi
57
-}
58
-
59
-function add_user_blog {
60
-    if [[ $(app_is_installed blog) == "0" ]]; then
61
-        echo '0'
62
-        return
63
-    fi
64
-
65
-    new_username="$1"
66
-    new_user_password="$2"
67
-
68
-    if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users ]; then
69
-        echo '2'
70
-        return
71
-    fi
72
-    NEW_USER_PASSWORD_HASH=$(${PROJECT_NAME}-sec --bloghash "$new_user_password")
73
-    if [ ${#NEW_USER_PASSWORD_HASH} -lt 8 ]; then
74
-        echo '3'
75
-        return
76
-    fi
77
-    echo ';Password' > /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$new_username.ini
78
-    echo "password = $NEW_USER_PASSWORD_HASH" >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$new_username.ini
79
-    echo 'encryption = password_hash' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$new_username.ini
80
-    echo ';Role' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$new_username.ini
81
-    echo 'role = admin' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$new_username.ini
82
-    echo '0'
83
-}
84
-
85
-function configure_interactive_blog {
86
-    data=$(tempfile 2>/dev/null)
87
-    trap "rm -f $data" 0 1 2 5 15
88
-    dialog --title $"Change blog avatar" \
89
-           --backtitle $"Freedombone Control Panel" \
90
-           --inputbox $"Enter a URL for an image. It should be approximately a square image." 8 75 2>$data
91
-    sel=$?
92
-    case $sel in
93
-        0)
94
-            IMAGE_URL=$(<$data)
95
-            if [ ${#IMAGE_URL} -gt 5 ]; then
96
-                clear
97
-                ${PROJECT_NAME}-blog -a $IMAGE_URL
98
-                if [ "$?" = "0" ]; then
99
-                    dialog --title $"Change blog avatar" \
100
-                           --msgbox $"Your blog avatar has been changed" 6 40
101
-                fi
102
-            fi
103
-            ;;
104
-    esac
105
-}
106
-
107
-function install_interactive_blog {
108
-    if [ ! $ONION_ONLY ]; then
109
-        ONION_ONLY='no'
110
-    fi
111
-
112
-    if [[ $ONION_ONLY != "no" ]]; then
113
-        MY_BLOG_TITLE='My Blog'
114
-        FULLBLOG_DOMAIN_NAME='blog.local'
115
-        write_config_param "MY_BLOG_TITLE" "$MY_BLOG_TITLE"
116
-        write_config_param "FULLBLOG_DOMAIN_NAME" "$FULLBLOG_DOMAIN_NAME"
117
-    else
118
-        function_check interactive_site_details_with_title
119
-        interactive_site_details_with_title "blog" "MY_BLOG_TITLE" "FULLBLOG_DOMAIN_NAME" "FULLBLOG_CODE"
120
-    fi
121
-    APP_INSTALLED=1
122
-}
123
-
124
-function change_password_blog {
125
-    if ! grep -q "blog domain:" $COMPLETION_FILE; then
126
-        echo "blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
127
-    fi
128
-    FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | head -n 1 | awk -F ':' '{print $2}')
129
-
130
-    BLOG_USERNAME="$1"
131
-    BLOG_PASSWORD="$2"
132
-    if [ ${#BLOG_PASSWORD} -lt 8 ]; then
133
-        echo $'Blog password is too short'
134
-        return
135
-    fi
136
-    BLOG_PASSWORD_HASH=$(${PROJECT_NAME}-sec --bloghash "$BLOG_PASSWORD")
137
-    if [ ${#BLOG_PASSWORD_HASH} -lt 8 ]; then
138
-        echo $'Blog admin password could not be hashed'
139
-        exit 625728
140
-    fi
141
-    sed -i "s|password =.*|password = $BLOG_PASSWORD_HASH|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$BLOG_USERNAME.ini
142
-}
143
-
144
-function reconfigure_blog {
145
-    echo -n ''
146
-}
147
-
148
-function upgrade_blog {
149
-    read_config_param "FULLBLOG_DOMAIN_NAME"
150
-
151
-    function_check set_repo_commit
152
-    set_repo_commit /var/www/$FULLBLOG_DOMAIN_NAME/htdocs "blog commit" "$FULLBLOG_COMMIT" $FULLBLOG_REPO
153
-
154
-    # update blog avatar
155
-    ${PROJECT_NAME}-blog
156
-}
157
-
158
-function backup_local_blog {
159
-    FULLBLOG_DOMAIN_NAME='blog'
160
-    if grep -q "blog domain" $COMPLETION_FILE; then
161
-        FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | awk -F ':' '{print $2}')
162
-    fi
163
-
164
-    source_directory=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
165
-    if [ -d $source_directory ]; then
166
-        dest_directory=blog
167
-        echo $"Backing up $source_directory to $dest_directory"
168
-
169
-        function_check suspend_site
170
-        suspend_site ${FULLBLOG_DOMAIN_NAME}
171
-
172
-        function_check backup_directory_to_usb
173
-        backup_directory_to_usb $source_directory $dest_directory
174
-
175
-        function_check restart_site
176
-        restart_site
177
-
178
-        echo $"Backup to $dest_directory complete"
179
-    fi
180
-}
181
-
182
-function restore_local_blog {
183
-    FULLBLOG_DOMAIN_NAME='blog'
184
-    if grep -q "blog domain" $COMPLETION_FILE; then
185
-        FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | awk -F ':' '{print $2}')
186
-    fi
187
-    if [ $FULLBLOG_DOMAIN_NAME ]; then
188
-        echo $"Restoring blog installation"
189
-        temp_restore_dir=/root/tempblog
190
-        restore_directory_from_usb $temp_restore_dir blog
191
-        rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
192
-        cp -r $temp_restore_dir/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
193
-        if [ ! "$?" = "0" ]; then
194
-            set_user_permissions
195
-            backup_unmount_drive
196
-            exit 593
197
-        fi
198
-        rm -rf $temp_restore_dir
199
-        if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
200
-            echo $"No content directory found after restoring blog"
201
-            set_user_permissions
202
-            backup_unmount_drive
203
-            exit 287
204
-        fi
205
-        chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
206
-        # Ensure that the bundled SSL cert is being used
207
-        if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
208
-            sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
209
-        fi
210
-        for d in /home/*/ ; do
211
-            USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
212
-            if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
213
-                if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
214
-                    mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
215
-                fi
216
-            fi
217
-        done
218
-        if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
219
-            ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
220
-            ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
221
-        fi
222
-    fi
223
-}
224
-
225
-function backup_remote_blog {
226
-    if grep -q "blog domain" $COMPLETION_FILE; then
227
-        FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | awk -F ':' '{print $2}')
228
-        temp_backup_dir=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
229
-        if [ -d $temp_backup_dir ]; then
230
-            echo $"Backing up blog"
231
-            backup_directory_to_friend $temp_backup_dir blog
232
-            echo $"Backup of blog complete"
233
-        else
234
-            echo $"Blog domain specified but not found in $temp_backup_dir"
235
-            exit 2578
236
-        fi
237
-    fi
238
-}
239
-
240
-function restore_remote_blog {
241
-    if [ -d $SERVER_DIRECTORY/backup/blog ]; then
242
-        FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | awk -F ':' '{print $2}')
243
-        echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME"
244
-        temp_restore_dir=/root/tempblog
245
-        mkdir $temp_restore_dir
246
-        function_check restore_directory_from_friend
247
-        restore_directory_from_friend $temp_restore_dir blog
248
-        rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
249
-        cp -r $temp_restore_dir/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
250
-        if [ ! "$?" = "0" ]; then
251
-            exit 593
252
-        fi
253
-        rm -rf $temp_restore_dir
254
-        if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
255
-            echo $"No content directory found after restoring blog"
256
-            exit 287
257
-        fi
258
-        # Ensure that the bundled SSL cert is being used
259
-        if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
260
-            sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
261
-        fi
262
-        for d in /home/*/ ; do
263
-            USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
264
-            if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
265
-                if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
266
-                    mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
267
-                fi
268
-            fi
269
-        done
270
-        if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
271
-            ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
272
-            ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
273
-        fi
274
-        echo $"Restore of blog complete"
275
-    fi
276
-}
277
-
278
-function remove_blog {
279
-    if [ ${#FULLBLOG_DOMAIN_NAME} -eq 0 ]; then
280
-        return
281
-    fi
282
-
283
-    read_config_param "FULLBLOG_DOMAIN_NAME"
284
-    nginx_dissite $FULLBLOG_DOMAIN_NAME
285
-    if [ -f /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME ]; then
286
-        rm -f /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
287
-    fi
288
-    if [ -d /var/www/$FULLBLOG_DOMAIN_NAME ]; then
289
-        rm -rf /var/www/$FULLBLOG_DOMAIN_NAME
290
-    fi
291
-    if [ $FULLBLOG_CODE ]; then
292
-        if [ -f /usr/bin/dynamicdns ]; then
293
-            sed -i "/$FULLBLOG_DOMAIN_NAME/d" /usr/bin/dynamicdns
294
-            sed -i "/$FULLBLOG_CODE/d" /usr/bin/dynamicdns
295
-        fi
296
-    fi
297
-    function_check remove_onion_service
298
-    remove_onion_service blog ${FULLBLOG_ONION_PORT}
299
-    sed -i '/install_blog/d' $COMPLETION_FILE
300
-    sed -i '/Blog .*/d' $COMPLETION_FILE
301
-}
302
-
303
-function get_blog_admin_password {
304
-    if [ -f /home/$MY_USERNAME/README ]; then
305
-        if grep -q "Your blog password is" /home/$MY_USERNAME/README; then
306
-            FULLBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Your blog password is" | awk -F ':' '{print $2}' | sed 's/^ *//')
307
-        fi
308
-    fi
309
-}
310
-
311
-function install_blog_social_networks {
312
-    # set social networks
313
-    if grep -q "social.hubzilla" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini; then
314
-        sed -i "s|;social.hubzilla|social.hubzilla|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
315
-        sed -i "s|social.hubzilla.*|social.hubzilla = \"$HUBZILLA_DOMAIN_NAME\"|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
316
-    fi
317
-    if grep -q "social.gnusocial" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini; then
318
-        sed -i "s|;social.gnusocial|social.gnusocial|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
319
-        sed -i "s|social.gnusocial.*|social.gnusocial = \"$MICROBLOG_DOMAIN_NAME\"|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
320
-    fi
321
-
322
-    # clear proprietary social network strings
323
-    sed -i 's|social.facebook.*|social.facebook = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
324
-    sed -i 's|social.twitter.*|social.twitter = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
325
-    sed -i 's|social.google.*|social.google = ""|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
326
-}
327
-
328
-function install_blog_user {
329
-    # create a user password
330
-    function_check get_blog_admin_password
331
-    get_blog_admin_password
332
-    if [ ! $FULLBLOG_ADMIN_PASSWORD ]; then
333
-        if [ -f $IMAGE_PASSWORD_FILE ]; then
334
-            FULLBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
335
-        else
336
-            FULLBLOG_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
337
-        fi
338
-        echo '' >> /home/$MY_USERNAME/README
339
-        echo '' >> /home/$MY_USERNAME/README
340
-        echo $'HTMLy Blog' >> /home/$MY_USERNAME/README
341
-        echo '==========' >> /home/$MY_USERNAME/README
342
-        echo $"Your blog username: $MY_USERNAME" >> /home/$MY_USERNAME/README
343
-        echo $"Your blog password is: $FULLBLOG_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
344
-        if [[ $ONION_ONLY == 'no' ]]; then
345
-            echo $"Log into your blog at https://$FULLBLOG_DOMAIN_NAME/login" >> /home/$MY_USERNAME/README
346
-        fi
347
-        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
348
-        chmod 600 /home/$MY_USERNAME/README
349
-    fi
350
-
351
-    # create a user
352
-    FULLBLOG_ADMIN_PASSWORD_HASH=$(${PROJECT_NAME}-sec --bloghash "$FULLBLOG_ADMIN_PASSWORD")
353
-    if [ ${#FULLBLOG_ADMIN_PASSWORD_HASH} -lt 8 ]; then
354
-        echo $'Blog admin password could not be hashed'
355
-        exit 625728
356
-    fi
357
-    echo ';Password' > /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
358
-    echo "password = $FULLBLOG_ADMIN_PASSWORD_HASH" >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
359
-    echo 'encryption = password_hash' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
360
-    echo ';Role' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
361
-    echo 'role = admin' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
362
-}
363
-
364
-function install_blog_settings {
365
-    cp /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini.example /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
366
-    sed -i "s|site.url.*|site.url = '/'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
367
-    sed -i "s|blog.title.*|blog.title = '$MY_BLOG_TITLE'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
368
-    sed -i "s|blog.tagline.*|blog.tagline = '$MY_BLOG_SUBTITLE'|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
369
-    sed -i 's|timezone.*|timezone = "Europe/London"|g' /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
370
-    sed -i "s|Your name|$MY_NAME|g" /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/config.ini
371
-}
372
-
373
-function install_blog_website {
374
-    function_check nginx_http_redirect
375
-    nginx_http_redirect $FULLBLOG_DOMAIN_NAME
376
-    echo 'server {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
377
-    echo '    listen 443 ssl;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
378
-    echo "    root /var/www/$FULLBLOG_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
379
-    echo "    server_name $FULLBLOG_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
380
-    echo '    access_log off;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
381
-    echo "    error_log /var/log/nginx/${FULLBLOG_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
382
-    echo '    index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
383
-    echo '    charset utf-8;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
384
-    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
385
-    function_check nginx_ssl
386
-    nginx_ssl $FULLBLOG_DOMAIN_NAME
387
-    function_check nginx_disable_sniffing
388
-    nginx_disable_sniffing $FULLBLOG_DOMAIN_NAME
389
-    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
390
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
391
-    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
392
-    echo '    location / {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
393
-    function_check nginx_limits
394
-    nginx_limits $FULLBLOG_DOMAIN_NAME
395
-    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
396
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
397
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
398
-    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
399
-    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
400
-    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
401
-    echo '        allow all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
402
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
403
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
404
-    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
405
-    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
406
-    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
407
-    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
408
-    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
409
-    echo '        expires 30d;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
410
-    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
411
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
412
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
413
-    echo '    # block these file types' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
414
-    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
415
-    echo '        deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
416
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
417
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
418
-    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
419
-    echo '    # or a unix socket' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
420
-    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
421
-    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
422
-    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
423
-    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
424
-    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
425
-    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
426
-    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
427
-    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
428
-    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
429
-    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
430
-    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
431
-    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
432
-    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
433
-    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
434
-    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
435
-    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
436
-    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
437
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
438
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
439
-    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
440
-    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
441
-    echo '        deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
442
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
443
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
444
-    echo '    #deny access to store' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
445
-    echo '    location ~ /store {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
446
-    echo '        deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
447
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
448
-    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
449
-    echo '      deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
450
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
451
-    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
452
-    echo '      deny  all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
453
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
454
-    echo '}' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
455
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
456
-}
457
-
458
-function install_blog_website_onion {
459
-    echo 'server {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
460
-    echo "    listen 127.0.0.1:${FULLBLOG_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
461
-    echo "    root /var/www/$FULLBLOG_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
462
-    echo "    server_name $FULLBLOG_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
463
-    echo '    access_log off;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
464
-    echo "    error_log /var/log/nginx/${FULLBLOG_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
465
-    echo '    index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
466
-    echo '    charset utf-8;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
467
-    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
468
-    function_check nginx_disable_sniffing
469
-    nginx_disable_sniffing $FULLBLOG_DOMAIN_NAME
470
-    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
471
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
472
-    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
473
-    echo '    location / {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
474
-    function_check nginx_limits
475
-    nginx_limits $FULLBLOG_DOMAIN_NAME
476
-    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
477
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
478
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
479
-    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
480
-    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
481
-    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
482
-    echo '        allow all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
483
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
484
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
485
-    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
486
-    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
487
-    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
488
-    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
489
-    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
490
-    echo '        expires 30d;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
491
-    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
492
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
493
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
494
-    echo '    # block these file types' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
495
-    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
496
-    echo '        deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
497
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
498
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
499
-    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
500
-    echo '    # or a unix socket' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
501
-    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
502
-    function_check nginx_limits
503
-    nginx_limits $FULLBLOG_DOMAIN_NAME
504
-    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
505
-    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
506
-    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
507
-    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
508
-    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
509
-    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
510
-    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
511
-    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
512
-    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
513
-    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
514
-    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
515
-    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
516
-    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
517
-    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
518
-    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
519
-    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
520
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
521
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
522
-    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
523
-    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
524
-    echo '        deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
525
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
526
-    echo '' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
527
-    echo '    #deny access to store' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
528
-    echo '    location ~ /store {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
529
-    echo '        deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
530
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
531
-    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
532
-    echo '      deny all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
533
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
534
-    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
535
-    echo '      deny  all;' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
536
-    echo '    }' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
537
-    echo '}' >> /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
538
-}
539
-
540
-function install_blog_from_repo {
541
-    if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME ]; then
542
-        mkdir /var/www/$FULLBLOG_DOMAIN_NAME
543
-    fi
544
-
545
-    cd /var/www/$FULLBLOG_DOMAIN_NAME
546
-    git_clone $FULLBLOG_REPO htdocs
547
-    cd htdocs
548
-    git checkout $FULLBLOG_COMMIT -b $FULLBLOG_COMMIT
549
-    if ! grep -q "blog commit" $COMPLETION_FILE; then
550
-        echo "blog commit:$FULLBLOG_COMMIT" >> $COMPLETION_FILE
551
-    else
552
-        sed -i "s/blog commit.*/blog commit:$FULLBLOG_COMMIT/g" $COMPLETION_FILE
553
-    fi
554
-}
555
-
556
-function install_blog {
557
-    if [ ! $ONION_ONLY ]; then
558
-        ONION_ONLY='no'
559
-    fi
560
-
561
-    if [ ! $FULLBLOG_DOMAIN_NAME ]; then
562
-        echo $'The blog domain name was not specified'
563
-        exit 5062
564
-    fi
565
-
566
-    # for the avatar changing command
567
-    apt-get -y install imagemagick
568
-
569
-    function_check install_blog_from_repo
570
-    install_blog_from_repo
571
-
572
-    if [[ $ONION_ONLY == "no" ]]; then
573
-        function_check install_blog_website
574
-        install_blog_website
575
-    else
576
-        echo -n '' > /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME
577
-    fi
578
-    function_check install_blog_website_onion
579
-    install_blog_website_onion
580
-
581
-    function_check create_site_certificate
582
-    create_site_certificate $FULLBLOG_DOMAIN_NAME 'yes'
583
-
584
-    function_check configure_php
585
-    configure_php
586
-
587
-    function_check install_blog_settings
588
-    install_blog_settings
589
-
590
-    function_check install_blog_social_networks
591
-    install_blog_social_networks
592
-
593
-    function_check install_blog_user
594
-    install_blog_user
595
-
596
-    chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
597
-
598
-    FULLBLOG_ONION_HOSTNAME=$(add_onion_service blog 80 ${FULLBLOG_ONION_PORT})
599
-
600
-    function_check nginx_ensite
601
-    nginx_ensite $FULLBLOG_DOMAIN_NAME
602
-
603
-    systemctl restart php5-fpm
604
-    systemctl restart nginx
605
-
606
-    if ! grep -q "Blog onion domain" /home/$MY_USERNAME/README; then
607
-        echo $"Blog onion domain: ${FULLBLOG_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
608
-        echo $"Log into your blog at https://${FULLBLOG_ONION_HOSTNAME}/login" >> /home/$MY_USERNAME/README
609
-        echo '' >> /home/$MY_USERNAME/README
610
-        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
611
-        chmod 600 /home/$MY_USERNAME/README
612
-    fi
613
-
614
-    function_check add_ddns_domain
615
-    add_ddns_domain $FULLBLOG_DOMAIN_NAME
616
-
617
-    if ! grep -q "blog domain:" $COMPLETION_FILE; then
618
-        echo "blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
619
-    fi
620
-    APP_INSTALLED=1
621
-}
622
-
623
-# NOTE: deliberately no exit 0

+ 661
- 0
src/freedombone-app-htmly ファイルの表示

@@ -0,0 +1,661 @@
1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Htmly functions
12
+#
13
+# License
14
+# =======
15
+#
16
+# Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
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
+
31
+VARIANTS="full full-vim writer"
32
+
33
+HYMLY_DOMAIN_NAME=
34
+HYMLY_CODE=
35
+HYMLY_ONION_PORT=8086
36
+HYMLY_REPO="https://github.com/danpros/htmly"
37
+HYMLY_COMMIT='bf5fe9486160be4da86d8987d3e5c977e1dc6d32'
38
+HTMLY_TITLE="My Htmly"
39
+HTMLY_SUBTITLE="Another ${PROJECT_NAME} Htmly"
40
+
41
+htmly_variables=(HYMLY_REPO
42
+                HYMLY_COMMIT
43
+                HYMLY_DOMAIN_NAME
44
+                HYMLY_CODE
45
+                HTMLY_TITLE
46
+                HTMLY_SUBTITLE
47
+                ONION_ONLY
48
+                DDNS_PROVIDER
49
+                MY_USERNAME)
50
+
51
+function set_avatar_from_url {
52
+    AVATAR="$1"
53
+
54
+    read_config_param "HTMLY_DOMAIN_NAME"
55
+    BASE_DIR=/var/www/$HTMLY_DOMAIN_NAME/htdocs
56
+
57
+    if [ ! -d $BASE_DIR/customimages ]; then
58
+        mkdir $BASE_DIR/customimages
59
+    fi
60
+
61
+    # download the image
62
+    cd $BASE_DIR/customimages
63
+    # convert to png
64
+    wget $AVATAR -O avatar
65
+    if [[ $AVATAR == *".gif" ]]; then
66
+        mv avatar avatar.gif
67
+        mogrify -format png avatar.gif
68
+    fi
69
+    if [[ $AVATAR == *".jpg" ]]; then
70
+        mv avatar avatar.jpg
71
+        mogrify -format png avatar.jpg
72
+    fi
73
+    if [[ $AVATAR == *".jpeg" ]]; then
74
+        mv avatar avatar.jpeg
75
+        mogrify -format png avatar.jpeg
76
+    fi
77
+    if [ -f avatar ]; then
78
+        mv avatar avatar.png
79
+    fi
80
+
81
+    # standard size
82
+    mogrify -resize 150x150 avatar.png
83
+    if [ ! -f $BASE_DIR/customimages/avatar.png ]; then
84
+        echo $'Avatar image could not be downloaded'
85
+        return
86
+    fi
87
+    chown -R www-data:www-data $BASE_DIR/customimages
88
+    AVATAR_SET=1
89
+}
90
+
91
+function remove_user_htmly {
92
+    remove_username="$1"
93
+
94
+    if [ -f /var/www/${HYMLY_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini ]; then
95
+        rm /var/www/${HYMLY_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini
96
+    fi
97
+}
98
+
99
+function add_user_htmly {
100
+    if [[ $(app_is_installed htmly) == "0" ]]; then
101
+        echo '0'
102
+        return
103
+    fi
104
+
105
+    new_username="$1"
106
+    new_user_password="$2"
107
+
108
+    if [ ! -d /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users ]; then
109
+        echo '2'
110
+        return
111
+    fi
112
+    NEW_USER_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$new_user_password")
113
+    if [ ${#NEW_USER_PASSWORD_HASH} -lt 8 ]; then
114
+        echo '3'
115
+        return
116
+    fi
117
+    echo ';Password' > /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
118
+    echo "password = $NEW_USER_PASSWORD_HASH" >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
119
+    echo 'encryption = password_hash' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
120
+    echo ';Role' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
121
+    echo 'role = admin' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$new_username.ini
122
+    echo '0'
123
+}
124
+
125
+function configure_interactive_htmly {
126
+    data=$(tempfile 2>/dev/null)
127
+    trap "rm -f $data" 0 1 2 5 15
128
+    dialog --title $"Change htmly avatar" \
129
+           --backtitle $"Freedombone Control Panel" \
130
+           --inputbox $"Enter a URL for an image. It should be approximately a square image." 8 75 2>$data
131
+    sel=$?
132
+    case $sel in
133
+        0)
134
+            IMAGE_URL=$(<$data)
135
+            if [ ${#IMAGE_URL} -gt 5 ]; then
136
+                clear
137
+                AVATAR_SET=
138
+                set_avatar_from_url $IMAGE_URL
139
+                if [ $AVATAR_SET ]; then
140
+                    dialog --title $"Change htmly avatar" \
141
+                           --msgbox $"Your htmly avatar has been changed" 6 40
142
+                fi
143
+            fi
144
+            ;;
145
+    esac
146
+}
147
+
148
+function install_interactive_htmly {
149
+    if [ ! $ONION_ONLY ]; then
150
+        ONION_ONLY='no'
151
+    fi
152
+
153
+    if [[ $ONION_ONLY != "no" ]]; then
154
+        HTMLY_TITLE='My Htmly'
155
+        HYMLY_DOMAIN_NAME='htmly.local'
156
+        write_config_param "HTMLY_TITLE" "$HTMLY_TITLE"
157
+        write_config_param "HYMLY_DOMAIN_NAME" "$HYMLY_DOMAIN_NAME"
158
+    else
159
+        function_check interactive_site_details_with_title
160
+        interactive_site_details_with_title "htmly" "HTMLY_TITLE" "HYMLY_DOMAIN_NAME" "HYMLY_CODE"
161
+    fi
162
+    APP_INSTALLED=1
163
+}
164
+
165
+function change_password_htmly {
166
+    if ! grep -q "htmly domain:" $COMPLETION_FILE; then
167
+        echo "htmly domain:$HYMLY_DOMAIN_NAME" >> $COMPLETION_FILE
168
+    fi
169
+    HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | head -n 1 | awk -F ':' '{print $2}')
170
+
171
+    HTMLY_USERNAME="$1"
172
+    HTMLY_PASSWORD="$2"
173
+    if [ ${#HTMLY_PASSWORD} -lt 8 ]; then
174
+        echo $'Htmly password is too short'
175
+        return
176
+    fi
177
+    HTMLY_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$HTMLY_PASSWORD")
178
+    if [ ${#HTMLY_PASSWORD_HASH} -lt 8 ]; then
179
+        echo $'Htmly admin password could not be hashed'
180
+        exit 625728
181
+    fi
182
+    sed -i "s|password =.*|password = $HTMLY_PASSWORD_HASH|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$HTMLY_USERNAME.ini
183
+}
184
+
185
+function reconfigure_htmly {
186
+    echo -n ''
187
+}
188
+
189
+function upgrade_htmly {
190
+    read_config_param "HYMLY_DOMAIN_NAME"
191
+
192
+    function_check set_repo_commit
193
+    set_repo_commit /var/www/$HYMLY_DOMAIN_NAME/htdocs "htmly commit" "$HYMLY_COMMIT" $HYMLY_REPO
194
+}
195
+
196
+function backup_local_htmly {
197
+    HYMLY_DOMAIN_NAME='htmly'
198
+    if grep -q "htmly domain" $COMPLETION_FILE; then
199
+        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
200
+    fi
201
+
202
+    source_directory=/var/www/${HYMLY_DOMAIN_NAME}/htdocs
203
+    if [ -d $source_directory ]; then
204
+        dest_directory=htmly
205
+        echo $"Backing up $source_directory to $dest_directory"
206
+
207
+        function_check suspend_site
208
+        suspend_site ${HYMLY_DOMAIN_NAME}
209
+
210
+        function_check backup_directory_to_usb
211
+        backup_directory_to_usb $source_directory $dest_directory
212
+
213
+        function_check restart_site
214
+        restart_site
215
+
216
+        echo $"Backup to $dest_directory complete"
217
+    fi
218
+}
219
+
220
+function restore_local_htmly {
221
+    HYMLY_DOMAIN_NAME='htmly'
222
+    if grep -q "htmly domain" $COMPLETION_FILE; then
223
+        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
224
+    fi
225
+    if [ $HYMLY_DOMAIN_NAME ]; then
226
+        echo $"Restoring htmly installation"
227
+        temp_restore_dir=/root/temphtmly
228
+        restore_directory_from_usb $temp_restore_dir htmly
229
+        rm -rf /var/www/${HYMLY_DOMAIN_NAME}/htdocs
230
+        cp -r $temp_restore_dir/var/www/${HYMLY_DOMAIN_NAME}/htdocs /var/www/${HYMLY_DOMAIN_NAME}/
231
+        if [ ! "$?" = "0" ]; then
232
+            set_user_permissions
233
+            backup_unmount_drive
234
+            exit 593
235
+        fi
236
+        rm -rf $temp_restore_dir
237
+        if [ ! -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content ]; then
238
+            echo $"No content directory found after restoring htmly"
239
+            set_user_permissions
240
+            backup_unmount_drive
241
+            exit 287
242
+        fi
243
+        chown -R www-data:www-data /var/www/${HYMLY_DOMAIN_NAME}/htdocs
244
+        # Ensure that the bundled SSL cert is being used
245
+        if [ -f /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.bundle.crt ]; then
246
+            sed -i "s|${HYMLY_DOMAIN_NAME}.crt|${HYMLY_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${HYMLY_DOMAIN_NAME}
247
+        fi
248
+        for d in /home/*/ ; do
249
+            USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
250
+            if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
251
+                if [ -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post ]; then
252
+                    mv /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/*.md /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post
253
+                fi
254
+            fi
255
+        done
256
+        if [ -d /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME} ]; then
257
+            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${HYMLY_DOMAIN_NAME}.key
258
+            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.pem
259
+        fi
260
+    fi
261
+}
262
+
263
+function backup_remote_htmly {
264
+    if grep -q "htmly domain" $COMPLETION_FILE; then
265
+        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
266
+        temp_backup_dir=/var/www/${HYMLY_DOMAIN_NAME}/htdocs
267
+        if [ -d $temp_backup_dir ]; then
268
+            echo $"Backing up htmly"
269
+            backup_directory_to_friend $temp_backup_dir htmly
270
+            echo $"Backup of htmly complete"
271
+        else
272
+            echo $"Htmly domain specified but not found in $temp_backup_dir"
273
+            exit 2578
274
+        fi
275
+    fi
276
+}
277
+
278
+function restore_remote_htmly {
279
+    if [ -d $SERVER_DIRECTORY/backup/htmly ]; then
280
+        HYMLY_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "htmly domain" | awk -F ':' '{print $2}')
281
+        echo $"Restoring htmly installation $HYMLY_DOMAIN_NAME"
282
+        temp_restore_dir=/root/temphtmly
283
+        mkdir $temp_restore_dir
284
+        function_check restore_directory_from_friend
285
+        restore_directory_from_friend $temp_restore_dir htmly
286
+        rm -rf /var/www/${HYMLY_DOMAIN_NAME}/htdocs
287
+        cp -r $temp_restore_dir/var/www/${HYMLY_DOMAIN_NAME}/htdocs /var/www/${HYMLY_DOMAIN_NAME}/
288
+        if [ ! "$?" = "0" ]; then
289
+            exit 593
290
+        fi
291
+        rm -rf $temp_restore_dir
292
+        if [ ! -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content ]; then
293
+            echo $"No content directory found after restoring htmly"
294
+            exit 287
295
+        fi
296
+        # Ensure that the bundled SSL cert is being used
297
+        if [ -f /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.bundle.crt ]; then
298
+            sed -i "s|${HYMLY_DOMAIN_NAME}.crt|${HYMLY_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${HYMLY_DOMAIN_NAME}
299
+        fi
300
+        for d in /home/*/ ; do
301
+            USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
302
+            if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
303
+                if [ -d /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post ]; then
304
+                    mv /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/*.md /var/www/${HYMLY_DOMAIN_NAME}/htdocs/content/$USERNAME/htmly/uncategorized/post
305
+                fi
306
+            fi
307
+        done
308
+        if [ -d /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME} ]; then
309
+            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${HYMLY_DOMAIN_NAME}.key
310
+            ln -s /etc/letsencrypt/live/${HYMLY_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${HYMLY_DOMAIN_NAME}.pem
311
+        fi
312
+        echo $"Restore of htmly complete"
313
+    fi
314
+}
315
+
316
+function remove_htmly {
317
+    if [ ${#HYMLY_DOMAIN_NAME} -eq 0 ]; then
318
+        return
319
+    fi
320
+
321
+    read_config_param "HYMLY_DOMAIN_NAME"
322
+    nginx_dissite $HYMLY_DOMAIN_NAME
323
+    if [ -f /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME ]; then
324
+        rm -f /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
325
+    fi
326
+    if [ -d /var/www/$HYMLY_DOMAIN_NAME ]; then
327
+        rm -rf /var/www/$HYMLY_DOMAIN_NAME
328
+    fi
329
+    if [ $HYMLY_CODE ]; then
330
+        if [ -f /usr/bin/dynamicdns ]; then
331
+            sed -i "/$HYMLY_DOMAIN_NAME/d" /usr/bin/dynamicdns
332
+            sed -i "/$HYMLY_CODE/d" /usr/bin/dynamicdns
333
+        fi
334
+    fi
335
+    function_check remove_onion_service
336
+    remove_onion_service htmly ${HYMLY_ONION_PORT}
337
+    sed -i '/install_htmly/d' $COMPLETION_FILE
338
+    sed -i '/Htmly .*/d' $COMPLETION_FILE
339
+}
340
+
341
+function get_htmly_admin_password {
342
+    if [ -f /home/$MY_USERNAME/README ]; then
343
+        if grep -q "Your htmly password is" /home/$MY_USERNAME/README; then
344
+            HYMLY_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Your htmly password is" | awk -F ':' '{print $2}' | sed 's/^ *//')
345
+        fi
346
+    fi
347
+}
348
+
349
+function install_htmly_social_networks {
350
+    # set social networks
351
+    if grep -q "social.hubzilla" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini; then
352
+        sed -i "s|;social.hubzilla|social.hubzilla|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
353
+        sed -i "s|social.hubzilla.*|social.hubzilla = \"$HUBZILLA_DOMAIN_NAME\"|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
354
+    fi
355
+    if grep -q "social.gnusocial" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini; then
356
+        sed -i "s|;social.gnusocial|social.gnusocial|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
357
+        sed -i "s|social.gnusocial.*|social.gnusocial = \"$MICROHTMLY_DOMAIN_NAME\"|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
358
+    fi
359
+
360
+    # clear proprietary social network strings
361
+    sed -i 's|social.facebook.*|social.facebook = ""|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
362
+    sed -i 's|social.twitter.*|social.twitter = ""|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
363
+    sed -i 's|social.google.*|social.google = ""|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
364
+}
365
+
366
+function install_htmly_user {
367
+    # create a user password
368
+    function_check get_htmly_admin_password
369
+    get_htmly_admin_password
370
+    if [ ! $HYMLY_ADMIN_PASSWORD ]; then
371
+        if [ -f $IMAGE_PASSWORD_FILE ]; then
372
+            HYMLY_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
373
+        else
374
+            HYMLY_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
375
+        fi
376
+        echo '' >> /home/$MY_USERNAME/README
377
+        echo '' >> /home/$MY_USERNAME/README
378
+        echo $'HTMLy Htmly' >> /home/$MY_USERNAME/README
379
+        echo '==========' >> /home/$MY_USERNAME/README
380
+        echo $"Your htmly username: $MY_USERNAME" >> /home/$MY_USERNAME/README
381
+        echo $"Your htmly password is: $HYMLY_ADMIN_PASSWORD" >> /home/$MY_USERNAME/README
382
+        if [[ $ONION_ONLY == 'no' ]]; then
383
+            echo $"Log into your htmly at https://$HYMLY_DOMAIN_NAME/login" >> /home/$MY_USERNAME/README
384
+        fi
385
+        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
386
+        chmod 600 /home/$MY_USERNAME/README
387
+    fi
388
+
389
+    # create a user
390
+    HYMLY_ADMIN_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$HYMLY_ADMIN_PASSWORD")
391
+    if [ ${#HYMLY_ADMIN_PASSWORD_HASH} -lt 8 ]; then
392
+        echo $'Htmly admin password could not be hashed'
393
+        exit 625728
394
+    fi
395
+    echo ';Password' > /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
396
+    echo "password = $HYMLY_ADMIN_PASSWORD_HASH" >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
397
+    echo 'encryption = password_hash' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
398
+    echo ';Role' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
399
+    echo 'role = admin' >> /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
400
+}
401
+
402
+function install_htmly_settings {
403
+    cp /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini.example /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
404
+    sed -i "s|site.url.*|site.url = '/'|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
405
+    sed -i "s|htmly.title.*|htmly.title = '$HTMLY_TITLE'|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
406
+    sed -i "s|htmly.tagline.*|htmly.tagline = '$HTMLY_SUBTITLE'|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
407
+    sed -i 's|timezone.*|timezone = "Europe/London"|g' /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
408
+    sed -i "s|Your name|$MY_NAME|g" /var/www/$HYMLY_DOMAIN_NAME/htdocs/config/config.ini
409
+}
410
+
411
+function install_htmly_website {
412
+    function_check nginx_http_redirect
413
+    nginx_http_redirect $HYMLY_DOMAIN_NAME
414
+    echo 'server {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
415
+    echo '    listen 443 ssl;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
416
+    echo "    root /var/www/$HYMLY_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
417
+    echo "    server_name $HYMLY_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
418
+    echo '    access_log off;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
419
+    echo "    error_log /var/log/nginx/${HYMLY_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
420
+    echo '    index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
421
+    echo '    charset utf-8;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
422
+    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
423
+    function_check nginx_ssl
424
+    nginx_ssl $HYMLY_DOMAIN_NAME
425
+    function_check nginx_disable_sniffing
426
+    nginx_disable_sniffing $HYMLY_DOMAIN_NAME
427
+    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
428
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
429
+    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
430
+    echo '    location / {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
431
+    function_check nginx_limits
432
+    nginx_limits $HYMLY_DOMAIN_NAME
433
+    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
434
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
435
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
436
+    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
437
+    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
438
+    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
439
+    echo '        allow all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
440
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
441
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
442
+    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
443
+    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
444
+    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
445
+    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
446
+    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
447
+    echo '        expires 30d;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
448
+    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
449
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
450
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
451
+    echo '    # block these file types' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
452
+    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
453
+    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
454
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
455
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
456
+    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
457
+    echo '    # or a unix socket' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
458
+    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
459
+    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
460
+    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
461
+    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
462
+    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
463
+    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
464
+    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
465
+    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
466
+    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
467
+    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
468
+    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
469
+    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
470
+    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
471
+    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
472
+    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
473
+    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
474
+    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
475
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
476
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
477
+    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
478
+    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
479
+    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
480
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
481
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
482
+    echo '    #deny access to store' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
483
+    echo '    location ~ /store {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
484
+    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
485
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
486
+    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
487
+    echo '      deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
488
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
489
+    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
490
+    echo '      deny  all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
491
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
492
+    echo '}' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
493
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
494
+}
495
+
496
+function install_htmly_website_onion {
497
+    echo 'server {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
498
+    echo "    listen 127.0.0.1:${HYMLY_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
499
+    echo "    root /var/www/$HYMLY_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
500
+    echo "    server_name $HYMLY_DOMAIN_NAME;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
501
+    echo '    access_log off;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
502
+    echo "    error_log /var/log/nginx/${HYMLY_DOMAIN_NAME}_error_ssl.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
503
+    echo '    index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
504
+    echo '    charset utf-8;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
505
+    echo '    proxy_read_timeout 86400s;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
506
+    function_check nginx_disable_sniffing
507
+    nginx_disable_sniffing $HYMLY_DOMAIN_NAME
508
+    echo '    add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
509
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
510
+    echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
511
+    echo '    location / {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
512
+    function_check nginx_limits
513
+    nginx_limits $HYMLY_DOMAIN_NAME
514
+    echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
515
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
516
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
517
+    echo "    # make sure webfinger and other well known services aren't blocked" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
518
+    echo '    # by denying dot files and rewrite request to the front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
519
+    echo '    location ^~ /.well-known/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
520
+    echo '        allow all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
521
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
522
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
523
+    echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
524
+    echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
525
+    echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
526
+    echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
527
+    echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
528
+    echo '        expires 30d;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
529
+    echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
530
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
531
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
532
+    echo '    # block these file types' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
533
+    echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
534
+    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
535
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
536
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
537
+    echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
538
+    echo '    # or a unix socket' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
539
+    echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
540
+    function_check nginx_limits
541
+    nginx_limits $HYMLY_DOMAIN_NAME
542
+    echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
543
+    echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
544
+    echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
545
+    echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
546
+    echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
547
+    echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
548
+    echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
549
+    echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
550
+    echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
551
+    echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
552
+    echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
553
+    echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
554
+    echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
555
+    echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
556
+    echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
557
+    echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
558
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
559
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
560
+    echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
561
+    echo '    location ~ /\. {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
562
+    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
563
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
564
+    echo '' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
565
+    echo '    #deny access to store' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
566
+    echo '    location ~ /store {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
567
+    echo '        deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
568
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
569
+    echo '    location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
570
+    echo '      deny all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
571
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
572
+    echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
573
+    echo '      deny  all;' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
574
+    echo '    }' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
575
+    echo '}' >> /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
576
+}
577
+
578
+function install_htmly_from_repo {
579
+    if [ ! -d /var/www/$HYMLY_DOMAIN_NAME ]; then
580
+        mkdir /var/www/$HYMLY_DOMAIN_NAME
581
+    fi
582
+
583
+    cd /var/www/$HYMLY_DOMAIN_NAME
584
+    git_clone $HYMLY_REPO htdocs
585
+    cd htdocs
586
+    git checkout $HYMLY_COMMIT -b $HYMLY_COMMIT
587
+    if ! grep -q "htmly commit" $COMPLETION_FILE; then
588
+        echo "htmly commit:$HYMLY_COMMIT" >> $COMPLETION_FILE
589
+    else
590
+        sed -i "s/htmly commit.*/htmly commit:$HYMLY_COMMIT/g" $COMPLETION_FILE
591
+    fi
592
+}
593
+
594
+function install_htmly {
595
+    if [ ! $ONION_ONLY ]; then
596
+        ONION_ONLY='no'
597
+    fi
598
+
599
+    if [ ! $HYMLY_DOMAIN_NAME ]; then
600
+        echo $'The htmly domain name was not specified'
601
+        exit 5062
602
+    fi
603
+
604
+    # for the avatar changing command
605
+    apt-get -y install imagemagick
606
+
607
+    function_check install_htmly_from_repo
608
+    install_htmly_from_repo
609
+
610
+    if [[ $ONION_ONLY == "no" ]]; then
611
+        function_check install_htmly_website
612
+        install_htmly_website
613
+    else
614
+        echo -n '' > /etc/nginx/sites-available/$HYMLY_DOMAIN_NAME
615
+    fi
616
+    function_check install_htmly_website_onion
617
+    install_htmly_website_onion
618
+
619
+    function_check create_site_certificate
620
+    create_site_certificate $HYMLY_DOMAIN_NAME 'yes'
621
+
622
+    function_check configure_php
623
+    configure_php
624
+
625
+    function_check install_htmly_settings
626
+    install_htmly_settings
627
+
628
+    function_check install_htmly_social_networks
629
+    install_htmly_social_networks
630
+
631
+    function_check install_htmly_user
632
+    install_htmly_user
633
+
634
+    chown -R www-data:www-data /var/www/$HYMLY_DOMAIN_NAME/htdocs
635
+
636
+    HYMLY_ONION_HOSTNAME=$(add_onion_service htmly 80 ${HYMLY_ONION_PORT})
637
+
638
+    function_check nginx_ensite
639
+    nginx_ensite $HYMLY_DOMAIN_NAME
640
+
641
+    systemctl restart php5-fpm
642
+    systemctl restart nginx
643
+
644
+    if ! grep -q "Htmly onion domain" /home/$MY_USERNAME/README; then
645
+        echo $"Htmly onion domain: ${HYMLY_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
646
+        echo $"Log into your htmly at https://${HYMLY_ONION_HOSTNAME}/login" >> /home/$MY_USERNAME/README
647
+        echo '' >> /home/$MY_USERNAME/README
648
+        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
649
+        chmod 600 /home/$MY_USERNAME/README
650
+    fi
651
+
652
+    function_check add_ddns_domain
653
+    add_ddns_domain $HYMLY_DOMAIN_NAME
654
+
655
+    if ! grep -q "htmly domain:" $COMPLETION_FILE; then
656
+        echo "htmly domain:$HYMLY_DOMAIN_NAME" >> $COMPLETION_FILE
657
+    fi
658
+    APP_INSTALLED=1
659
+}
660
+
661
+# NOTE: deliberately no exit 0

+ 0
- 163
src/freedombone-blog ファイルの表示

@@ -1,163 +0,0 @@
1
-#!/bin/bash
2
-#
3
-# .---.                  .              .
4
-# |                      |              |
5
-# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
-# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
-# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
-#
9
-#                    Freedom in the Cloud
10
-#
11
-# Blogging functions
12
-
13
-# License
14
-# =======
15
-#
16
-# Copyright (C) 2016 Bob Mottram <bob@robotics.uk.to>
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
-
31
-PROJECT_NAME='freedombone'
32
-
33
-export TEXTDOMAIN=${PROJECT_NAME}-blog
34
-export TEXTDOMAINDIR="/usr/share/locale"
35
-
36
-CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
37
-
38
-UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
39
-for f in $UTILS_FILES
40
-do
41
-  source $f
42
-done
43
-
44
-AVATAR=
45
-
46
-# get the blog hostname
47
-read_config_param "FULLBLOG_DOMAIN_NAME"
48
-HOSTNAME=$FULLBLOG_DOMAIN_NAME
49
-
50
-BASE_DIR=/var/www/$HOSTNAME/htdocs
51
-
52
-function show_help {
53
-    echo ''
54
-    echo $"${PROJECT_NAME}-blog -h [hostname] -a [avatar image file]"
55
-    echo ''
56
-    echo $'Blogging functions'
57
-    echo ''
58
-    echo $'     --help                     Show help'
59
-    echo $'  -h --hostname [name]          Hostname'
60
-    echo $'  -a --avatar [url]             Filename or url for avatar'
61
-    echo ''
62
-    exit 0
63
-}
64
-
65
-while [[ $# > 1 ]]
66
-do
67
-    key="$1"
68
-
69
-    case $key in
70
-        --help)
71
-            show_help
72
-            ;;
73
-        -h|--hostname)
74
-            shift
75
-            HOSTNAME="$1"
76
-            ;;
77
-        -a|--avatar)
78
-            shift
79
-            AVATAR="$1"
80
-            ;;
81
-        *)
82
-            # unknown option
83
-            ;;
84
-    esac
85
-    shift
86
-done
87
-
88
-if [ ! $HOSTNAME ]; then
89
-    echo $'No hostname specified'
90
-    exit 5748
91
-fi
92
-
93
-if [ ! -d $BASE_DIR ]; then
94
-    echo "$BASE_DIR was not found"
95
-    exit 1
96
-fi
97
-
98
-function set_avatar_from_file {
99
-    SOURCE_IMAGE_FILE="$1"
100
-
101
-    if [ ! -f $SOURCE_IMAGE_FILE ]; then
102
-        echo $'Source file not found'
103
-        exit 2
104
-    fi
105
-
106
-    # copy the source image
107
-    cd $BASE_DIR
108
-    AVATAR_FILES=$(find . -name avatar.png)
109
-    read -a arr <<<$AVATAR_FILES
110
-
111
-    for i in "${arr[@]}"
112
-    do
113
-        FILENAME="$BASE_DIR$(echo \"$i\" | awk -F '.' '{print $2}')".png
114
-        if [[ "$FILENAME" != "$SOURCE_IMAGE_FILE" ]]; then
115
-            cp -f $SOURCE_IMAGE_FILE "$FILENAME"
116
-        fi
117
-    done
118
-}
119
-
120
-function set_avatar_from_url {
121
-    if [ ! -d $BASE_DIR/customimages ]; then
122
-        mkdir $BASE_DIR/customimages
123
-    fi
124
-
125
-    # download the image
126
-    cd $BASE_DIR/customimages
127
-    # convert to png
128
-    wget $AVATAR -O avatar
129
-    if [[ $AVATAR == *".gif" ]]; then
130
-        mv avatar avatar.gif
131
-        mogrify -format png avatar.gif
132
-    fi
133
-    if [[ $AVATAR == *".jpg" ]]; then
134
-        mv avatar avatar.jpg
135
-        mogrify -format png avatar.jpg
136
-    fi
137
-    if [[ $AVATAR == *".jpeg" ]]; then
138
-        mv avatar avatar.jpeg
139
-        mogrify -format png avatar.jpeg
140
-    fi
141
-    if [ -f avatar ]; then
142
-        mv avatar avatar.png
143
-    fi
144
-
145
-    # standard size
146
-    mogrify -resize 150x150 avatar.png
147
-    if [ ! -f $BASE_DIR/customimages/avatar.png ]; then
148
-        echo $'Avatar image could not be downloaded'
149
-        exit 3
150
-    fi
151
-    chown -R www-data:www-data $BASE_DIR/customimages
152
-}
153
-
154
-if [[ "$AVATAR" == "http"* ]]; then
155
-    set_avatar_from_url
156
-fi
157
-
158
-AVATAR=$BASE_DIR/customimages/avatar.png
159
-if [ -f $AVATAR ]; then
160
-    set_avatar_from_file $AVATAR
161
-fi
162
-
163
-exit 0

+ 3
- 3
src/freedombone-config ファイルの表示

@@ -67,9 +67,9 @@ NAMESERVER2=
67 67
 DOKUWIKI_TITLE=
68 68
 DOKUWIKI_DOMAIN_NAME=
69 69
 DOKUWIKI_CODE=
70
-MY_BLOG_TITLE=
71
-FULLBLOG_DOMAIN_NAME=
72
-FULLBLOG_CODE=
70
+HTMLY_TITLE=
71
+HTMLY_DOMAIN_NAME=
72
+HTMLY_CODE=
73 73
 MEDIAGOBLIN_ENABLED='no'
74 74
 MEDIAGOBLIN_DOMAIN_NAME=
75 75
 MEDIAGOBLIN_CODE=

+ 24
- 24
src/freedombone-sec ファイルの表示

@@ -990,21 +990,21 @@ function monkeysphere_sign_server_keys {
990 990
     exit 0
991 991
 }
992 992
 
993
-function blog_hash {
994
-    # produces a hash corresponding to a blog password
993
+function htmly_hash {
994
+    # produces a hash corresponding to a htmly password
995 995
     pass="$1"
996
-    BLOGHASH_FILENAME=/usr/bin/bloghash
997
-
998
-    echo '<?php' > $BLOGHASH_FILENAME
999
-    echo 'parse_str(implode("&", array_slice($argv, 1)), $_GET);' >> $BLOGHASH_FILENAME
1000
-    echo '$password = $_GET["password"];' >> $BLOGHASH_FILENAME
1001
-    echo '$hash = password_hash($password, PASSWORD_BCRYPT);' >> $BLOGHASH_FILENAME
1002
-    echo 'if (password_verify($password, $hash)) {' >> $BLOGHASH_FILENAME
1003
-    echo '  echo $hash;' >> $BLOGHASH_FILENAME
1004
-    echo '}' >> $BLOGHASH_FILENAME
1005
-    echo '?>' >> $BLOGHASH_FILENAME
1006
-
1007
-    php $BLOGHASH_FILENAME password="$pass"
996
+    HTMLYHASH_FILENAME=/usr/bin/htmlyhash
997
+
998
+    echo '<?php' > $HTMLYHASH_FILENAME
999
+    echo 'parse_str(implode("&", array_slice($argv, 1)), $_GET);' >> $HTMLYHASH_FILENAME
1000
+    echo '$password = $_GET["password"];' >> $HTMLYHASH_FILENAME
1001
+    echo '$hash = password_hash($password, PASSWORD_BCRYPT);' >> $HTMLYHASH_FILENAME
1002
+    echo 'if (password_verify($password, $hash)) {' >> $HTMLYHASH_FILENAME
1003
+    echo '  echo $hash;' >> $HTMLYHASH_FILENAME
1004
+    echo '}' >> $HTMLYHASH_FILENAME
1005
+    echo '?>' >> $HTMLYHASH_FILENAME
1006
+
1007
+    php $HTMLYHASH_FILENAME password="$pass"
1008 1008
 }
1009 1009
 
1010 1010
 function show_help {
@@ -1014,13 +1014,13 @@ function show_help {
1014 1014
     echo $'Alters the security settings'
1015 1015
     echo ''
1016 1016
     echo ''
1017
-    echo $'  -h --help                Show help'
1018
-    echo $'  -e --export              Export security settings to a file'
1019
-    echo $'  -i --import              Import security settings from a file'
1020
-    echo $'  -r --refresh             Refresh GPG keys for all users'
1021
-    echo $'  -s --sign                Sign monkeysphere server keys'
1022
-    echo $'     --register [domain]   Register a https domain with monkeysphere'
1023
-    echo $'  -b --bloghash [password] Returns the hash of a password for the blog'
1017
+    echo $'  -h --help                 Show help'
1018
+    echo $'  -e --export               Export security settings to a file'
1019
+    echo $'  -i --import               Import security settings from a file'
1020
+    echo $'  -r --refresh              Refresh GPG keys for all users'
1021
+    echo $'  -s --sign                 Sign monkeysphere server keys'
1022
+    echo $'     --register [domain]    Register a https domain with monkeysphere'
1023
+    echo $'  -b --htmlyhash [password] Returns the hash of a password for a htmly blog'
1024 1024
     echo ''
1025 1025
     exit 0
1026 1026
 }
@@ -1060,10 +1060,10 @@ do
1060 1060
             shift
1061 1061
             monkeysphere_sign_server_keys
1062 1062
             ;;
1063
-        # get a hash of the given blog password
1064
-        -b|--bloghash)
1063
+        # get a hash of the given htmly password
1064
+        -b|--htmlyhash)
1065 1065
             shift
1066
-            blog_hash "$1"
1066
+            htmly_hash "$1"
1067 1067
             exit 0
1068 1068
             ;;
1069 1069
         *)

+ 3
- 3
src/freedombone-utils-onion ファイルの表示

@@ -126,7 +126,7 @@ function set_default_onion_domains {
126 126
     fi
127 127
 
128 128
     MICROBLOG_DOMAIN_NAME='microblog.local'
129
-    FULLBLOG_DOMAIN_NAME='blog.local'
129
+    HTMLY_DOMAIN_NAME='htmly.local'
130 130
     DOKUWIKI_DOMAIN_NAME='dokuwiki.local'
131 131
     DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local"
132 132
     GIT_DOMAIN_NAME='git.local'
@@ -144,9 +144,9 @@ function create_avahi_onion_domains {
144 144
         function_check create_avahi_service
145 145
         create_avahi_service microblog http tcp $MICROBLOG_ONION_PORT
146 146
     fi
147
-    if [ $FULLBLOG_DOMAIN_NAME ]; then
147
+    if [ $HTMLY_DOMAIN_NAME ]; then
148 148
         function_check create_avahi_service
149
-        create_avahi_service blog http tcp $BLOG_ONION_PORT
149
+        create_avahi_service blog http tcp $HTMLY_ONION_PORT
150 150
     fi
151 151
     if [ $GIT_DOMAIN_NAME ]; then
152 152
         function_check create_avahi_service

+ 1
- 1
src/freedombone-utils-upgrade ファイルの表示

@@ -72,7 +72,7 @@ function upgrade_installation_from_previous_versions {
72 72
     sed -i 's|voip|mumble|g' $COMPLETION_FILE
73 73
     sed -i 's|VoIP|mumble|g' $COMPLETION_FILE
74 74
     sed -i 's|SIP |sip |g' $COMPLETION_FILE
75
-    sed -i 's|Blog|blog|g' $COMPLETION_FILE
75
+    sed -i 's|Blog|htmly|g' $COMPLETION_FILE
76 76
     sed -i 's|Hubzilla|hubzilla|g' $COMPLETION_FILE
77 77
     sed -i 's|Gogs|gogs|g' $COMPLETION_FILE
78 78
     sed -i 's|Wiki|dokuwiki|g' $COMPLETION_FILE