浏览代码

Only add web client if a corresponding domain variable exists

Bob Mottram 6 年前
父节点
当前提交
95b0f1cbee
共有 1 个文件被更改,包括 26 次插入21 次删除
  1. 26
    21
      src/freedombone-utils-android

+ 26
- 21
src/freedombone-utils-android 查看文件

@@ -58,49 +58,54 @@ function android_update_apps {
58 58
                 "${app_name_upper}_DESCRIPTION"=
59 59
                 "${app_name_upper}_ICON_URL"=
60 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 62
                     # shellcheck disable=SC2140
63 63
                     "${app_name_upper}_SHORT_DESCRIPTION"="$(grep "${app_name_upper}_SHORT_DESCRIPTION=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
64 64
                 fi
65
-                if ! grep "${app_name_upper}_DESCRIPTION=" "$app_filename"; then
65
+                if grep -q "${app_name_upper}_DESCRIPTION=" "$app_filename"; then
66 66
                     # shellcheck disable=SC2140
67 67
                     "${app_name_upper}_DESCRIPTION"="$(grep "${app_name_upper}_DESCRIPTION=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
68 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 70
                     # shellcheck disable=SC2140
71 71
                     "${app_name_upper}_ICON_URL"="$(grep "${app_name_upper}_ICON_URL=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
72 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 74
                     # shellcheck disable=SC2140
75 75
                     "${app_name_upper}_MOBILE_APP_URL"="$(grep "${app_name_upper}_MOBILE_APP_URL=" "$app_filename" | head -n 1 | awk -F '=' '{print $2}')"
76 76
                 fi
77 77
 
78 78
                 { echo '    {';
79 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 102
                       echo "          \"name\": \"${app_name}\",";
98 103
                       echo "          \"platforms\": [";
99 104
                       echo '            {';
100 105
                       echo '              "type": "store",';
101 106
                       echo '              "os": "android",';
102 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 109
                       echo '            }';
105 110
                       echo '          ]';
106 111
                       echo -n '        }'; } >> "$plinth_api"