Bob Mottram пре 8 година
родитељ
комит
ca08ef487d
3 измењених фајлова са 197 додато и 56 уклоњено
  1. 5
    3
      src/freedombone-app-gnusocial
  2. 7
    3
      src/freedombone-app-postactiv
  3. 185
    50
      src/freedombone-utils-gnusocialtools

+ 5
- 3
src/freedombone-app-gnusocial Прегледај датотеку

311
         trap "rm -f $data" 0 1 2 5 15
311
         trap "rm -f $data" 0 1 2 5 15
312
         dialog --backtitle $"Freedombone Control Panel" \
312
         dialog --backtitle $"Freedombone Control Panel" \
313
                --title $"GNU Social" \
313
                --title $"GNU Social" \
314
-               --radiolist $"Choose an operation:" 16 70 7 \
314
+               --radiolist $"Choose an operation:" 17 70 8 \
315
                1 $"Set a background image" off \
315
                1 $"Set a background image" off \
316
                2 $"Set the title" off \
316
                2 $"Set the title" off \
317
                3 $"Set post expiry period (currently $GNUSOCIAL_EXPIRE_MONTHS months)" off \
317
                3 $"Set post expiry period (currently $GNUSOCIAL_EXPIRE_MONTHS months)" off \
318
                4 $"Select Qvitter user interface" off \
318
                4 $"Select Qvitter user interface" off \
319
                5 $"Select Pleroma user interface" off \
319
                5 $"Select Pleroma user interface" off \
320
                6 $"Select Classic user interface" off \
320
                6 $"Select Classic user interface" off \
321
-               7 $"Exit" on 2> $data
321
+               7 $"Select Armadillo user interface" off \
322
+               8 $"Exit" on 2> $data
322
         sel=$?
323
         sel=$?
323
         case $sel in
324
         case $sel in
324
             1) return;;
325
             1) return;;
331
             4) gnusocial_use_qvitter gnusocial;;
332
             4) gnusocial_use_qvitter gnusocial;;
332
             5) gnusocial_use_pleroma gnusocial;;
333
             5) gnusocial_use_pleroma gnusocial;;
333
             6) gnusocial_use_classic gnusocial;;
334
             6) gnusocial_use_classic gnusocial;;
334
-            7) break;;
335
+            7) gnusocial_use_armadillo gnusocial;;
336
+            8) break;;
335
         esac
337
         esac
336
     done
338
     done
337
 }
339
 }

+ 7
- 3
src/freedombone-app-postactiv Прегледај датотеку

313
         trap "rm -f $data" 0 1 2 5 15
313
         trap "rm -f $data" 0 1 2 5 15
314
         dialog --backtitle $"Freedombone Control Panel" \
314
         dialog --backtitle $"Freedombone Control Panel" \
315
                --title $"PostActiv" \
315
                --title $"PostActiv" \
316
-               --radiolist $"Choose an operation:" 16 70 7 \
316
+               --radiolist $"Choose an operation:" 17 70 8 \
317
                1 $"Set a background image" off \
317
                1 $"Set a background image" off \
318
                2 $"Set the title" off \
318
                2 $"Set the title" off \
319
                3 $"Set post expiry period (currently $POSTACTIV_EXPIRE_MONTHS months)" off \
319
                3 $"Set post expiry period (currently $POSTACTIV_EXPIRE_MONTHS months)" off \
320
                4 $"Select Qvitter user interface" off \
320
                4 $"Select Qvitter user interface" off \
321
                5 $"Select Pleroma user interface" off \
321
                5 $"Select Pleroma user interface" off \
322
                6 $"Select Classic user interface" off \
322
                6 $"Select Classic user interface" off \
323
-               7 $"Exit" on 2> $data
323
+               7 $"Select Armadillo user interface" off \
324
+               8 $"Exit" on 2> $data
324
         sel=$?
325
         sel=$?
325
         case $sel in
326
         case $sel in
326
             1) return;;
327
             1) return;;
333
             4) gnusocial_use_qvitter postactiv;;
334
             4) gnusocial_use_qvitter postactiv;;
334
             5) gnusocial_use_pleroma postactiv;;
335
             5) gnusocial_use_pleroma postactiv;;
335
             6) gnusocial_use_classic postactiv;;
336
             6) gnusocial_use_classic postactiv;;
336
-            7) break;;
337
+            7) gnusocial_use_armadillo postactiv;;
338
+            8) break;;
337
         esac
339
         esac
338
     done
340
     done
339
 }
341
 }
789
     #function_check install_nodejs
791
     #function_check install_nodejs
