Browse Source

Only add web client if a corresponding domain variable exists

Bob Mottram 6 years ago
parent
commit
95b0f1cbee
1 changed files with 26 additions and 21 deletions
  1. 26
    21
      src/freedombone-utils-android

+ 26
- 21
src/freedombone-utils-android View File

58
                 "${app_name_upper}_DESCRIPTION"=
58
                 "${app_name_upper}_DESCRIPTION"=
59
                 "${app_name_upper}_ICON_URL"=
59
                 "${app_name_upper}_ICON_URL"=
60
                 "${app_name_upper}_MOBILE_APP_URL"=
60
                 "${app_name_upper}_MOBILE_APP_URL"=
61
-                if ! grep "${app_name_upper}_SHORT_DESCRIPTION=" "$app_filename"; then
61
+                if grep -q "${app_name_upper}_SHORT_DESCRIPTION=" "$app_filename"; then
62
                     # shellcheck disable=SC2140
62
                     # shellcheck disable=SC2140
63
                     "${app_name_upper}_SHORT_DESCRIPTION"="$(grep "${app_name_upper}_SHORT_DESCRIPTION=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
63
                     "${app_name_upper}_SHORT_DESCRIPTION"="$(grep "${app_name_upper}_SHORT_DESCRIPTION=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
64
                 fi
64
                 fi
65
-                if ! grep "${app_name_upper}_DESCRIPTION=" "$app_filename"; then
65
+                if grep -q "${app_name_upper}_DESCRIPTION=" "$app_filename"; then
66
                     # shellcheck disable=SC2140
66
                     # shellcheck disable=SC2140
67
                     "${app_name_upper}_DESCRIPTION"="$(grep "${app_name_upper}_DESCRIPTION=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
67
                     "${app_name_upper}_DESCRIPTION"="$(grep "${app_name_upper}_DESCRIPTION=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
68
                 fi
68
                 fi
69
-                if ! grep "${app_name_upper}_ICON_URL=" "$app_filename"; then
69
+                if grep -q "${app_name_upper}_ICON_URL=" "$app_filename"; then
70
                     # shellcheck disable=SC2140
70
                     # shellcheck disable=SC2140
71
                     "${app_name_upper}_ICON_URL"="$(grep "${app_name_upper}_ICON_URL=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
71
                     "${app_name_upper}_ICON_URL"="$(grep "${app_name_upper}_ICON_URL=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
72
                 fi
72
                 fi
73
-                if ! grep "${app_name_upper}_MOBILE_APP_URL=" "$app_filename"; then
73
+                if grep -q "${app_name_upper}_MOBILE_APP_URL=" "$app_filename"; then
74
                     # shellcheck disable=SC2140
74
                     # shellcheck disable=SC2140
75
                     "${app_name_upper}_MOBILE_APP_URL"="$(grep "${app_name_upper}_MOBILE_APP_URL=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
75
                     "${app_name_upper}_MOBILE_APP_URL"="$(grep "${app_name_upper}_MOBILE_APP_URL=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
76
                 fi
76
                 fi
77
 
77
 
78
                 { echo '    {';
78
                 { echo '    {';
79
                   echo "      \"name\": \"${app_name}\",";
79
                   echo "      \"name\": \"${app_name}\",";
80
-                  echo "      \"short_description\": \"${app_name_upper}_SHORT_DESCRIPTION\",";
81
-                  echo "      \"description\": \"${app_name_upper}_DESCRIPTION\",";
82
-                  echo "      \"icon_url\": \"${app_name_upper}_ICON_URL\",";
83
-                  echo "      \"clients\": [";
84
-                  echo '        {';
85
-                  echo "          \"name\": \"${app_name}\",";
86
-                  echo "          \"platforms\": [";
87
-                  echo '            {';
88
-                  echo '              "type": "web",';
89
-                  echo "              \"url\": \"${app_name_upper}_DOMAIN_NAME\"";
90
-                  echo '            }';
91
-                  echo '          ]';
92
-                  echo -n '        }'; } >> "$plinth_api"
80
+                  echo "      \"short_description\": \"$((${app_name_upper}_SHORT_DESCRIPTION))\",";
81
+                  echo "      \"description\": \"$((${app_name_upper}_DESCRIPTION))\",";
82
+                  echo "      \"icon_url\": \"$((${app_name_upper}_ICON_URL))\",";
83
+                  echo "      \"clients\": ["; } >> "$plinth_api"
93
 
84
 
94
-                if [[ $(("${app_name_upper}_MOBILE_APP_URL")) ]]; then
95
-                    { echo ',';
96
-                      echo '        {';
85
+                if [ $(("${app_name_upper}_DOMAIN_NAME")) ]; then
86
+                    { echo '        {';
87
+                      echo "          \"name\": \"${app_name}\",";
88
+                      echo "          \"platforms\": [";
89
+                      echo '            {';
90
+                      echo '              "type": "web",';
91
+                      echo "              \"url\": \"$((${app_name_upper}_DOMAIN_NAME))\"";
92
+                      echo '            }';
93
+                      echo '          ]';
94
+                      echo -n '        }'; } >> "$plinth_api"
95
+                fi
96
+
97
+                if [ $(("${app_name_upper}_MOBILE_APP_URL")) ]; then
98
+                    if [ $(("${app_name_upper}_DOMAIN_NAME")) ]; then
99
+                        echo ',' >> "$plinth_api"
100
+                    fi
101
+                    { echo '        {';
97
                       echo "          \"name\": \"${app_name}\",";
102
                       echo "          \"name\": \"${app_name}\",";
98
                       echo "          \"platforms\": [";
103
                       echo "          \"platforms\": [";
99
                       echo '            {';
104
                       echo '            {';
100
                       echo '              "type": "store",';
105
                       echo '              "type": "store",';
101
                       echo '              "os": "android",';
106
                       echo '              "os": "android",';
102
                       echo '              "store_name": "f-droid",';
107
                       echo '              "store_name": "f-droid",';
103
-                      echo "              \"url\": \"${app_name_upper}_MOBILE_APP_URL\"";
108
+                      echo "              \"url\": \"$((${app_name_upper}_MOBILE_APP_URL))\"";
104
                       echo '            }';
109
                       echo '            }';
105
                       echo '          ]';
110
                       echo '          ]';
106
                       echo -n '        }'; } >> "$plinth_api"
111
                       echo -n '        }'; } >> "$plinth_api"