ソースを参照

Add a commit update function

Bob Mottram 9 年 前
コミット
94c8427320
共有1 個のファイルを変更した104 個の追加308 個の削除を含む
  1. 104
    308
      src/freedombone

+ 104
- 308
src/freedombone ファイルの表示

@@ -503,6 +503,7 @@ RSS_READER_ONION_PORT=8092
503 503
 RSS_READER_DOMAIN_NAME=ttrss
504 504
 RSS_MOBILE_READER_REPO="https://github.com/g2ttrss/g2ttrss-mobile"
505 505
 RSS_MOBILE_READER_COMMIT='c5af46ebf64076e4c62c978551fa749af268710b'
506
+RSS_READER_PATH=/etc/share/tt-rss
506 507
 
507 508
 function show_help {
508 509
     echo ''
@@ -1434,6 +1435,84 @@ function set_default_onion_domains {
1434 1435
     fi
1435 1436
 }
1436 1437
 
1438
+function set_repo_commit {
1439
+    repo_dir=$1
1440
+    repo_commit_name=$2
1441
+    repo_commit=$3
1442
+    repo_url=$4
1443
+    if [ -d $repo_dir ]; then
1444
+        if grep -q "$repo_commit_name" $COMPLETION_FILE; then
1445
+            CURRENT_REPO_COMMIT=$(grep "$repo_commit_name" $COMPLETION_FILE | awk -F ':' '{print $2}')
1446
+            if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
1447
+                cd $repo_dir
1448
+                git_pull $repo_url $repo_commit
1449
+                sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
1450
+
1451
+                # application specific stuff after updating the repo
1452
+                if [[ $repo_dir == *"www"* ]]; then
1453
+                    chown -R www-data:www-data $repo_dir
1454
+                fi
1455
+                if [[ $repo_dir == *"cjdns" ]]; then
1456
+                    ./do
1457
+                fi
1458
+                if [[ $repo_dir == *"gpgit" ]]; then
1459
+                    cp gpgit.pl /usr/bin/gpgit.pl
1460
+                fi
1461
+                if [[ $repo_dir == *"cleanup-maildir" ]]; then
1462
+                    cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
1463
+                fi
1464
+                if [[ $repo_dir == *"nginx_ensite" ]]; then
1465
+                    make install
1466
+                fi
1467
+                if [[ $repo_dir == *"gogs" ]]; then
1468
+                    go get -u ./...
1469
+                    if [ ! "$?" = "0" ]; then
1470
+                        exit 52792
1471
+                    fi
1472
+                    go build
1473
+                    if [ ! "$?" = "0" ]; then
1474
+                        exit 36226
1475
+                    fi
1476
+                    systemctl restart gogs
1477
+                fi
1478
+                if [[ $repo_dir == *"toxcore" ]]; then
1479
+                    autoreconf -i
1480
+                    ./configure --enable-daemon
1481
+                    make
1482
+                    make install
1483
+                    systemctl restart tox-bootstrapd.service
1484
+                fi
1485
+                if [[ $repo_dir == *"toxic" ]]; then
1486
+                    make
1487
+                    make install
1488
+                fi
1489
+                if [[ $repo_dir == $RSS_READER_PATH ]]; then
1490
+                    if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/plugins/af_unburn/init.php; then
1491
+                        sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/plugins/af_unburn/init.php
1492
+                    fi
1493
+                    if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/include/functions.php; then
1494
+                        sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/include/functions.php
1495
+                    fi
1496
+                    chown -R www-data:www-data $RSS_READER_PATH
1497
+                fi
1498
+                if [[ $repo_dir == *"inadyn" ]]; then
1499
+                    ./configure
1500
+                    USE_OPENSSL=1 make
1501
+                    make install
1502
+                    systemctl restart inadyn
1503
+                fi
1504
+                if [[ $repo_dir == *"ipfs" ]]; then
1505
+                    chown -R git:git /home/git
1506
+                    systemctl restart ipfs
1507
+                    systemctl daemon-reload
1508
+                fi
1509
+            fi
1510
+        else
1511
+            echo "\${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
1512
+        fi
1513
+    fi
1514
+}
1515
+
1437 1516
 function wait_for_onion_service {
1438 1517
     onion_service_name="$1"
1439 1518
 
@@ -2020,18 +2099,8 @@ function mesh_cjdns {
2020 2099
     fi
2021 2100
 
2022 2101
     # update to the next commit
2023
-    if [ -d /etc/cjdns ]; then
2024
-        if grep -q "cjdns commit" $COMPLETION_FILE; then
2025
-            CURRENT_CJDNS_COMMIT=$(grep "cjdns commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
2026
-            if [[ "$CURRENT_CJDNS_COMMIT" != "$CJDNS_COMMIT" ]]; then
2027
-                cd /etc/cjdns
2028
-                git_pull $CJDNS_REPO $CJDNS_COMMIT
2029
-                sed -i "s/cjdns commit.*/cjdns commit:$CJDNS_COMMIT/g" $COMPLETION_FILE
2030
-                ./do
2031
-            fi
2032
-        fi
2033
-    fi
2034
-
2102
+    set_repo_commit /etc/cjdns "cjdns commit" "$CJDNS_COMMIT" $CJDNS_REPO
2103
+    
2035 2104
     if grep -Fxq "mesh_cjdns" $COMPLETION_FILE; then
2036 2105
         return
2037 2106
     fi
@@ -2374,19 +2443,8 @@ function install_zeronet_blog {
2374 2443
         return
2375 2444
     fi
2376 2445
 
2377
-    if [ -d /opt/zeronet/ZeroBlog ]; then
2378
-        if grep -q "ZeroNet Blog commit" $COMPLETION_FILE; then
2379
-            CURRENT_ZERONET_BLOG_COMMIT=$(grep "ZeroNet Blog commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
2380
-            if [[ "$CURRENT_ZERONET_BLOG_COMMIT" != "$ZERONET_BLOG_COMMIT" ]]; then
2381
-                cd /opt/zeronet/ZeroBlog
2382
-                git_pull $ZERONET_BLOG_REPO $ZERONET_BLOG_COMMIT
2383
-                sed -i "s/ZeroNet Blog commit.*/ZeroNet Blog commit:$ZERONET_BLOG_COMMIT/g" $COMPLETION_FILE
2384
-            fi
2385
-        else
2386
-            echo "ZeroNet Blog commit:$ZERONET_BLOG_COMMIT" >> $COMPLETION_FILE
2387
-        fi
2388
-    fi
2389
-
2446
+    set_repo_commit /opt/zeronet/ZeroBlog "ZeroNet Blog commit" "$ZERONET_BLOG_COMMIT" $ZERONET_BLOG_REPO
2447
+    
2390 2448
     if grep -Fxq "install_zeronet_blog" $COMPLETION_FILE; then
2391 2449
         return
2392 2450
     fi
@@ -2497,18 +2555,7 @@ function install_zeronet_mail {
2497 2555
         return
2498 2556
     fi
2499 2557
 
2500
-    if [ -d /opt/zeronet/ZeroMail ]; then
2501
-        if grep -q "ZeroNet Mail commit" $COMPLETION_FILE; then
2502
-            CURRENT_ZERONET_MAIL_COMMIT=$(grep "ZeroNet Mail commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
2503
-            if [[ "$CURRENT_ZERONET_MAIL_COMMIT" != "$ZERONET_MAIL_COMMIT" ]]; then
2504
-                cd /opt/zeronet/ZeroMail
2505
-                git_pull $ZERONET_MAIL_REPO $ZERONET_MAIL_COMMIT
2506
-                sed -i "s/ZeroNet Mail commit.*/ZeroNet Mail commit:$ZERONET_MAIL_COMMIT/g" $COMPLETION_FILE
2507
-            fi
2508
-        else
2509
-            echo "ZeroNet Mail commit:$ZERONET_MAIL_COMMIT" >> $COMPLETION_FILE
2510
-        fi
2511
-    fi
2558
+    set_repo_commit /opt/zeronet/ZeroMail "ZeroNet Mail commit" "$ZERONET_MAIL_COMMIT" $ZERONET_MAIL_REPO
2512 2559
 
2513 2560
     if grep -Fxq "install_zeronet_mail" $COMPLETION_FILE; then
2514 2561
         return
@@ -2621,18 +2668,7 @@ function install_zeronet_forum {
2621 2668
     fi
2622 2669
 
2623 2670
     # update to the next commit
2624
-    if [ -d /opt/zeronet/ZeroTalk ]; then
2625
-        if grep -q "ZeroNet Forum commit" $COMPLETION_FILE; then
2626
-            CURRENT_ZERONET_FORUM_COMMIT=$(grep "ZeroNet Forum commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
2627
-            if [[ "$CURRENT_ZERONET_FORUM_COMMIT" != "$ZERONET_FORUM_COMMIT" ]]; then
2628
-                cd /opt/zeronet/ZeroTalk
2629
-                git_pull $ZERONET_FORUM_REPO $ZERONET_FORUM_COMMIT
2630
-                sed -i "s/ZeroNet Forum commit.*/ZeroNet Forum commit:$ZERONET_FORUM_COMMIT/g" $COMPLETION_FILE
2631
-            fi
2632
-        else
2633
-            echo "ZeroNet Forum commit:$ZERONET_FORUM_COMMIT" >> $COMPLETION_FILE
2634
-        fi
2635
-    fi
2671
+    set_repo_commit /opt/zeronet/ZeroTalk "ZeroNet Forum commit" "$ZERONET_FORUM_COMMIT" $ZERONET_FORUM_REPO
2636 2672
 
2637 2673
     if grep -Fxq "install_zeronet_forum" $COMPLETION_FILE; then
2638 2674
         return
@@ -2739,19 +2775,7 @@ function install_zeronet {
2739 2775
     fi
2740 2776
 
2741 2777
     # update to the next commit
2742
-    if [ -d /opt/zeronet ]; then
2743
-        if grep -q "ZeroNet commit" $COMPLETION_FILE; then
2744
-            CURRENT_ZERONET_COMMIT=$(grep "ZeroNet commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
2745
-            if [[ "$CURRENT_ZERONET_COMMIT" != "$ZERONET_COMMIT" ]]; then
2746
-                cd /opt/zeronet
2747
-                git_pull $ZERONET_REPO $ZERONET_COMMIT
2748
-                sed -i "s/ZeroNet commit.*/ZeroNet commit:$ZERONET_COMMIT/g" $COMPLETION_FILE
2749
-                systemctl restart zeronet.service
2750
-            fi
2751
-        else
2752
-            echo "ZeroNet commit:$ZERONET_COMMIT" >> $COMPLETION_FILE
2753
-        fi
2754
-    fi
2778
+    set_repo_commit /opt/zeronet "ZeroNet commit" "$ZERONET_COMMIT" $ZERONET_REPO
2755 2779
 
2756 2780
     if grep -Fxq "install_zeronet" $COMPLETION_FILE; then
2757 2781
         return
@@ -5345,19 +5369,7 @@ function encrypt_incoming_email {
5345 5369
     fi
5346 5370
 
5347 5371
     # update to the next commit
5348
-    if [ -f /usr/bin/gpgit.pl ]; then
5349
-        if grep -q "gpgit commit" $COMPLETION_FILE; then
5350
-            CURRENT_GPGIT_COMMIT=$(grep "gpgit commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
5351
-            if [[ "$CURRENT_GPGIT_COMMIT" != "$GPGIT_COMMIT" ]]; then
5352
-                cd $INSTALL_DIR/gpgit
5353
-                git_pull $GPGIT_REPO $GPGIT_COMMIT
5354
-                sed -i "s/gpgit commit.*/gpgit commit:$GPGIT_COMMIT/g" $COMPLETION_FILE
5355
-                cp gpgit.pl /usr/bin/gpgit.pl
5356
-            fi
5357
-        else
5358
-            echo "gpgit commit:$GPGIT_COMMIT" >> $COMPLETION_FILE
5359
-        fi
5360
-    fi
5372
+    set_repo_commit $INSTALL_DIR/gpgit "gpgit commit" "$GPGIT_COMMIT" $GPGIT_REPO
5361 5373
 
5362 5374
     if grep -Fxq "encrypt_incoming_email" $COMPLETION_FILE; then
5363 5375
         return
@@ -5657,19 +5669,7 @@ function email_archiving {
5657 5669
     chmod +x /etc/cron.daily/archivemail
5658 5670
 
5659 5671
     # update to the next commit
5660
-    if [ -d $INSTALL_DIR/cleanup-maildir ]; then
5661
-        if grep -q "cleanup-maildir commit" $COMPLETION_FILE; then
5662
-            CURRENT_CLEANUP_MAILDIR_COMMIT=$(grep "cleanup-maildir commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
5663
-            if [[ "$CURRENT_CLEANUP_MAILDIR_COMMIT" != "$CLEANUP_MAILDIR_COMMIT" ]]; then
5664
-                cd $INSTALL_DIR/cleanup-maildir
5665
-                git_pull $CLEANUP_MAILDIR_REPO $CLEANUP_MAILDIR_COMMIT
5666
-                sed -i "s/cleanup-maildir commit.*/cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT/g" $COMPLETION_FILE
5667
-                cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
5668
-            fi
5669
-        else
5670
-            echo "cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT" >> $COMPLETION_FILE
5671
-        fi
5672
-    fi
5672
+    set_repo_commit $INSTALL_DIR/cleanup-maildir "cleanup-maildir commit" "$CLEANUP_MAILDIR_COMMIT" $CLEANUP_MAILDIR_REPO
5673 5673
 
5674 5674
     if grep -Fxq "email_archiving" $COMPLETION_FILE; then
5675 5675
         return
@@ -5943,19 +5943,7 @@ function install_web_server {
5943 5943
     fi
5944 5944
 
5945 5945
     # update to the next commit
5946
-    if [ -d $INSTALL_DIR/nginx_ensite ]; then
5947
-        if grep -q "Nginx-ensite commit" $COMPLETION_FILE; then
5948
-            CURRENT_NGINX_ENSITE_COMMIT=$(grep "Nginx-ensite commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
5949
-            if [[ "$CURRENT_NGINX_ENSITE_COMMIT" != "$NGINX_ENSITE_COMMIT" ]]; then
5950
-                $INSTALL_DIR/nginx_ensite
5951
-                git_pull $NGINX_ENSITE_REPO $NGINX_ENSITE_COMMIT
5952
-                sed -i "s/Nginx-ensite commit.*/Nginx-ensite commit:$NGINX_ENSITE_COMMIT/g" $COMPLETION_FILE
5953
-                make install
5954
-            fi
5955
-        else
5956
-            echo "Nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> $COMPLETION_FILE
5957
-        fi
5958
-    fi
5946
+    set_repo_commit $INSTALL_DIR/nginx_ensite "Nginx-ensite commit" "$NGINX_ENSITE_COMMIT" $NGINX_ENSITE_REPO
5959 5947
 
5960 5948
     if grep -Fxq "install_web_server" $COMPLETION_FILE; then
5961 5949
         return
@@ -6209,18 +6197,7 @@ function install_owncloud_music_app {
6209 6197
     fi
6210 6198
 
6211 6199
     # update to the next commit
6212
-    if [ -d /usr/share/owncloud/apps/music ]; then
6213
-        if grep -q "Owncloud music app commit" $COMPLETION_FILE; then
6214
-            CURRENT_OWNCLOUD_MUSIC_APP_COMMIT=$(grep "Owncloud music app commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
6215
-            if [[ "$OWNCLOUD_MUSIC_APP_COMMIT" != "$OWNCLOUD_MUSIC_APP_COMMIT" ]]; then
6216
-                cd /usr/share/owncloud/apps/music
6217
-                git_pull $OWNCLOUD_MUSIC_APP_REPO $OWNCLOUD_MUSIC_APP_COMMIT
6218
-                sed -i "s/Owncloud music app commit.*/Owncloud music app commit:$OWNCLOUD_MUSIC_APP_COMMIT/g" $COMPLETION_FILE
6219
-            fi
6220
-        else
6221
-            echo "Owncloud music app commit:$OWNCLOUD_MUSIC_APP_COMMIT" >> $COMPLETION_FILE
6222
-        fi
6223
-    fi
6200
+    set_repo_commit /usr/share/owncloud/apps/music "Owncloud music app commit" "$OWNCLOUD_MUSIC_APP_COMMIT" $OWNCLOUD_MUSIC_APP_REPO
6224 6201
 
6225 6202
     if grep -Fxq "install_owncloud_music_app" $COMPLETION_FILE; then
6226 6203
         return
@@ -6671,27 +6648,7 @@ function install_gogs {
6671 6648
     systemctl set-environment GOPATH=/home/git/go
6672 6649
 
6673 6650
     # update to the next commit
6674
-    if [ -d /var/www/$GIT_DOMAIN_NAME ]; then
6675
-        if grep -q "Gogs commit" $COMPLETION_FILE; then
6676
-            CURRENT_GOGS_COMMIT=$(grep "Gogs commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
6677
-            if [[ "$CURRENT_GOGS_COMMIT" != "$GOGS_COMMIT" ]]; then
6678
-                cd $GOPATH/src/github.com/gogits/gogs
6679
-                git_pull $GIT_DOMAIN_REPO $GOGS_COMMIT
6680
-                sed -i "s/Gogs commit.*/Gogs commit:$GOGS_COMMIT/g" $COMPLETION_FILE
6681
-                go get -u ./...
6682
-                if [ ! "$?" = "0" ]; then
6683
-                    exit 52792
6684
-                fi
6685
-                go build
6686
-                if [ ! "$?" = "0" ]; then
6687
-                    exit 36226
6688
-                fi
6689
-                systemctl restart gogs
6690
-            fi
6691
-        else
6692
-            echo "Gogs commit:$GOGS_COMMIT" >> $COMPLETION_FILE
6693
-        fi
6694
-    fi
6651
+    set_repo_commit $GOPATH/src/github.com/gogits/gogs "Gogs commit" "$GOGS_COMMIT" $GIT_DOMAIN_REPO
6695 6652
 
6696 6653
     if grep -Fxq "install_gogs" $COMPLETION_FILE; then
6697 6654
         return
@@ -7010,23 +6967,7 @@ function install_tox_node {
7010 6967
     fi
7011 6968
 
7012 6969
     # update to the next commit
7013
-    if [ -d $INSTALL_DIR/toxcore ]; then
7014
-        if grep -q "toxcore commit" $COMPLETION_FILE; then
7015
-            CURRENT_TOX_COMMIT=$(grep "toxcore commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
7016
-            if [[ "$CURRENT_TOX_COMMIT" != "$TOX_COMMIT" ]]; then
7017
-                cd $INSTALL_DIR/toxcore
7018
-                git_pull $TOX_REPO $TOX_COMMIT
7019
-                sed -i "s/toxcore commit.*/toxcore commit:$TOX_COMMIT/g" $COMPLETION_FILE
7020
-                autoreconf -i
7021
-                ./configure --enable-daemon
7022
-                make
7023
-                make install
7024
-                systemctl restart tox-bootstrapd.service
7025
-            fi
7026
-        else
7027
-            echo "toxcore commit:$TOX_COMMIT" >> $COMPLETION_FILE
7028
-        fi
7029
-    fi
6970
+    set_repo_commit $INSTALL_DIR/toxcore "toxcore commit" "$TOX_COMMIT" $TOX_REPO
7030 6971
 
7031 6972
     if grep -Fxq "install_tox_node" $COMPLETION_FILE; then
7032 6973
         return
@@ -7176,20 +7117,7 @@ function install_tox_client {
7176 7117
     fi
7177 7118
 
7178 7119
     # update to the next commit
7179
-    if [ -d $INSTALL_DIR/toxic ]; then
7180
-        if grep -q "Toxic commit" $COMPLETION_FILE; then
7181
-            CURRENT_TOXIC_COMMIT=$(grep "Toxic commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
7182
-            if [[ "$CURRENT_TOXIC_COMMIT" != "$TOXIC_COMMIT" ]]; then
7183
-                cd $INSTALL_DIR/toxic
7184
-                git_pull $TOXIC_REPO $TOXIC_COMMIT
7185
-                sed -i "s/Toxic commit.*/Toxic commit:$TOXIC_COMMIT/g" $COMPLETION_FILE
7186
-                make
7187
-                make install
7188
-            fi
7189
-        else
7190
-            echo "Toxic commit:$TOXIC_COMMIT" >> $COMPLETION_FILE
7191
-        fi
7192
-    fi
7120
+    set_repo_commit $INSTALL_DIR/toxic "Toxix commit" "$TOXIC_COMMIT" $TOXIC_REPO
7193 7121
 
7194 7122
     if grep -Fxq "install_tox_client" $COMPLETION_FILE; then
7195 7123
         return
@@ -7932,19 +7860,7 @@ function install_blog {
7932 7860
     fi
7933 7861
 
7934 7862
     # update to the next commit
7935
-    if [ -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs ]; then
7936
-        if grep -q "Blog commit" $COMPLETION_FILE; then
7937
-            CURRENT_FULLBLOG_COMMIT=$(grep "Blog commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
7938
-            if [[ "$CURRENT_FULLBLOG_COMMIT" != "$FULLBLOG_COMMIT" ]]; then
7939
-                cd /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
7940
-                git_pull $FULLBLOG_REPO $FULLBLOG_COMMIT
7941
-                sed -i "s/Blog commit.*/Blog commit:$FULLBLOG_COMMIT/g" $COMPLETION_FILE
7942
-                chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs
7943
-            fi
7944
-        else
7945
-            echo "Blog commit:$FULLBLOG_COMMIT" >> $COMPLETION_FILE
7946
-        fi
7947
-    fi
7863
+    set_repo_commit /var/www/$FULLBLOG_DOMAIN_NAME/htdocs "Blog commit" "$FULLBLOG_COMMIT" $FULLBLOG_REPO
7948 7864
 
7949 7865
     if grep -Fxq "install_blog" $COMPLETION_FILE; then
7950 7866
         return
@@ -8304,29 +8220,8 @@ function install_rss_reader {
8304 8220
         return
8305 8221
     fi
8306 8222
 
8307
-    RSS_READER_PATH=/etc/share/tt-rss
8308
-
8309 8223
     # update to the next commit
8310
-    if [ -d $RSS_READER_PATH ]; then
8311
-        if grep -q "RSS reader commit" $COMPLETION_FILE; then
8312
-            CURRENT_RSS_READER_COMMIT=$(grep "RSS reader commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
8313
-            if [[ "$CURRENT_RSS_READER_COMMIT" != "$RSS_READER_COMMIT" ]]; then
8314
-                cd $RSS_READER_PATH
8315
-                git_pull $RSS_READER_REPO $RSS_READER_COMMIT
8316
-                sed -i "s/RSS reader commit.*/RSS reader commit:$RSS_READER_COMMIT/g" $COMPLETION_FILE
8317
-                # ensure that socks5 proxy is used
8318
-                if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/plugins/af_unburn/init.php; then
8319
-                    sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/plugins/af_unburn/init.php
8320
-                fi
8321
-                if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/include/functions.php; then
8322
-                    sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/include/functions.php
8323
-                fi
8324
-                chown -R www-data:www-data $RSS_READER_PATH
8325
-            fi
8326
-        else
8327
-            echo "RSS reader commit:$RSS_READER_COMMIT" >> $COMPLETION_FILE
8328
-        fi
8329
-    fi
8224
+    set_repo_commit $RSS_READER_PATH "RSS reader commit" "$RSS_READER_COMMIT" $RSS_READER_REPO
8330 8225
 
8331 8226
     if grep -Fxq "install_rss_reader" $COMPLETION_FILE; then
8332 8227
         return
@@ -8562,19 +8457,7 @@ function install_rss_mobile_reader {
8562 8457
     fi
8563 8458
 
8564 8459
     # update to the next commit
8565
-    if [ -d $RSS_MOBILE_READER_PATH ]; then
8566
-        if grep -q "RSS mobile reader commit" $COMPLETION_FILE; then
8567
-            CURRENT_RSS_MOBILE_READER_COMMIT=$(grep "RSS mobile reader commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
8568
-            if [[ "$CURRENT_RSS_MOBILE_READER_COMMIT" != "$RSS_MOBILE_READER_COMMIT" ]]; then
8569
-                cd $RSS_MOBILE_READER_PATH
8570
-                git_pull $RSS_MOBILE_READER_REPO $RSS_MOBILE_READER_COMMIT
8571
-                sed -i "s/RSS mobile reader commit.*/RSS mobile reader commit:$RSS_MOBILE_READER_COMMIT/g" $COMPLETION_FILE
8572
-                chown -R www-data:www-data $RSS_MOBILE_READER_PATH
8573
-            fi
8574
-        else
8575
-            echo "RSS mobile reader commit:$RSS_MOBILE_READER_COMMIT" >> $COMPLETION_FILE
8576
-        fi
8577
-    fi
8460
+    set_repo_commit $RSS_MOBILE_READER_PATH "RSS mobile reader commit" "$RSS_MOBILE_READER_COMMIT" $RSS_MOBILE_READER_REPO
8578 8461
 
8579 8462
     if grep -Fxq "install_rss_mobile_reader" $COMPLETION_FILE; then
8580 8463
         return
@@ -8614,19 +8497,7 @@ function install_gnu_social {
8614 8497
     fi
8615 8498
 
8616 8499
     # update to the next commit
8617
-    if [ -d /var/www/$MICROBLOG_DOMAIN_NAME/htdocs ]; then
8618
-        if grep -q "GNU Social commit" $COMPLETION_FILE; then
8619
-            CURRENT_MICROBLOG_COMMIT=$(grep "GNU Social commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
8620
-            if [[ "$CURRENT_MICROBLOG_COMMIT" != "$MICROBLOG_COMMIT" ]]; then
8621
-                cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs
8622
-                git_pull $MICROBLOG_REPO $MICROBLOG_COMMIT
8623
-                sed -i "s/GNU Social commit.*/GNU Social commit:$MICROBLOG_COMMIT/g" $COMPLETION_FILE
8624
-                chown -R www-data:www-data /var/www/$MICROBLOG_DOMAIN_NAME/htdocs
8625
-            fi
8626
-        else
8627
-            echo "GNU Social commit:$MICROBLOG_COMMIT" >> $COMPLETION_FILE
8628
-        fi
8629
-    fi
8500
+    set_repo_commit /var/www/$MICROBLOG_DOMAIN_NAME/htdocs "GNU Social commit" "$MICROBLOG_COMMIT" $MICROBLOG_REPO
8630 8501
 
8631 8502
     if grep -Fxq "install_gnu_social" $COMPLETION_FILE; then
8632 8503
         return
@@ -9001,19 +8872,7 @@ function install_gnu_social_theme {
9001 8872
     fi
9002 8873
 
9003 8874
     # update to the next commit
9004
-    if grep -q "addPlugin('Qvitter')" /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/config.php; then
9005
-        if grep -q "GNU Social theme commit" $COMPLETION_FILE; then
9006
-            CURRENT_MICROBLOG_THEME_COMMIT=$(grep "GNU Social theme commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
9007
-            if [[ "$CURRENT_MICROBLOG_THEME_COMMIT" != "$MICROBLOG_THEME_COMMIT" ]]; then
9008
-                cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/local/plugins/Qvitter
9009
-                git_pull $MICROBLOG_THEME_REPO $MICROBLOG_THEME_COMMIT
9010
-                sed -i "s/GNU Social theme commit.*/GNU Social theme commit:$MICROBLOG_THEME_COMMIT/g" $COMPLETION_FILE
9011
-                chown -R www-data:www-data /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/local
9012
-            fi
9013
-        else
9014
-            echo "GNU Social theme commit:$MICROBLOG_THEME_COMMIT" >> $COMPLETION_FILE
9015
-        fi
9016
-    fi
8875
+    set_repo_commit /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/local/plugins/Qvitter "GNU Social theme commit" "$MICROBLOG_THEME_COMMIT" $MICROBLOG_THEME_REPO
9017 8876
 
9018 8877
     if grep -Fxq "install_gnu_social_theme" $COMPLETION_FILE; then
9019 8878
         return
@@ -9100,19 +8959,7 @@ function install_gnu_social_markdown {
9100 8959
     fi
9101 8960
 
9102 8961
     # update to the next commit
9103
-    if grep -q "addPlugin('Markdown'" /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/config.php; then
9104
-        if grep -q "GNU Social Markdown commit" $COMPLETION_FILE; then
9105
-            CURRENT_MICROBLOG_MARKDOWN_COMMIT=$(grep "GNU Social Markdown commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
9106
-            if [[ "$CURRENT_MICROBLOG_MARKDOWN_COMMIT" != "$MICROBLOG_MARKDOWN_COMMIT" ]]; then
9107
-                cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/local/plugins/Markdown
9108
-                git_pull $MICROBLOG_MARKDOWN_REPO $MICROBLOG_MARKDOWN_COMMIT
9109
-                sed -i "s/GNU Social Markdown commit.*/GNU Social Markdown commit:$MICROBLOG_MARKDOWN_COMMIT/g" $COMPLETION_FILE
9110
-                chown -R www-data:www-data /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/local
9111
-            fi
9112
-        else
9113
-            echo "GNU Social Markdown commit:$MICROBLOG_MARKDOWN_COMMIT" >> $COMPLETION_FILE
9114
-        fi
9115
-    fi
8962
+    set_repo_commit /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/local/plugins/Markdown "GNU Social Markdown commit" "$MICROBLOG_MARKDOWN_COMMIT" $MICROBLOG_MARKDOWN_REPO
9116 8963
 
9117 8964
     if grep -Fxq "install_gnu_social_markdown" $COMPLETION_FILE; then
9118 8965
         return
@@ -9155,31 +9002,9 @@ function install_hubzilla {
9155 9002
         return
9156 9003
     fi
9157 9004
 
9158
-    # update to the next commit
9159
-    if [ -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs ]; then
9160
-        if grep -q "Hubzilla commit" $COMPLETION_FILE; then
9161
-            CURRENT_HUBZILLA_COMMIT=$(grep "Hubzilla commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
9162
-            if [[ "$CURRENT_HUBZILLA_COMMIT" != "$HUBZILLA_COMMIT" ]]; then
9163
-                cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
9164
-                git_pull $HUBZILLA_REPO $HUBZILLA_COMMIT
9165
-                sed -i "s/Hubzilla commit.*/Hubzilla commit:$HUBZILLA_COMMIT/g" $COMPLETION_FILE
9166
-                chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
9167
-            fi
9168
-        else
9169
-            echo "Hubzilla commit:$HUBZILLA_COMMIT" >> $COMPLETION_FILE
9170
-        fi
9171
-        if grep -q "Hubzilla addons commit" $COMPLETION_FILE; then
9172
-            CURRENT_HUBZILLA_ADDONS_COMMIT=$(grep "Hubzilla addons commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
9173
-            if [[ "$CURRENT_HUBZILLA_ADDONS_COMMIT" != "$HUBZILLA_ADDONS_COMMIT" ]]; then
9174
-                cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/addon
9175
-                git_pull $HUBZILLA_ADDONS_REPO $HUBZILLA_ADDONS_COMMIT
9176
-                sed -i "s/Hubzilla addons commit.*/Hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT/g" $COMPLETION_FILE
9177
-                chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs
9178
-            fi
9179
-        else
9180
-            echo "Hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT" >> $COMPLETION_FILE
9181
-        fi
9182
-    fi
9005
+    # update to a new commit if needed
9006
+    set_repo_commit /var/www/$HUBZILLA_DOMAIN_NAME/htdocs "Hubzilla commit" "$HUBZILLA_COMMIT" $HUBZILLA_REPO
9007
+    set_repo_commit /var/www/$HUBZILLA_DOMAIN_NAME/htdocs "Hubzilla addons commit" "$HUBZILLA_ADDONS_COMMIT" $HUBZILLA_ADDONS_REPO
9183 9008
 
9184 9009
     if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
9185 9010
         return
@@ -10012,22 +9837,7 @@ function install_dynamicdns {
10012 9837
     fi
10013 9838
 
10014 9839
     # update to the next commit
10015
-    if [ -d $INSTALL_DIR/inadyn ]; then
10016
-        if grep -q "inadyn commit" $COMPLETION_FILE; then
10017
-            CURRENT_INADYN_COMMIT=$(grep "inadyn commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
10018
-            if [[ "$CURRENT_INADYN_COMMIT" != "$INADYN_COMMIT" ]]; then
10019
-                cd $INSTALL_DIR/inadyn
10020
-                git_pull $INADYN_REPO $INADYN_COMMIT
10021
-                sed -i "s/inadyn commit.*/inadyn commit:$INADYN_COMMIT/g" $COMPLETION_FILE
10022
-                ./configure
10023
-                USE_OPENSSL=1 make
10024
-                make install
10025
-                systemctl restart inadyn
10026
-            fi
10027
-        else
10028
-            echo "inadyn commit:$INADYN_COMMIT" >> $COMPLETION_FILE
10029
-        fi
10030
-    fi
9840
+    set_repo_commit $INSTALL_DIR/inadyn "inadyn commit" "$INADYN_COMMIT" $INADYN_REPO
10031 9841
 
10032 9842
     if grep -Fxq "install_dynamicdns" $COMPLETION_FILE; then
10033 9843
         return
@@ -10128,21 +9938,7 @@ function install_ipfs {
10128 9938
     systemctl set-environment GOPATH=/home/git/go
10129 9939
 
10130 9940
     # update to the next commit
10131
-    if [ -d /home/git/go/src/github.com/ipfs/go-ipfs ]; then
10132
-        if grep -q "ipfs commit" $COMPLETION_FILE; then
10133
-            CURRENT_IPFS_COMMIT=$(grep "ipfs commit" $COMPLETION_FILE | awk -F ':' '{print $2}')
10134
-            if [[ "$CURRENT_IPFS_COMMIT" != "$IPFS_COMMIT" ]]; then
10135
-                cd /home/git/go/src/github.com/ipfs/go-ipfs
10136
-                git_pull $IPFS_GO_REPO $IPFS_COMMIT
10137
-                sed -i "s/ipfs commit.*/ipfs commit:$IPFS_COMMIT/g" $COMPLETION_FILE
10138
-                chown -R git:git /home/git
10139
-                systemctl restart ipfs
10140
-                systemctl daemon-reload
10141
-            fi
10142
-        else
10143
-            echo "ipfs commit:$IPFS_COMMIT" >> $COMPLETION_FILE
10144
-        fi
10145
-    fi
9941
+    set_repo_commit /home/git/go/src/github.com/ipfs/go-ipfs "ipfs commit" "$IPFS_COMMIT" $IPFS_REPO
10146 9942
 
10147 9943
     if grep -Fxq "install_ipfs" $COMPLETION_FILE; then
10148 9944
         return