소스 검색

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 7 년 전
부모
커밋
99bc83ac89
3개의 변경된 파일64개의 추가작업 그리고 63개의 파일을 삭제
  1. 36
    63
      src/freedombone-app-ghost
  2. 3
    0
      src/freedombone-utils-setup
  3. 25
    0
      src/freedombone-utils-web

+ 36
- 63
src/freedombone-app-ghost 파일 보기

@@ -14,7 +14,7 @@
14 14
 # License
15 15
 # =======
16 16
 #
17
-# Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
17
+# Copyright (C) 2016-2018 Bob Mottram <bob@freedombone.net>
18 18
 #
19 19
 # This program is free software: you can redistribute it and/or modify
20 20
 # it under the terms of the GNU Affero General Public License as published by
@@ -319,6 +319,8 @@ function remove_ghost {
319 319
     rm /etc/systemd/system/ghost.service
320 320
     systemctl daemon-reload
321 321
 
322
+    npm uninstall -g ghost-cli
323
+
322 324
     function_check remove_nodejs
323 325
     remove_nodejs ghost
324 326
 
@@ -347,6 +349,8 @@ function remove_ghost {
347 349
 }
348 350
 
349 351
 function install_ghost {
352
+    check_ram_availability 900
353
+
350 354
     if [ ! $ONION_ONLY ]; then
351 355
         ONION_ONLY='no'
352 356
     fi
@@ -367,78 +371,46 @@ function install_ghost {
367 371
     function_check install_nodejs
368 372
     install_nodejs ghost
369 373
 
370
-    # Some dependencies of ghost
371
-    npm install -g jison@0.4.13 --save
372
-    npm install moment-timezone@0.5.13
373
-    npm install express@4.15.3
374
-    npm install lodash@4.17.4
375
-    npm install uuid@3.0.1
376
-    npm install bluebird@3.5.0
377
-    npm install chalk@1.1.3
378
-    npm install intl-messageformat@1.3.0
379
-    npm install validator@7.0.0
380
-    npm install express-hbs@1.0.4
381
-    npm install glob@7.1.2
382
-    npm install unidecode@0.1.8
383
-    npm install csv-parser@1.11.0
384
-    npm install archiver@1.3.0
385
-    npm install fs-extra@3.0.1
386
-    npm install extract-zip-fork@1.5.1
387
-    npm install moment@2.18.1
388
-    npm install nodemailer@4.0.1
389
-    npm install html-to-text@3.3.0
390
-    npm install gscan@1.1.0
391
-    npm install body-parser@1.17.2
392
-    npm install compression@1.6.2
393
-    npm install morgan@1.8.2
394
-    npm install semver@5.3.0
395
-    npm install path-match@1.2.4
396
-    npm install downsize@0.0.8
397
-    npm install rss@1.2.2
398
-    npm install cheerio@1.0.0-rc.1
399
-    npm install passport@0.3.2
400
-    npm install xml@1.0.1
401
-    npm install multer@1.3.0
402
-    npm install oauth2orize@1.8.0
403
-    npm install connect-slashes@1.3.1
404
-    npm install cors@2.8.3
405
-    npm install netjet@1.1.3
406
-    npm install jsonpath@0.2.11
407
-    npm install image-size@0.5.4
408
-    npm install passport-oauth2-client-password@0.1.2
409
-    npm install passport-http-bearer@1.0.1
410
-    npm install amperize@0.3.4
411
-    npm install bcryptjs@2.4.3
412
-    npm install knex@0.12.9
413
-    npm install bookshelf@0.10.2
414
-    npm install cookie-session@1.2.0
415
-    npm install ghost-gql@0.0.6
416
-    npm install intl@1.2.5
417
-    npm install sanitize-html@1.14.1
418
-    npm install showdown-ghost@0.3.6
419
-    npm install superagent@3.5.2
420
-    npm install mysql@2.1.1
421
-    npm install mariasql@0.2.6
422
-    npm install debug@2.6.8
423
-    npm install nconf@0.8.4
424
-
425
-    npm install -g knex-migrator
426
-    knex-migrator init
427
-
428 374
     # now install ghost itself
429
-    npm install -g ghost-cli
375
+    npm install -g ghost-cli@latest
376
+    if [ ! -f /usr/local/bin/ghost ]; then
377
+        echo $'ghost was not installed'
378
+        exit 738539
379
+    fi
430 380
 
431 381
     GHOST_ONION_HOSTNAME=$(add_onion_service ghost 80 ${GHOST_ONION_PORT})
432 382
 
433
-    ghost install local --port ${GHOST_PORT}
383
+    npm install -g yarn
384
+    yarn install --no-emoji --no-progress
385
+    yarn cache clean
386
+    adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost
387
+    rm -rf /var/www/$GHOST_DOMAIN_NAME/htdocs/*
388
+    printf 'y' | ghost install ${GHOST_VERSION} --user ghost --db=sqlite3 --port ${GHOST_PORT} --verbose
389
+
390
+    if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs/versions ]; then
391
+        echo $'versions directory was not found'
392
+        exit 782523462
393
+    fi
394
+    if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
395
+        echo $'content directory was not found'
396
+        exit 68352682
397
+    fi
398
+
399
+    npm install -g knex-migrator
400
+    if [ ! -f /var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/MigratorConfig.js ]; then
401
+        echo $'MigratorConfig.js was not found'
402
+        exit 62783538
403
+    fi
404
+    cp /var/www/$GHOST_DOMAIN_NAME/htdocs/versions/${GHOST_VERSION}/MigratorConfig.js /var/www/$GHOST_DOMAIN_NAME/htdocs
405
+    chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
406
+    cd /var/www/$GHOST_DOMAIN_NAME/htdocs/current
407
+    knex-migrator init
434 408
 
435 409
     ghost_bust
436 410
 
437 411
     # NOTE: this has to be http, not https
438 412
     sed -i "s|\"url\":|\"url\": \"http://${GHOST_DOMAIN_NAME}/\",|g" /var/www/${GHOST_DOMAIN_NAME}/htdocs/config.development.json
439 413
 
440
-    adduser --system --home=/var/www/${GHOST_DOMAIN_NAME}/htdocs/ --group ghost
441
-
442 414
     echo '[Unit]' > /etc/systemd/system/ghost.service
443 415
     echo 'Description=Ghost Blog' >> /etc/systemd/system/ghost.service
444 416
     echo 'After=syslog.target' >> /etc/systemd/system/ghost.service
@@ -562,6 +534,7 @@ function install_ghost {
562 534
     else
563 535
         sed -i "s|ghost version.*|ghost version:${GHOST_VERSION}|g" ${COMPLETION_FILE}
564 536
     fi
537
+
565 538
     APP_INSTALLED=1
566 539
 }
567 540
 

+ 3
- 0
src/freedombone-utils-setup 파일 보기

@@ -1076,6 +1076,9 @@ function setup_web {
1076 1076
 
1077 1077
     function_check install_web_server_access_control
1078 1078
     install_web_server_access_control
1079
+
1080
+    function_check install_web_local_user_interface
1081
+    install_web_local_user_interface
1079 1082
 }
1080 1083
 
1081 1084
 function upgrade_apps {

+ 25
- 0
src/freedombone-utils-web 파일 보기

@@ -1070,4 +1070,29 @@ function email_install_tls {
1070 1070
     fi
1071 1071
 }
1072 1072
 
1073
+function install_web_local_user_interface {
1074
+    # TODO
1075
+    # This is intended as a placeholder for a potential local web user interface
1076
+    # similar to Plinth or the yunohost admin interface
1077
+    local_hostname=$(cat /etc/avahi/avahi-daemon.conf | grep 'host-name' | awk -F '=' '{print $2}').local
1078
+
1079
+    mkdir -p /var/www/${local_hostname}/htdocs
1080
+    echo '<html>' > /var/www/${local_hostname}/htdocs/index.html
1081
+    echo '  <body>' >> /var/www/${local_hostname}/htdocs/index.html
1082
+    echo "  This is a test on $local_hostname" >> /var/www/${local_hostname}/htdocs/index.html
1083
+    echo '  </body>' >> /var/www/${local_hostname}/htdocs/index.html
1084
+    echo '</html>' >> /var/www/${local_hostname}/htdocs/index.html
1085
+    chown -R www-data:www-data /var/www/${local_hostname}/htdocs
1086
+
1087
+    nginx_file=/etc/nginx/sites-available/$local_hostname
1088
+    echo 'server {' > $nginx_file
1089
+    echo '  listen 80;' >> $nginx_file
1090
+    echo '  listen [::]:80;' >> $nginx_file
1091
+    echo "  server_name ${local_hostname};" >> $nginx_file
1092
+    echo "  root /var/www/${local_hostname}/htdocs;" >> $nginx_file
1093
+    echo '  index index.html;' >> $nginx_file
1094
+    echo '}' >> $nginx_file
1095
+    nginx_ensite $local_hostname
1096
+}
1097
+
1073 1098
 # NOTE: deliberately no exit 0