Kaynağa Gözat

trove command

Bob Mottram 9 yıl önce
ebeveyn
işleme
2fbdac891b

BIN
man/freedombone-trove.1.gz Dosyayı Görüntüle


+ 30
- 11
src/freedombone Dosyayı Görüntüle

@@ -88,6 +88,13 @@ CONFIGURATION_FILE="${PROJECT_NAME}.cfg"
88 88
 SSH_PORT=2222
89 89
 IRC_PORT=6697
90 90
 
91
+# password used for accessing your repo trove
92
+MY_TROVE_PASSWORD=
93
+# friend's repo trove
94
+FRIENDS_TROVE_PASSWORD=
95
+FRIENDS_TROVE_SERVER=
96
+FRIENDS_TROVE_SSH_PORT=
97
+
91 98
 # An optional password to log into IRC. This applies to all users
92 99
 IRC_PASSWORD=
93 100
 
@@ -102,7 +109,7 @@ DDNS_USERNAME=
102 109
 DDNS_PASSWORD=
103 110
 CURRENT_DDNS_DOMAIN=
104 111
 
105
-EXIM_ONION_REPO='https://github.com/petterreinholdtsen/exim4-smtorp'
112
+EXIM_ONION_REPO="https://github.com/petterreinholdtsen/exim4-smtorp"
106 113
 
107 114
 NGINX_ENSITE_REPO="https://github.com/perusio/nginx_ensite"
108 115
 NGINX_ENSITE_COMMIT='fa4d72ce1c0a490442c8474e9c8dc21ed52c93d0'
@@ -193,7 +200,7 @@ HUBZILLA_DOMAIN_NAME=
193 200
 HUBZILLA_CODE=
194 201
 HUBZILLA_ONION_PORT=8085
195 202
 HUBZILLA_REPO="https://github.com/redmatrix/hubzilla.git"
196
-HUBZILLA_THEMES_REPO='https://github.com/DeadSuperHero/redmatrix-themes'
203
+HUBZILLA_THEMES_REPO="https://github.com/DeadSuperHero/redmatrix-themes"
197 204
 HUBZILLA_ADDONS_REPO="https://github.com/redmatrix/hubzilla-addons.git"
198 205
 HUBZILLA_ADMIN_PASSWORD=
199 206
 HUBZILLA_COMMIT='761afd029d97703f2f7609d546b7b5f3d257c601'
@@ -428,8 +435,8 @@ BABEL_PORT=6696
428 435
 ENABLE_SOCIAL_KEY_MANAGEMENT="no"
429 436
 
430 437
 TOX_PORT=33445
431
-TOX_REPO='git://github.com/irungentoo/toxcore.git'
432
-TOXID_REPO='https://github.com/bashrc/toxid'
438
+TOX_REPO="git://github.com/irungentoo/toxcore.git"
439
+TOXID_REPO="https://github.com/bashrc/toxid"
433 440
 TOX_COMMIT='73b2144edcfd1ca617e9054479b66ab0c0361a14'
434 441
 TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
435 442
 # These are some default nodes, but you can replace them with trusted nodes
@@ -443,13 +450,13 @@ TOXIC_REPO="https://github.com/Tox/toxic"
443 450
 TOXIC_COMMIT='88270827a96b2082e254677f35585ed24581a42c'
444 451
 
445 452
 #ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet.git'
446
-ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet.git'
453
+ZERONET_REPO="https://github.com/HelloZeroNet/ZeroNet.git"
447 454
 ZERONET_COMMIT='675bd462556c541d65e2d95f91f899146a373aad'
448
-ZERONET_BLOG_REPO='https://github.com/HelloZeroNet/ZeroBlog'
455
+ZERONET_BLOG_REPO="https://github.com/HelloZeroNet/ZeroBlog"
449 456
 ZERONET_BLOG_COMMIT='bbb0d6c36465fed2e6df71f1aab45fcc9c6ad609'
450
-ZERONET_MAIL_REPO='https://github.com/HelloZeroNet/ZeroMail'
457
+ZERONET_MAIL_REPO="https://github.com/HelloZeroNet/ZeroMail"
451 458
 ZERONET_MAIL_COMMIT='955af09d643c72b02e4983d71eca5c0c93a6c131'
452
-ZERONET_FORUM_REPO='https://github.com/HelloZeroNet/ZeroTalk'
459
+ZERONET_FORUM_REPO="https://github.com/HelloZeroNet/ZeroTalk"
453 460
 ZERONET_FORUM_COMMIT='e2d2c9cb1cfbfef91b244935efb5c14c2ad95faa'
