Procházet zdrojové kódy

Beginning of wekan

Bob Mottram před 7 roky
rodič
revize
812f5de7f2

+ 2
- 2
src/freedombone-app-gogs Zobrazit soubor

@@ -139,7 +139,7 @@ function gogs_create_database {
139 139
     fi
140 140
 
141 141
     function_check create_database
142
-    create_database gogs "$GOGS_ADMIN_PASSWORD"
142
+    create_database gogs "$GIT_ADMIN_PASSWORD"
143 143
 }
144 144
 
145 145
 function reconfigure_gogs {
@@ -302,7 +302,7 @@ function backup_remote_gogs {
302 302
         suspend_site ${GIT_DOMAIN_NAME}
303 303
 
304 304
         function_check backup_database_to_friend
305
-        backup_database_to_friend $GOGS_USERNAME
305
+        backup_database_to_friend gogs
306 306
 
307 307
         echo $"Obtaining Gogs settings backup"
308 308
 

+ 494
- 0
src/freedombone-app-wekan Zobrazit soubor

@@ -0,0 +1,494 @@
1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Wekan kanban
12
+#
13
+# License
14
+# =======
15
+#
16
+# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
17
+#
18
+# This program is free software: you can redistribute it and/or modify
19
+# it under the terms of the GNU Affero General Public License as published by
20
+# the Free Software Foundation, either version 3 of the License, or
21
+# (at your option) any later version.
22
+#
23
+# This program is distributed in the hope that it will be useful,
24
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
+# GNU Affero General Public License for more details.
27
+#
28
+# You should have received a copy of the GNU Affero General Public License
29
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30
+
31
+VARIANTS=''
32
+
33
+IN_DEFAULT_INSTALL=0
34
+SHOW_ON_ABOUT=0
35
+
36
+WEKAN_DOMAIN_NAME=
37
+WEKAN_CODE=
38
+WEKAN_PORT=8081
39
+WEKAN_ONION_PORT=8120
40
+WEKAN_REPO="https://github.com/wekan/wekan"
41
+WEKAN_COMMIT='dc547c38d1f5ca72729f6d8f81eb03671ca15934'
42
+FLOW_ROUTER_REPO="git://github.com/wekan/flow-router.git"
43
+FLOW_ROUTER_COMMIT='0c1f6423ed9b68eb00cfb1a19492438917a38956'
44
+WEKAN_DIR=/etc/wekan
45
+
46
+wekan_variables=(ONION_ONLY
47
+                 WEKAN_DOMAIN_NAME
48
+                 WEKAN_CODE
49
+                 DDNS_PROVIDER
50
+                 MY_USERNAME)
51
+
52
+function logging_on_wekan {
53
+    echo -n ''
54
+}
55
+
56
+function logging_off_wekan {
57
+    echo -n ''
58
+}
59
+
60
+function remove_user_wekan {
61
+    remove_username="$1"
62
+}
63
+
64
+function add_user_wekan {
65
+    new_username="$1"
66
+    new_user_password="$2"
67
+    echo '0'
68
+}
69
+
70
+function install_interactive_wekan {
71
+    if [[ $ONION_ONLY != "no" ]]; then
72
+        GIT_DOMAIN_NAME='wekan.local'
73
+        write_config_param "WEKAN_DOMAIN_NAME" "$WEKAN_DOMAIN_NAME"
74
+    else
75
+        function_check interactive_site_details
76
+        interactive_site_details wekan
77
+    fi
78
+    APP_INSTALLED=1
79
+}
80
+
81
+function change_password_wekan {
82
+    curr_username="$1"
83
+    new_user_password="$2"
84
+}
85
+
86
+function reconfigure_wekan {
87
+    echo -n ''
88
+}
89
+
90
+function upgrade_wekan {
91
+    CURR_WEKAN_COMMIT=$(get_completion_param "wekan commit")
92
+    if [[ "$CURR_WEKAN_COMMIT" == "$WEKAN_COMMIT" ]]; then
93
+        return
94
+    fi
95
+
96
+    systemctl stop wekan
97
+
98
+    # update to the next commit
99
+    function_check set_repo_commit
100
+    set_repo_commit $WEKAN_DIR "wekan commit" "$WEKAN_COMMIT" $WEKAN_REPO
101
+
102
+    systemctl start wekan
103
+}
104
+
105
+function backup_local_wekan {
106
+    source_directory=$WEKAN_DIR/data
107
+    if [ -d $source_directory ]; then
108
+        systemctl stop wekan
109
+
110
+        dest_directory=wekan
111
+        function_check suspend_site
112
+        suspend_site wekan
113
+
114
+        function_check backup_database_to_usb
115
+        backup_database_to_usb wekan
116
+
117
+        function_check backup_directory_to_usb
118
+        backup_directory_to_usb $source_directory $dest_directory
119
+
120
+        function_check restart_site
121
+        restart_site
122
+
123
+        systemctl start wekan
124
+    fi
125
+}
126
+
127
+function restore_local_wekan {
128
+    if [ -d $WEKAN_DIR ]; then
129
+        systemctl stop wekan
130
+
131
+        function_check restore_database
132
+        restore_database gogs ${WEKAN_DOMAIN_NAME}
133
+
134
+        temp_restore_dir=/root/tempwekan
135
+        function_check restore_directory_from_usb
136
+        restore_directory_from_usb $temp_restore_dir wekan
137
+        cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
138
+
139
+        systemctl start wekan
140
+    fi
141
+}
142
+
143
+function backup_remote_wekan {
144
+    if grep -q "wekan domain" $COMPLETION_FILE; then
145
+        temp_backup_dir=$WEKAN_DIR/data
146
+        if [ -d $temp_backup_dir ]; then
147
+            systemctl stop wekan
148
+
149
+            function_check suspend_site
150
+            suspend_site wekan
151
+
152
+            echo $"Backing up Wekan installation"
153
+
154
+            function_check backup_database_to_friend
155
+            backup_database_to_friend wekan
156
+
157
+            function_check backup_directory_to_friend
158
+            backup_directory_to_friend $temp_backup_dir wekan
159
+
160
+            function_check restart_site
161
+            restart_site
162
+
163
+            systemctl start wekan
164
+        else
165
+            echo $"wekan domain specified but not found in ${temp_backup_dir}"
166
+        fi
167
+    fi
168
+}
169
+
170
+function restore_remote_wekan {
171
+    if [ -d $WEKAN_DIR ]; then
172
+        systemctl stop wekan
173
+
174
+        function_check restore_database_from_friend
175
+        restore_database_from_friend wekan
176
+
177
+        temp_restore_dir=/root/tempwekan
178
+        function_check restore_directory_from_usb
179
+        restore_directory_from_friend $temp_restore_dir wekan
180
+        cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
181
+
182
+        systemctl start wekan
183
+    fi
184
+}
185
+
186
+function remove_wekan {
187
+    systemctl stop wekan
188
+    systemctl disable wekan
189
+    if [ -f /etc/systemd/system/wekan.service ]; then
190
+        rm /etc/systemd/system/wekan.service
191
+    fi
192
+    systemctl daemon-reload
193
+
194
+    function_check remove_nodejs
195
+    remove_nodejs wekan
196
+
197
+    nginx_dissite wekan
198
+
199
+    if [ -d $WEKAN_DIR ]; then
200
+        rm -rf $WEKAN_DIR
201
+    fi
202
+    if [ -f /etc/nginx/sites-available/wekan ]; then
203
+        rm /etc/nginx/sites-available/wekan
204
+    fi
205
+    function_check drop_database
206
+    drop_database wekan
207
+    function_check remove_onion_service
208
+    remove_onion_service wekan ${WEKAN_ONION_PORT}
209
+    remove_app wekan
210
+    remove_completion_param install_wekan
211
+    sed -i '/wekan/d' $COMPLETION_FILE
212
+
213
+    groupdel -f gogs
214
+    userdel -r wekan
215
+    remove_meteor
216
+}
217
+
218
+function wekan_create_database {
219
+    if [ -f ${IMAGE_PASSWORD_FILE} ]; then
220
+        WEKAN_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
221
+    else
222
+        if [ ! ${GIT_ADMIN_PASSWORD} ]; then
223
+            WEKAN_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
224
+        fi
225
+    fi
226
+    if [ ! $WEKAN_ADMIN_PASSWORD ]; then
227
+        return
228
+    fi
229
+
230
+    function_check create_database
231
+    create_database gogs "$WEKAN_ADMIN_PASSWORD"
232
+}
233
+
234
+function install_wekan_main {
235
+    if [[ $(app_is_installed wekan_main) == "1" ]]; then
236
+        return
237
+    fi
238
+
239
+    if [ ! -d /var/www/wekan ]; then
240
+        mkdir /var/www/wekan
241
+    fi
242
+    if [ -d $WEKAN_DIR ]; then
243
+        rm -rf $WEKAN_DIR
244
+    fi
245
+
246
+    if [ -d /repos/wekan ]; then
247
+        mkdir -p $WEKAN_DIR
248
+        cp -r -p /repos/wekan/. $WEKAN_DIR
249
+        cd $WEKAN_DIR
250
+        git pull
251
+    else
252
+        function_check git_clone
253
+        git_clone $WEKAN_REPO $WEKAN_DIR
254
+    fi
255
+
256
+    if [ ! -d $WEKAN_DIR ]; then
257
+        echo $'Unable to clone wekan repo'
258
+        exit 783251
259
+    fi
260
+
261
+    # an unprivileged user to run as
262
+    useradd -d $WEKAN_DIR/ wekan
263
+    groupadd wekan
264
+
265
+    cd $WEKAN_DIR
266
+    git checkout $WEKAN_COMMIT -b $WEKAN_COMMIT
267
+    set_completion_param "wekan commit" "$WEKAN_COMMIT"
268
+
269
+    chown -R wekan:wekan $WEKAN_DIR
270
+
271
+    WEKAN_ONION_HOSTNAME=$(add_onion_service wekan 80 ${WEKAN_ONION_PORT})
272
+    set_completion_param "wekan onion domain" "$WEKAN_ONION_HOSTNAME"
273
+
274
+    wekan_nginx_site=/etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
275
+    if [[ ${ONION_ONLY} == "no" ]]; then
276
+        function_check nginx_http_redirect
277
+        nginx_http_redirect ${WEKAN_DOMAIN_NAME}
278
+        echo 'server {' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
279
+        echo '    listen 443 ssl;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
280
+        echo '    listen [::]:443 ssl;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
281
+        echo "    root /var/www/${WEKAN_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
282
+        echo "    server_name ${WEKAN_DOMAIN_NAME};" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
283
+        echo '    access_log /dev/null;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
284
+        echo "    error_log /dev/null;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
285
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
286
+        function_check nginx_ssl
287
+        nginx_ssl ${WEKAN_DOMAIN_NAME}
288
+        function_check nginx_disable_sniffing
289
+        nginx_disable_sniffing ${WEKAN_DOMAIN_NAME}
290
+        echo '    add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
291
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
292
+        echo '    location / {' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
293
+        function_check nginx_limits
294
+        nginx_limits ${WEKAN_DOMAIN_NAME} '15m'
295
+        echo "        proxy_pass http://localhost:$WEKAN_PORT;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
296
+        echo '    }' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
297
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
298
+        echo '    fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
299
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
300
+        echo '    error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
301
+        echo '    error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
302
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
303
+        echo '    location = /robots.txt {' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
304
+        echo '        allow all;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
305
+        echo '        log_not_found off;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
306
+        echo '        access_log /dev/null;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
307
+        echo '    }' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
308
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
309
+        nginx_keybase ${WEKAN_DOMAIN_NAME}
310
+        echo '}' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
311
+        echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
312
+    else
313
+        echo -n '' > /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
314
+    fi
315
+    echo 'server {' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
316
+    echo "    listen 127.0.0.1:${WEKAN_ONION_PORT} default_server;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
317
+    echo "    root /var/www/$WEKAN_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
318
+    echo "    server_name $WEKAN_DOMAIN_NAME;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
319
+    echo '    access_log /dev/null;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
320
+    echo "    error_log /dev/null;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
321
+    echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
322
+    function_check nginx_disable_sniffing
323
+    nginx_disable_sniffing ${WEKAN_DOMAIN_NAME}
324
+    echo '    add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
325
+    echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
326
+    echo '    location / {' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
327
+    function_check nginx_limits
328
+    nginx_limits ${WEKAN_DOMAIN_NAME} '15m'
329
+    echo "        proxy_pass http://localhost:$WEKAN_PORT;" >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
330
+    echo '    }' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
331
+    echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
332
+    echo '    fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
333
+    echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
334
+    echo '    error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
335
+    echo '    error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
336
+    echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
337
+    echo '    location = /robots.txt {' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
338
+    echo '        allow all;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
339
+    echo '        log_not_found off;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
340
+    echo '        access_log /dev/null;' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
341
+    echo '    }' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
342
+    echo '' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
343
+    nginx_keybase ${WEKAN_DOMAIN_NAME}
344
+    echo '}' >> /etc/nginx/sites-available/${WEKAN_DOMAIN_NAME}
345
+
346
+    function_check nginx_ensite
347
+    nginx_ensite wekan
348
+
349
+    install_completed wekan_main
350
+}
351
+
352
+function install_wekan {
353
+    apt-get -qy install build-essential c++ capnproto curl
354
+
355
+    function_check install_nodejs
356
+    install_nodejs wekan
357
+
358
+    install_wekan_main
359
+    install_meteor
360
+
361
+    cd $WEKAN_DIR
362
+
363
+    su -c 'npm install babel-runtime' - wekan
364
+    su -c 'npm install node-gyp' - wekan
365
+    su -c 'npm install node-pre-gyp' - wekan
366
+    su -c 'npm install fibers' - wekan
367
+    su -c 'npm install bcrypt' - wekan
368
+    su -c 'npm install bson' - wekan
369
+    su -c 'npm install es6-promise' - wekan
370
+    su -c 'npm install meteor-node-stubs' - wekan
371
+    su -c 'npm install winston' - wekan
372
+    su -c 'npm install winston-zulip' - wekan
373
+    su -c 'npm install xss' - wekan
374
+
375
+    # Remove any directories from previous installs
376
+    if [ -d $WEKAN_DIR/.meteor ]; then
377
+        rm -rf $WEKAN_DIR/.meteor
378
+    fi
379
+    if [ -d $WEKAN_DIR/app ]; then
380
+        rm -rf $WEKAN_DIR/app
381
+    fi
382
+    if [ -d $WEKAN_DIR/app_build ]; then
383
+        rm -rf $WEKAN_DIR/app_build
384
+    fi
385
+
386
+    # Get additional packages
387
+    mkdir -p $WEKAN_DIR/.meteor/packages
388
+    chown wekan:wekan --recursive $WEKAN_DIR/.meteor
389
+    cd $WEKAN_DIR/.meteor/packages
390
+    if [ ! -d /repos/flowrouter ]; then
391
+        su -c "git clone --depth 1 -b master $FLOW_ROUTER_REPO kadira-flow-router" - wekan
392
+    else
393
+        mkdir kadira-flow-router
394
+        cp -r -p /repos/flowrouter/. kadira-flow-router
395
+        cd kadira-flow-router
396
+        git pull
397
+        cd ..
398
+    fi
399
+    cd kadira-flow-router
400
+    git checkout $FLOW_ROUTER_COMMIT -b $FLOW_ROUTER_COMMIT
401
+    cd ..
402
+    if [ ! -d /repos/meteoruseraccounts ]; then
403
+        su -c "git clone --depth 1 -b master $METEOR_USERACCOUNTS_REPO meteor-useraccounts-core" - wekan
404
+    else
405
+        mkdir meteor-useraccounts-core
406
+        cp -r -p /repos/meteoruseraccounts/. meteor-useraccounts-core
407
+        cd meteor-useraccounts-core
408
+        git pull
409
+        cd ..
410
+    fi
411
+    cd meteor-useraccounts-core
412
+    git checkout $METEOR_USERACCOUNTS_COMMIT -b $METEOR_USERACCOUNTS_COMMIT
413
+    cd ..
414
+    if [ ! -f $WEKAN_DIR/.meteor/packages/meteor-useraccounts-core/package.js ]; then
415
+        echo $"File not found: $WEKAN_DIR/.meteor/packages/meteor-useraccounts-core/package.js"
416
+        exit 7289529
417
+    fi
418
+    sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' $WEKAN_DIR/.meteor/packages/meteor-useraccounts-core/package.js
419
+    cd $WEKAN_DIR/.meteor
420
+    su -c "$WEKAN_DIR/.meteor/meteor -- help" - wekan
421
+
422
+    # Build app
423
+    if [ ! -d $WEKAN_DIR/app ]; then
424
+        echo $'No app subdirectory found'
425
+        exit 294569
426
+    fi
427
+    cd $WEKAN_DIR/app
428
+    su -c "$WEKAN_DIR/.meteor/meteor add standard-minifier-js" - wekan
429
+    su -c "$WEKAN_DIR/.meteor/meteor npm install" - wekan
430
+    su -c "$WEKAN_DIR/.meteor/meteor build --directory $WEKAN_DIR/app_build" - wekan
431
+    cp $WEKAN_DIR/app/fix-download-unicode/cfs_access-point.txt $WEKAN_DIR/app_build/bundle/programs/server/packages/cfs_access-point.js
432
+    chown wekan:wekan $WEKAN_DIR/app_build/bundle/programs/server/packages/cfs_access-point.js
433
+    sed -i "s|build\/Release\/bson|browser_build\/bson|g" $WEKAN_DIR/app_build/bundle/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/node_modules/bson/ext/index.js
434
+    if [ ! -d $WEKAN_DIR/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt ]; then
435
+        echo $"No subdirectory found: $WEKAN_DIR/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt"
436
+        exit 479832
437
+    fi
438
+    cd $WEKAN_DIR/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt
439
+    su -c 'rm -rf node_modules/bcrypt' - wekan
440
+    su -c 'npm install bcrypt' - wekan
441
+    cd $WEKAN_DIR/app_build/bundle/programs/server/
442
+    su -c 'npm install' - wekan
443
+    mv $WEKAN_DIR/app_build/bundle ../build
444
+
445
+    if [ ! -f $WEKAN_DIR/build/main.js ]; then
446
+        echo $'main.js not found'
447
+        exit 7828252
448
+    fi
449
+
450
+    # Cleanup
451
+    rm -R $WEKAN_DIR/.meteor
452
+    rm -R $WEKAN_DIR/app
453
+    rm -R $WEKAN_DIR/app_build
454
+
455
+    chown -R wekan:wekan $WEKAN_DIR
456
+
457
+    function_check install_mariadb
458
+    install_mariadb
459
+
460
+    function_check get_mariadb_password
461
+    get_mariadb_password
462
+
463
+    function_check wekan_create_database
464
+    wekan_create_database
465
+
466
+    # daemon
467
+    echo '[Unit]' > /etc/systemd/system/wekan.service
468
+    echo 'Description=Wekan' >> /etc/systemd/system/wekan.service
469
+    echo 'After=syslog.target' >> /etc/systemd/system/wekan.service
470
+    echo 'After=network.target' >> /etc/systemd/system/wekan.service
471
+    echo '' >> /etc/systemd/system/wekan.service
472
+    echo '[Service]' >> /etc/systemd/system/wekan.service
473
+    echo 'User=wekan' >> /etc/systemd/system/wekan.service
474
+    echo 'Group=wekan' >> /etc/systemd/system/wekan.service
475
+    echo "WorkingDirectory=$WEKAN_DIR" >> /etc/systemd/system/wekan.service
476
+    echo "ExecStart=/usr/local/bin/node $WEKAN_DIR/build/main.js" >> /etc/systemd/system/wekan.service
477
+    echo 'Environment=PATH=/usr/bin:/usr/local/bin' >> /etc/systemd/system/wekan.service
478
+    echo 'Environment=NODE_ENV=production' >> /etc/systemd/system/wekan.service
479
+    echo 'Restart=on-failure' >> /etc/systemd/system/wekan.service
480
+    echo '' >> /etc/systemd/system/wekan.service
481
+    echo '[Install]' >> /etc/systemd/system/wekan.service
482
+    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/wekan.service
483
+    systemctl enable wekan.service
484
+    systemctl daemon-reload
485
+    systemctl start wekan.service
486
+
487
+    systemctl restart nginx
488
+
489
+    set_completion_param "wekan domain" "$WEKAN_DOMAIN_NAME"
490
+
491
+    APP_INSTALLED=1
492
+}
493
+
494
+# NOTE: deliberately there is no "exit 0"

+ 4
- 0
src/freedombone-image-customise Zobrazit soubor

@@ -1274,6 +1274,10 @@ function image_preinstall_repos {
1274 1274
     git clone $TOXID_REPO $rootdir/repos/toxid
1275 1275
     git clone $TOXIC_REPO $rootdir/repos/toxic
1276 1276
     git clone $TURTL_REPO $rootdir/repos/turtl
1277
+    git clone $WEKAN_REPO $rootdir/repos/wekan
1278
+    git clone $FLOW_ROUTER_REPO $rootdir/repos/flowrouter
1279
+    git clone $METEOR_USERACCOUNTS_REPO $rootdir/repos/meteoruseraccounts
1280
+    git clone $METEOR_REPO $rootdir/repos/meteor
1277 1281
     #git clone $ZERONET_REPO $rootdir/repos/zeronet
1278 1282
     #git clone $QTOX_REPO $rootdir/repos/qtox
1279 1283
 }

+ 220
- 0
src/freedombone-utils-meteor Zobrazit soubor

@@ -0,0 +1,220 @@
1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Functions for installing meteor
12
+# See meteor.com
13
+#
14
+# License
15
+# =======
16
+#
17
+# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
18
+#
19
+# This program is free software: you can redistribute it and/or modify
20
+# it under the terms of the GNU Affero General Public License as published by
21
+# the Free Software Foundation, either version 3 of the License, or
22
+# (at your option) any later version.
23
+#
24
+# This program is distributed in the hope that it will be useful,
25
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
+# GNU Affero General Public License for more details.
28
+#
29
+# You should have received a copy of the GNU Affero General Public License
30
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
31
+
32
+METEOR_RELEASE='1.4.4.1'
33
+METEOR_REPO="https://github.com/meteor/meteor"
34
+METEOR_COMMIT='b52c6587d7542c0f27481a3bee8c65be06068ac1'
35
+METEOR_USERACCOUNTS_REPO="git://github.com/meteor-useraccounts/core.git"
36
+METEOR_USERACCOUNTS_COMMIT='2e8986813b51f321f908d2f6211f6f81f76cd627'
37
+
38
+function meteor_cleanUp {
39
+    rm -rf "$TARBALL_FILE"
40
+    rm -rf "$INSTALL_TMPDIR"
41
+}
42
+
43
+function install_meteor_script {
44
+    meteor_dir=$1
45
+
46
+    if [ ! $meteor_dir ]; then
47
+        echo $'No meteor install directory specified'
48
+        exit 692025
49
+    fi
50
+
51
+    if [ ! -d $meteor_dir ]; then
52
+        echo $'Meteor install directory not found'
53
+        exit 845382
54
+    fi
55
+
56
+    if [[ "$(arch)" == "arm"* ]]; then
57
+        echo 'meteor does not support ARM'
58
+        exit 8362952
59
+    fi
60
+    if [[ "$(arch)" == "i386" || "$(arch)" == "x86_32" ]]; then
61
+        PLATFORM="os.linux.x86_32"
62
+    else
63
+        PLATFORM="os.linux.x86_64"
64
+    fi
65
+
66
+    RELEASE="$METEOR_RELEASE"
67
+
68
+    DIR_PREFIX="/usr/local"
69
+
70
+    TARBALL_URL="$https://meteorinstall-4168.kxcdn.com/packages-bootstrap/${RELEASE}/meteor-bootstrap-${PLATFORM}.tar.gz"
71
+    INSTALL_TMPDIR="$meteor_dir/.meteor-install-tmp"
72
+    TARBALL_FILE="$meteor_dir/.meteor-tarball-tmp"
73
+
74
+    # Remove temporary files now in case they exist.
75
+    meteor_cleanUp
76
+
77
+    if [ -d $INSTALL_TMPDIR ]; then
78
+        rm -rf $INSTALL_TMPDIR
79
+    fi
80
+    mkdir "$INSTALL_TMPDIR"
81
+
82
+    if [ ! -f ${TARBALL_FILE} ]; then
83
+        echo "Downloading Meteor distribution"
84
+        # keep trying to curl the file until it works (resuming where possible)
85
+        MAX_ATTEMPTS=10
86
+        RETRY_DELAY_SECS=5
87
+        set +e
88
+        ATTEMPTS=0
89
+        while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]
90
+        do
91
+            ATTEMPTS=$((ATTEMPTS + 1))
92
+
93
+            curl --progress-bar --fail --continue-at - \
94
+                 "$TARBALL_URL" --output "$TARBALL_FILE"
95
+
96
+            if [ $? -eq 0 ]
97
+            then
98
+                break
99
+            fi
100
+
101
+            echo "Retrying download in $RETRY_DELAY_SECS seconds..."
102
+            sleep $RETRY_DELAY_SECS
103
+        done
104
+    fi
105
+
106
+    if [ ! -f ${TARBALL_FILE} ]; then
107
+        echo $'meteor tarball could not be downloaded'
108
+        exit 7272452
109
+    fi
110
+
111
+    tar -xzf "$TARBALL_FILE" -C "$INSTALL_TMPDIR" -o
112
+
113
+    if [ ! -f ${INSTALL_TMPDIR}/.meteor/meteor ]; then
114
+        echo $'tarball not extracted'
115
+        exit 693252
116
+    fi
117
+
118
+    mv "${INSTALL_TMPDIR}/.meteor" "$meteor_dir"
119
+
120
+    meteor_cleanUp
121
+
122
+    echo ''
123
+    echo "Meteor ${RELEASE} has been installed in $meteor_dir/.meteor"
124
+
125
+    METEOR_SYMLINK_TARGET="$(readlink "$meteor_dir/.meteor/meteor")"
126
+    METEOR_TOOL_DIRECTORY="$(dirname "$METEOR_SYMLINK_TARGET")"
127
+    LAUNCHER="$meteor_dir/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor"
128
+
129
+    if cp "$LAUNCHER" "$DIR_PREFIX/bin/meteor" >/dev/null 2>&1; then
130
+        echo "Writing a launcher script to $DIR_PREFIX/bin/meteor for your convenience."
131
+        cat <<"EOF"
132
+
133
+To get started fast:
134
+
135
+  $ meteor create ~/my_cool_app
136
+  $ cd ~/my_cool_app
137
+  $ meteor
138
+
139
+Or see the docs at:
140
+
141
+  docs.meteor.com
142
+
143
+EOF
144
+    elif type sudo >/dev/null 2>&1; then
145
+        echo "Writing a launcher script to $DIR_PREFIX/bin/meteor for your convenience."
146
+        echo "This may prompt for your password."
147
+
148
+        # New macs (10.9+) don't ship with /usr/local, however it is still in
149
+        # the default PATH. We still install there, we just need to create the
150
+        # directory first.
151
+        # XXX this means that we can run sudo too many times. we should never
152
+        #     run it more than once if it fails the first time
153
+        if [ ! -d "$DIR_PREFIX/bin" ] ; then
154
+            sudo mkdir -m 755 "$DIR_PREFIX" || true
155
+            sudo mkdir -m 755 "$DIR_PREFIX/bin" || true
156
+        fi
157
+
158
+        if sudo cp "$LAUNCHER" "$DIR_PREFIX/bin/meteor"; then
159
+            cat <<"EOF"
160
+
161
+To get started fast:
162
+
163
+  $ meteor create ~/my_cool_app
164
+  $ cd ~/my_cool_app
165
+  $ meteor
166
+
167
+Or see the docs at:
168
+
169
+  docs.meteor.com
170
+
171
+EOF
172
+        else
173
+            cat <<EOF
174
+
175
+Couldn't write the launcher script. Please either:
176
+
177
+  (1) Run the following as root:
178
+        cp "$LAUNCHER" /usr/bin/meteor
179
+  (2) Add "\$meteor_dir/.meteor" to your path, or
180
+  (3) Rerun this command to try again.
181
+
182
+Then to get started, take a look at 'meteor --help' or see the docs at
183
+docs.meteor.com.
184
+EOF
185
+        fi
186
+    else
187
+        cat <<EOF
188
+
189
+Now you need to do one of the following:
190
+
191
+  (1) Add "\$meteor_dir/.meteor" to your path, or
192
+  (2) Run this command as root:
193
+        cp "$LAUNCHER" /usr/bin/meteor
194
+
195
+Then to get started, take a look at 'meteor --help' or see the docs at
196
+docs.meteor.com.
197
+EOF
198
+    fi
199
+
200
+}
201
+
202
+function install_meteor {
203
+    apt-get -yq install curl
204
+    if [ ! -d $INSTALL_DIR/meteor ]; then
205
+        mkdir $INSTALL_DIR/meteor
206
+    fi
207
+    cd $INSTALL_DIR/meteor
208
+    install_meteor_script
209
+}
210
+
211
+function remove_meteor {
212
+    if [ -f /usr/local/bin/meteor ]; then
213
+        rm /usr/local/bin/meteor
214
+    fi
215
+    if [ -f /usr/bin/meteor ]; then
216
+        rm /usr/bin/meteor
217
+    fi
218
+}
219
+
220
+# NOTE: deliberately no exit 0