790
     #install_nodejs pleroma-postactiv
792
     #install_nodejs pleroma-postactiv
791
 
793
 
794
+    install_armadillo_front_end "postactiv" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL"
795
+
792
     # Currently Pleroma won't install on ARM systems
796
     # Currently Pleroma won't install on ARM systems
793
     # because it uses node-sass which doesn't support ARM
797
     # because it uses node-sass which doesn't support ARM
794
     if [[ "$(arch)" == "arm"* ]]; then
798
     if [[ "$(arch)" == "arm"* ]]; then

+ 185
- 50
src/freedombone-utils-gnusocialtools Прегледај датотеку

34
 PLEROMA_REPO="https://gitgud.io/lambadalambda/pleroma-fe"
34
 PLEROMA_REPO="https://gitgud.io/lambadalambda/pleroma-fe"
35
 PLEROMA_COMMIT='1f8d30386388f8b91aa84fdbd7861e588aa0d935'
35
 PLEROMA_COMMIT='1f8d30386388f8b91aa84fdbd7861e588aa0d935'
36
 
36
 
37
+ARMADILLO_REPO="https://git.postactiv.com/maiya/Armadillo"
38
+ARMADILLO_COMMIT='ec3938a678f373156c4cbf37926c9a5ab68222c4'
39
+
40
+function qvitter_update_background {
41
+    domain_name="$1"
42
+    ext=$2
43
+
44
+    if [ -d /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img ]; then
45
+        cp bg_custom.${ext} /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img
46
+        if ! grep -q "bg_custom.${ext}" /var/www/${domain_name}/htdocs/config.php; then
47
+            if grep -q 'sitebackground' /var/www/${domain_name}/htdocs/config.php; then
48
+                sed -i '/sitebackground/d' /var/www/${domain_name}/htdocs/config.php
49
+            fi
50
+            echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> /var/www/${domain_name}/htdocs/config.php
51
+        fi
52
+    fi
53
+}
54
+
37
 function pleroma_set_background_image_from_url {
55
 function pleroma_set_background_image_from_url {
38
     domain_name="$1"
56
     domain_name="$1"
39
     url="$2"
57
     url="$2"
58
     fi
76
     fi
59
 
77
 
60
     if [ ${#ext} -gt 0 ]; then
78
     if [ ${#ext} -gt 0 ]; then
61
-        if [ -d /var/www/${domain_name}/htdocs/static ]; then
62
-            cd /var/www/${domain_name}/htdocs/static
79
+        cd /var/www/${domain_name}/htdocs
63
 
80
 
64
-            # remove any existing image
65
-            if [ -f bg_custom.${ext} ]; then
66
-                rm bg_custom.${ext}
67
-            fi
81
+        # remove any existing image
82
+        if [ -f bg_custom.${ext} ]; then
83
+            rm bg_custom.${ext}
84
+        fi
68
 
85
 
69
-            # get the new image
70
-            wget "$url" -O bg_custom.${ext}
71
-            if [ ! -f bg_custom.${ext} ]; then
72
-                echo "$url"
73
-                echo $'Custom background image for pleroma could not be downloaded'
74
-                echo "1"
75
-                return
76
-            fi
86
+        # get the new image
87
+        wget "$url" -O bg_custom.${ext}
88
+        if [ ! -f bg_custom.${ext} ]; then
89
+            echo "$url"
90
+            echo $'Custom background image for pleroma could not be downloaded'
91
+            echo "1"
92
+            return
93
+        fi
77
 
94
 
95
+        if [ -d /var/www/${domain_name}/htdocs/static ]; then
96
+            cd /var/www/${domain_name}/htdocs/static
97
+            cp ../bg_custom.${ext} bg_custom.${ext}
78
             sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" config.json
98
             sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" config.json
79
-
80
-            # update the qvitter background
81
-            if [ -d /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img ]; then
82
-                cp bg_custom.${ext} /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img
83
-                if ! grep -q "bg_custom.${ext}" /var/www/${domain_name}/htdocs/config.php; then
84
-                    if grep -q 'sitebackground' /var/www/${domain_name}/htdocs/config.php; then
85
-                        sed -i '/sitebackground/d' /var/www/${domain_name}/htdocs/config.php
86
-                    fi
87
-                    echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> /var/www/${domain_name}/htdocs/config.php
88
-                fi
89
-            fi
90
-        else
91
-            # qvitter background
92
-            if [ -d /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img ]; then
93
-                cd /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img
94
-
95
-                # remove any existing image
96
-                if [ -f bg_custom.${ext} ]; then
97
-                    rm bg_custom.${ext}
98
-                fi
99
-
100
-                # get the new image
101
-                wget "$url" -O bg_custom.${ext}
102
-                if [ ! -f bg_custom.${ext} ]; then
103
-                    echo "$url"
104
-                    echo $'Custom background image for Qvitter could not be downloaded'
105
-                    echo "3"
106
-                    return
107
-                fi
108
-                if ! grep -q "bg_custom.${ext}" /var/www/${domain_name}/htdocs/config.php; then
109
-                    if grep -q 'sitebackground' /var/www/${domain_name}/htdocs/config.php; then
110
-                        sed -i '/sitebackground/d' /var/www/${domain_name}/htdocs/config.php
111
-                    fi
112
-                    echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> /var/www/${domain_name}/htdocs/config.php
113
-                fi
114
-            fi
115
         fi
99
         fi
100
+
101
+        qvitter_update_background ${domain_name} ${ext}
102
+
103
+        rm bg_custom.${ext}
116
     else
104
     else
117
         echo "2"
105
         echo "2"
118
         return
106
         return
137
     echo "0"
125
     echo "0"
138
 }
126
 }
139
 
127
 
128
+function armadillo_set_background_image_from_url {
129
+    domain_name="$1"
130
+    url="$2"
131
+
132
+    if [ ${#domain_name} -eq 0 ]; then
133
+        echo "1"
134
+        return
135
+    fi
136
+
137
+    ext=
138
+    if [ ${#url} -gt 0 ]; then
139
+        if [[ "$url" == *".jpeg" || "$url" == *".jpg" ]]; then
140
+            ext="jpg"
141
+        fi
142
+        if [[ "$url" == *".png" ]]; then
143
+            ext="png"
144
+        fi
145
+        if [[ "$url" == *".gif" ]]; then
146
+            ext="gif"
147
+        fi
148
+    fi
149
+
150
+    if [ ${#ext} -gt 0 ]; then
151
+        cd /var/www/${domain_name}/htdocs
152
+
153
+        # remove any existing image
154
+        if [ -f bg_custom.${ext} ]; then
155
+            rm bg_custom.${ext}
156
+        fi
157
+
158
+        # get the new image
159
+        wget "$url" -O bg_custom.${ext}
160
+        if [ ! -f bg_custom.${ext} ]; then
161
+            echo "$url"
162
+            echo $'Custom background image for armadillo could not be downloaded'
163
+            echo "1"
164
+            return
165
+        fi
166
+
167
+        if [ -d /var/www/${domain_name}/htdocs/armadillo ]; then
168
+            cd /var/www/${domain_name}/htdocs/armadillo
169
+            cp ../bg_custom.${ext} media/img/bg_custom.${ext}
170
+            sed -i "s|\"background\":.*|\"background\": \"armadillo/media/img/background.jpeg\"," config.json
171
+        fi
172
+
173
+        qvitter_update_background ${domain_name} ${ext}
174
+
175
+        rm bg_custom.${ext}
176
+    else
177
+        echo "2"
178
+        return
179
+    fi
180
+
181
+    echo "0"
182
+}
183
+
140
 function install_qvitter {
184
 function install_qvitter {
141
     domain_name=$1
185
     domain_name=$1
142
     app_name=$2
186
     app_name=$2
238
     fi
282
     fi
239
 }
283
 }
240
 
284
 
285
+function install_armadillo_front_end {
286
+    app_name="$1"
287
+    armadillo_domain="$2"
288
+    background_url="$3"
289
+
290
+    if [ ! -d $INSTALL_DIR/armadillo ]; then
291
+        function_check git_clone
292
+        git_clone $ARMADILLO_REPO $INSTALL_DIR/armadillo
293
+        if [ ! -d $INSTALL_DIR/armadillo ]; then
294
+            echo $'Unable to clone armadillo repo'
295
+            exit 35722
296
+        fi
297
+    fi
298
+
299
+    cd $INSTALL_DIR/armadillo
300
+    git checkout $ARMADILLO_COMMIT -b $ARMADILLO_COMMIT
301
+    set_completion_param "${app_name} armadillo commit" "$ARMADILLO_COMMIT"
302
+
303
+    cp armadillo/config.json.example armadillo/config.json
304
+    sed -i "s|\"server\".*|\"server\": \"${armadillo_domain}\",|g" armadillo/config.json
305
+    cp -r $INSTALL_DIR/armadillo/armadillo /var/www/${armadillo_domain}/htdocs/
306
+    cp $INSTALL_DIR/armadillo/armadillo.html /var/www/${armadillo_domain}/htdocs/index.html
307
+    cp $INSTALL_DIR/armadillo/dash.html /var/www/${armadillo_domain}/htdocs/dash.html
308
+
309
+    armadillo_set_background_image_from_url "$armadillo_domain" "$background_url"
310
+
311
+    nginx_site=/etc/nginx/sites-available/${armadillo_domain}
312
+    sed -i 's|index index.php;|index index.html;|g' $nginx_site
313
+
314
+    if [ -f /var/www/${armadillo_domain}/htdocs/index.php ]; then
315
+        mv /var/www/${armadillo_domain}/htdocs/index.php /var/www/${armadillo_domain}/htdocs/index_qvitter.php
316
+    fi
317
+    sed -i 's|index.php|index_qvitter.php|g' $nginx_site
318
+
319
+    chown -R www-data:www-data /var/www/${armadillo_domain}/htdocs
320
+}
321
+
241
 function install_pleroma_front_end {
322
 function install_pleroma_front_end {
242
     app_name="$1"
323
     app_name="$1"
243
     pleroma_domain="$2"
324
     pleroma_domain="$2"
344
     fi
425
     fi
345
 }
426
 }
346
 
427
 
428
+function upgrade_armadillo {
429
+    domain_name="$1"
430
+    app_name="$2"
431
+    background_url="$3"
432
+
433
+    if [ -d $INSTALL_DIR/armadillo ]; then
434
+        set_repo_commit $INSTALL_DIR/armadillo "${app_name} armadillo commit" "$ARMADILLO_COMMIT" $ARMADILLO_REPO
435
+        cd $INSTALL_DIR/armadillo
436
+
437
+        if [ -f $INSTALL_DIR/armadillo/armadillo/config.json ]; then
438
+            rm $INSTALL_DIR/armadillo/armadillo/config.json
439
+        fi
440
+        cp -r $INSTALL_DIR/armadillo/armadillo /var/www/${armadillo_domain}/htdocs/
441
+        cp $INSTALL_DIR/armadillo/armadillo.html /var/www/${armadillo_domain}/htdocs/index.html
442
+        cp $INSTALL_DIR/armadillo/dash.html /var/www/${armadillo_domain}/htdocs/dash.html
443
+        chown -R www-data:www-data /var/www/${domain_name}/htdocs
444
+    else
445
+        install_armadillo_front_end "${app_name}" "${domain_name}" "${background_url}"
446
+    fi
447
+}
448
+
347
 function gnusocial_hourly_script {
449
 function gnusocial_hourly_script {
348
     gnusocial_type=$1
450
     gnusocial_type=$1
349
     domain_name=$2
451
     domain_name=$2
711
         sed -i "s|// addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
813
         sed -i "s|// addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
712
     fi
814
     fi
713
 
815
 
816
+    cp $INSTALL_DIR/pleroma/dist/index.html /var/www/${domain_name}/htdocs/index.html
817
+
818
+    systemctl restart nginx
819
+}
820
+
821
+function gnusocial_use_armadillo {
822
+    database_name=$1
823
+
824
+    domain_name=$(get_completion_param "$database_name domain")
825
+
826
+    if [ ! -d /var/www/$domain_name/htdocs/armadillo ]; then
827
+        return
828
+    fi
829
+
830
+    if [ -f /var/www/$domain_name/htdocs/index.php ]; then
831
+        mv /var/www/$domain_name/htdocs/index.php /var/www/$domain_name/htdocs/index_qvitter.php
832
+    fi
833
+
834
+    if [ -f /etc/nginx/sites-available/$domain_name ]; then
835
+        sed -i 's|index.php|index_qvitter.php|g' /etc/nginx/sites-available/$domain_name
836
+        sed -i 's|index index_qvitter.php|index index.html|g' /etc/nginx/sites-available/$domain_name
837
+    fi
838
+
839
+    if grep -q "//addPlugin('Qvitter')" /var/www/$domain_name/htdocs/config.php; then
840
+        sed -i "s|//addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
841
+    fi
842
+    if grep -q "// addPlugin('Qvitter')" /var/www/$domain_name/htdocs/config.php; then
843
+        sed -i "s|// addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
844
+    fi
845
+
846
+    cp $INSTALL_DIR/armadillo/armadillo.html /var/www/${domain_name}/htdocs/index.html
847
+    cp $INSTALL_DIR/armadillo/dash.html /var/www/${domain_name}/htdocs/dash.html
848
+
714
     systemctl restart nginx
849
     systemctl restart nginx
715
 }
850
 }
716
 
851