454 461
 ZERONET_URL=http://127.0.0.1:43110
455 462
 ZERONET_PORT=15441
@@ -470,7 +477,7 @@ GPGIT_COMMIT='583dc76119f19420f8a33f606744faa7c8922738'
470 477
 DH_KEYLENGTH=2048
471 478
 
472 479
 # repo for atheros AR9271 wifi driver
473
-ATHEROS_WIFI_REPO='https://github.com/qca/open-ath9k-htc-firmware.git'
480
+ATHEROS_WIFI_REPO="https://github.com/qca/open-ath9k-htc-firmware.git"
474 481
 
475 482
 # Whether Let's Encrypt is enabled for all sites
476 483
 LETSENCRYPT_ENABLED="no"
@@ -916,6 +923,18 @@ function read_configuration {
916 923
         if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
917 924
             cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
918 925
         fi
926
+        if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
927
+            FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
928
+        fi
929
+        if grep -q "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
930
+            FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
931
+        fi
932
+        if grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
933
+            MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
934
+        fi
935
+        if grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
936
+            FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
937
+        fi
919 938
         if grep -q "PROJECT_WEBSITE" $CONFIGURATION_FILE; then
920 939
             PROJECT_WEBSITE=$(grep "PROJECT_WEBSITE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
921 940
         fi
@@ -4656,7 +4675,7 @@ function spam_filtering {
4656 4675
     echo '#!/bin/bash' > /usr/bin/filterspam
4657 4676
     echo 'for d in /home/*/ ; do' >> /usr/bin/filterspam
4658 4677
     echo '    USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterspam
4659
-    echo '    if [[ $USERNAME != "git" ]]; then' >> /usr/bin/filterspam
4678
+    echo '    if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then' >> /usr/bin/filterspam
4660 4679
     echo '        MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
4661 4680
     echo '        if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
4662 4681
     echo '           exit' >> /usr/bin/filterspam
@@ -4678,7 +4697,7 @@ function spam_filtering {
4678 4697
     echo '#!/bin/bash' > /usr/bin/filterham
4679 4698
     echo 'for d in /home/*/ ; do' >> /usr/bin/filterham
4680 4699
     echo '    USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterham
4681
-    echo '    if [[ $USERNAME != "git" ]]; then' >> /usr/bin/filterham
4700
+    echo '    if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then' >> /usr/bin/filterham
4682 4701
     echo '        MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
4683 4702
     echo '        if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
4684 4703
     echo '            exit' >> /usr/bin/filterham

+ 1
- 1
src/freedombone-archive-mail Dosyayı Görüntüle

@@ -35,7 +35,7 @@ export TEXTDOMAINDIR="/usr/share/locale"
35 35
 
36 36
 for d in /home/*/ ; do
37 37
     USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
38
-    if [[ $USERNAME != "git" ]]; then
38
+    if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
39 39
         # for every user who has a mail directory
40 40
         if [ -d /home/$USERNAME/Maildir ]; then
41 41
             MUTTRC=/home/$USERNAME/.muttrc

+ 1
- 1
src/freedombone-backup-local Dosyayı Görüntüle

@@ -265,7 +265,7 @@ function backup_users {
265 265
     # Backup user files
266 266
     for d in /home/*/ ; do
267 267
         USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
268
-        if [[ $USERNAME != "git" ]]; then
268
+        if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
269 269
 
270 270
             # Backup any gpg keys
271 271
             if [ -d /home/$USERNAME/.gnupg ]; then

+ 2
- 2
src/freedombone-backup-remote Dosyayı Görüntüle

@@ -178,7 +178,7 @@ function backup_configuration {
178 178
 function backup_users {
179 179
     for d in /home/*/ ; do
180 180
         USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
181
-        if [[ $USERNAME != "git" ]]; then
181
+        if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
182 182
 
183 183
             # personal settings
184 184
             if [ -d /home/$USERNAME/personal ]; then
@@ -604,7 +604,7 @@ do
604 604
         # Social key management
605 605
         for d in /home/*/ ; do
606 606
             USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
607
-            if [[ $USERNAME != "git" ]]; then
607
+            if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
608 608
                 disperse_key_shares $USERNAME $REMOTE_DOMAIN $REMOTE_SSH_PORT "$REMOTE_PASSWORD" $REMOTE_SERVER
609 609
             fi
610 610
         done

+ 1
- 1
src/freedombone-controlpanel Dosyayı Görüntüle

@@ -261,7 +261,7 @@ function show_users {
261 261
     echo '--------------------------------------------------------------------------'
262 262
     for d in /home/*/ ; do
263 263
         USRNAME=$(echo "$d" | awk -F '/' '{print $3}')
264
-        if [[ $USRNAME != "git" ]]; then
264
+        if [[ $USRNAME != "git" && $USRNAME != "trove" ]]; then
265 265
             echo -n -e "$(pad_string ${USRNAME})"
266 266
             # get the SIP extension
267 267
             SIPEXT=

+ 11
- 11
src/freedombone-restore-local Dosyayı Görüntüle

@@ -116,7 +116,7 @@ function unmount_drive {
116 116
     echo $"Setting permissions"
117 117
     for d in /home/*/ ; do
118 118
         USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
119
-        if [[ $USERNAME != "git" ]]; then
119
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
120 120
             chown -R $USERNAME:$USERNAME /home/$USERNAME
121 121
         fi
122 122
     done
@@ -356,7 +356,7 @@ function restore_mutt_settings {
356 356
     if [ -d $USB_MOUNT/backup/mutt ]; then
357 357
         for d in $USB_MOUNT/backup/mutt/*/ ; do
358 358
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
359
-            if [[ $USERNAME != "git" ]]; then
359
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
360 360
                 if [ ! -d /home/$USERNAME ]; then
361 361
                     ${PROJECT_NAME}-adduser $USERNAME
362 362
                 fi
@@ -388,7 +388,7 @@ function restore_gpg {
388 388
     if [ -d $USB_MOUNT/backup/gnupg ]; then
389 389
         for d in $USB_MOUNT/backup/gnupg/*/ ; do
390 390
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
391
-            if [[ $USERNAME != "git" ]]; then
391
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
392 392
                 if [ ! -d /home/$USERNAME ]; then
393 393
                     ${PROJECT_NAME}-adduser $USERNAME
394 394
                 fi
@@ -422,7 +422,7 @@ function restore_procmail {
422 422
     if [ -d $USB_MOUNT/backup/procmail ]; then
423 423
         for d in $USB_MOUNT/backup/procmail/*/ ; do
424 424
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
425
-            if [[ $USERNAME != "git" ]]; then
425
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
426 426
                 if [ ! -d /home/$USERNAME ]; then
427 427
                     ${PROJECT_NAME}-adduser $USERNAME
428 428
                 fi
@@ -449,7 +449,7 @@ function restore_spamassassin {
449 449
     if [ -d $USB_MOUNT/backup/spamassassin ]; then
450 450
         for d in $USB_MOUNT/backup/spamassassin/*/ ; do
451 451
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
452
-            if [[ $USERNAME != "git" ]]; then
452
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
453 453
                 if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then
454 454
                     if [ ! -d /home/$USERNAME ]; then
455 455
                         ${PROJECT_NAME}-adduser $USERNAME
@@ -525,7 +525,7 @@ function restore_user_ssh_keys {
525 525
     if [ -d $USB_MOUNT/backup/ssh ]; then
526 526
         for d in $USB_MOUNT/backup/ssh/*/ ; do
527 527
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
528
-            if [[ $USERNAME != "git" ]]; then
528
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
529 529
                 if [ ! -d /home/$USERNAME ]; then
530 530
                     ${PROJECT_NAME}-adduser $USERNAME
531 531
                 fi
@@ -552,7 +552,7 @@ function restore_user_config {
552 552
     if [ -d $USB_MOUNT/backup/config ]; then
553 553
         for d in $USB_MOUNT/backup/config/*/ ; do
554 554
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
555
-            if [[ $USERNAME != "git" ]]; then
555
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
556 556
                 if [ ! -d /home/$USERNAME ]; then
557 557
                     ${PROJECT_NAME}-adduser $USERNAME
558 558
                 fi
@@ -622,7 +622,7 @@ function restore_personal_settings {
622 622
     if [ -d $USB_MOUNT/backup/personal ]; then
623 623
         for d in $USB_MOUNT/backup/personal/*/ ; do
624 624
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
625
-            if [[ $USERNAME != "git" ]]; then
625
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
626 626
                 if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then
627 627
                     if [ ! -d /home/$USERNAME ]; then
628 628
                         ${PROJECT_NAME}-adduser $USERNAME
@@ -739,7 +739,7 @@ function restore_owncloud {
739 739
             chown -R www-data:www-data /var/lib/owncloud/assets
740 740
             for d in /home/*/ ; do
741 741
                 USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
742
-                if [[ $USERNAME != "git" ]]; then
742
+                if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
743 743
                     occ files:scan $USERNAME
744 744
                 fi
745 745
             done
@@ -853,7 +853,7 @@ function restore_blog {
853 853
         fi
854 854
         for d in /home/*/ ; do
855 855
             USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
856
-            if [[ $USERNAME != "git" ]]; then
856
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
857 857
                 if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
858 858
                     mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
859 859
                 fi
@@ -894,7 +894,7 @@ function restore_email {
894 894
     if [ -d $USB_MOUNT/backup/mail ]; then
895 895
         for d in $USB_MOUNT/backup/mail/*/ ; do
896 896
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
897
-            if [[ $USERNAME != "git" ]]; then
897
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
898 898
                 if [ ! -d /home/$USERNAME ]; then
899 899
                     ${PROJECT_NAME}-adduser $USERNAME
900 900
                 fi

+ 10
- 10
src/freedombone-restore-remote Dosyayı Görüntüle

@@ -260,7 +260,7 @@ function restore_mutt_settings {
260 260
     fi
261 261
     for d in $SERVER_DIRECTORY/backup/mutt/*/ ; do
262 262
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
263
-        if [[ $USERNAME != "git" ]]; then
263
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
264 264
             if [ -d $SERVER_DIRECTORY/backup/mutt/$USERNAME ]; then
265 265
                 if [ ! -d /home/$USERNAME ]; then
266 266
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -291,7 +291,7 @@ function restore_gpg {
291 291
     fi
292 292
     for d in $SERVER_DIRECTORY/backup/gnupg/*/ ; do
293 293
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
294
-        if [[ $USERNAME != "git" ]]; then
294
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
295 295
             if [ -d $SERVER_DIRECTORY/backup/gnupg/$USERNAME ]; then
296 296
                 if [ ! -d /home/$USERNAME ]; then
297 297
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -323,7 +323,7 @@ function restore_procmail {
323 323
     fi
324 324
     for d in $SERVER_DIRECTORY/backup/procmail/*/ ; do
325 325
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
326
-        if [[ $USERNAME != "git" ]]; then
326
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
327 327
             if [ -d $SERVER_DIRECTORY/backup/procmail/$USERNAME ]; then
328 328
                 if [ ! -d /home/$USERNAME ]; then
329 329
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -349,7 +349,7 @@ function restore_spamassassin {
349 349
     fi
350 350
     for d in $SERVER_DIRECTORY/backup/spamassassin/*/ ; do
351 351
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
352
-        if [[ $USERNAME != "git" ]]; then
352
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
353 353
             if [ -d $SERVER_DIRECTORY/backup/spamassassin/$USERNAME ]; then
354 354
                 if [ ! -d /home/$USERNAME ]; then
355 355
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -411,7 +411,7 @@ function restore_ssh_keys {
411 411
     fi
412 412
     for d in $SERVER_DIRECTORY/backup/ssh/*/ ; do
413 413
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
414
-        if [[ $USERNAME != "git" ]]; then
414
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
415 415
             if [ -d $SERVER_DIRECTORY/backup/ssh/$USERNAME ]; then
416 416
                 if [ ! -d /home/$USERNAME ]; then
417 417
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -437,7 +437,7 @@ function restore_user_config {
437 437
     fi
438 438
     for d in $SERVER_DIRECTORY/backup/config/*/ ; do
439 439
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
440
-        if [[ $USERNAME != "git" ]]; then
440
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
441 441
             if [ -d $SERVER_DIRECTORY/backup/config/$USERNAME ]; then
442 442
                 if [ ! -d /home/$USERNAME ]; then
443 443
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -504,7 +504,7 @@ function restore_personal_settings {
504 504
     fi
505 505
     for d in $SERVER_DIRECTORY/backup/personal/*/ ; do
506 506
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
507
-        if [[ $USERNAME != "git" ]]; then
507
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
508 508
             if [ -d $SERVER_DIRECTORY/backup/personal/$USERNAME ]; then
509 509
                 if [ ! -d /home/$USERNAME ]; then
510 510
                     ${PROJECT_NAME}-adduser $USERNAME
@@ -624,7 +624,7 @@ function restore_owncloud {
624 624
             chown -R www-data:www-data /var/lib/owncloud/assets
625 625
             for d in /home/*/ ; do
626 626
                 USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
627
-                if [[ $USERNAME != "git" ]]; then
627
+                if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
628 628
                     occ files:scan $USERNAME
629 629
                 fi
630 630
             done
@@ -733,7 +733,7 @@ function restore_blog {
733 733
         fi
734 734
         for d in /home/*/ ; do
735 735
             USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
736
-            if [[ $USERNAME != "git" ]]; then
736
+            if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
737 737
                 if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
738 738
                     mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
739 739
                 fi
@@ -825,7 +825,7 @@ function restore_email {
825 825
     fi
826 826
     for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
827 827
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
828
-        if [[ $USERNAME != "git" ]]; then
828
+        if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
829 829
             if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then
830 830
                 if [ ! -d /home/$USERNAME ]; then
831 831
                     ${PROJECT_NAME}-adduser $USERNAME

+ 217
- 0
src/freedombone-trove Dosyayı Görüntüle

@@ -0,0 +1,217 @@
1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Host git repos which the project depends on
12
+#
13
+# License
14
+# =======
15
+#
16
+# Copyright (C) 2015-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 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 General Public License for more details.
27
+#
28
+# You should have received a copy of the GNU 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}-trove
34
+export TEXTDOMAINDIR="/usr/share/locale"
35
+
36
+# Minimum number of characters in a password
37
+MINIMUM_PASSWORD_LENGTH=10
38
+
39
+CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
40
+
41
+# if this is blank then just use the default repos
42
+FRIENDS_TROVE_SERVER=
43
+REPOS=
44
+TROVE_BASE=/home/trove/trove
45
+MY_TROVE_PASSWORD=
46
+FRIENDS_TROVE_PASSWORD=
47
+NEW_TROVE='no'
48
+FRIENDS_TROVE_SSH_PORT=2222
49
+
50
+MAIN_COMMAND=/usr/local/bin/${PROJECT_NAME}
51
+if [ ! -f $MAIN_COMMAND ]; then
52
+    MAIN_COMMAND=/usr/bin/${PROJECT_NAME}
53
+fi
54
+
55
+REPOS=($(cat ${MAIN_COMMAND} | grep "_REPO=\"" | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
56
+
57
+# obtain the trove password if it exists
58
+if [ -f $CONFIGURATION_FILE ]; then
59
+    if ! grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
60
+        MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
61
+    fi
62
+    if ! grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
63
+        FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
64
+    fi
65
+    if ! grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
66
+        FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
67
+    fi
68
+    if ! grep -q "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
69
+        FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
70
+    fi
71
+fi
72
+
73
+function show_help {
74
+    echo ''
75
+    echo $"${PROJECT_NAME}-trove --sync [domain/url] -p [password]"
76
+    echo ''
77
+    echo $'Creates or syncs with a set of git repositories'
78
+    echo ''
79
+    echo $'     --help                   Show help'
80
+    echo $'  -n|--new [yes|no]           Start a new trove'
81
+    echo $"  -p|--password [yes|no]      Friend's trove user password"
82
+    echo $"  -m|--mypassword [yes|no]    Local trove user password"
83
+    echo $"     --port [number]          Friend's server ssh port number"
84
+    echo $"  -s|--sync [domain]          Friend's server domain to sync with"
85
+    echo ''
86
+    exit 0
87
+}
88
+
89
+function create_trove_user {
90
+    if [ -d /home/trove ]; then
91
+        return
92
+    fi
93
+
94
+    create_password='no'
95
+    if [ ! "$MY_TROVE_PASSWORD" ]; then
96
+        create_password='yes'
97
+    fi
98
+    if [ ${#MY_TROVE_PASSWORD} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then
99
+        echo $'Password is too short. Creating new one.'
100
+        create_password='yes'
101
+    fi
102
+
103
+    if [[ $create_password == 'yes' ]]; then
104
+        MY_TROVE_PASSWORD="$(openssl rand -base64 20 | cut -c1-18)"
105
+    fi
106
+
107
+    useradd -m -p "$MY_TROVE_PASSWORD" -s /bin/bash trove
108
+
109
+    # remove any existing user files
110
+    rm -rf /home/trove/*
111
+
112
+    # store the trove password
113
+    if [ -f $CONFIGURATION_FILE ]; then
114
+        if ! grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
115
+            echo "MY_TROVE_PASSWORD=$MY_TROVE_PASSWORD" >> $CONFIGURATION_FILE
116
+        else
117
+            sed -i "s|MY_TROVE_PASSWORD=.*|MY_TROVE_PASSWORD=${MY_TROVE_PASSWORD}|g" $CONFIGURATION_FILE
118
+        fi
119
+    fi
120
+}
121
+
122
+function update_repos_from_friend {
123
+    if [ ! $FRIENDS_TROVE_SERVER ] then
124
+       return
125
+    fi
126
+
127
+    new_repos=()
128
+    for line in "${REPOS[@]}"
129
+    do
130
+        repo_name=$(echo "$line" | awk -F '=' '{print $1}')
131
+        trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
132
+        #repo_url=$(echo "$line" | awk -F '=' '{print $2}'  | awk -F '"' '{print $2}')
133
+        friends_repo_url="ssh://trove@${FRIENDS_TROVE_SERVER}:${FRIENDS_TROVE_SSH_PORT}/home/trove/${trove_name}"
134
+        new_line="${repo_name}=\"${friends_repo_url}\""
135
+        new_repos+=($new_line)
136
+    done
137
+    REPOS=("${new_repos[@]}")
138
+}
139
+
140
+function sync_trove_repos {
141
+    for line in "${REPOS[@]}"
142
+    do
143
+        repo_name=$(echo "$line" | awk -F '=' '{print $1}')
144
+        repo_url=$(echo "$line" | awk -F '=' '{print $2}'  | awk -F '"' '{print $2}')
145
+        trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
146
+        if [[ $NEW_TROVE == 'yes' ]]; then
147
+            if [ -d /home/trove/${trove_name} ]; then
148
+                rm -rf /home/trove/${trove_name}
149
+            fi
150
+        fi
151
+        if [ ! -d /home/trove/${trove_name} ]; then
152
+            git clone --mirror ${repo_url} /home/trove/${trove_name}
153
+            if [ ! -d /home/trove/${trove_name} ]; then
154
+                echo $"WARNING: failed to mirror repo ${repo_url}"
155
+            fi
156
+        else
157
+            cd /home/trove/${trove_name}
158
+            git fetch -p origin
159
+        fi
160
+    done
161
+}
162
+
163
+while [[ $# > 1 ]]
164
+do
165
+key="$1"
166
+
167
+case $key in
168
+    --help)
169
+    show_help
170
+    ;;
171
+    -s|--sync)
172
+    shift
173
+    # use repos on another server
174
+    FRIENDS_TROVE_SERVER="$1"
175
+    ;;
176
+    -m|--mypass|--mypassword)
177
+    shift
178
+    MY_TROVE_PASSWORD="$1"
179
+    if [ -f $CONFIGURATION_FILE ]; then
180
+        if ! grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
181
+            echo "MY_TROVE_PASSWORD=$MY_TROVE_PASSWORD" >> $CONFIGURATION_FILE
182
+        else
183
+            sed -i "s|MY_TROVE_PASSWORD=.*|MY_TROVE_PASSWORD=${MY_TROVE_PASSWORD}|g" $CONFIGURATION_FILE
184
+        fi
185
+    fi
186
+    ;;
187
+    -p|--pass|--password)
188
+    shift
189
+    FRIENDS_TROVE_PASSWORD="$1"
190
+    if [ -f $CONFIGURATION_FILE ]; then
191
+        if ! grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
192
+            echo "FRIENDS_TROVE_PASSWORD=$FRIENDS_TROVE_PASSWORD" >> $CONFIGURATION_FILE
193
+        else
194
+            sed -i "s|FRIENDS_TROVE_PASSWORD=.*|FRIENDS_TROVE_PASSWORD=${FRIENDS_TROVE_PASSWORD}|g" $CONFIGURATION_FILE
195
+        fi
196
+    fi
197
+    ;;
198
+    -n|--new)
199
+    shift
200
+    NEW_TROVE="$1"
201
+    ;;
202
+    --port)
203
+    shift
204
+    FRIENDS_TROVE_SSH_PORT=${1}
205
+    ;;
206
+    *)
207
+    # unknown option
208
+    ;;
209
+esac
210
+shift
211
+done
212
+
213
+create_trove_user
214
+update_repos_from_friend
215
+sync_trove_repos
216
+
217
+exit 0