Bob Mottram 8 år sedan
förälder
incheckning
6c143c31f2
1 ändrade filer med 22 tillägg och 6 borttagningar
  1. 22
    6
      src/freedombone-utils-selector

+ 22
- 6
src/freedombone-utils-selector Visa fil

43
 # file containing a list of removed apps
43
 # file containing a list of removed apps
44
 REMOVED_APPS_FILE=/root/removed
44
 REMOVED_APPS_FILE=/root/removed
45
 
45
 
46
+# gets the variants list from an app script
46
 function app_variants {
47
 function app_variants {
47
     filename=$1
48
     filename=$1
48
     variants_line=$(cat ${filename} | grep "VARIANTS=")
49
     variants_line=$(cat ${filename} | grep "VARIANTS=")
54
     echo "$variants_list"
55
     echo "$variants_list"
55
 }
56
 }
56
 
57
 
58
+# whether a given item is in an array
57
 function item_in_array {
59
 function item_in_array {
58
     local e
60
     local e
59
     for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
61
     for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
60
     return 1
62
     return 1
61
 }
63
 }
62
 
64
 
65
+# mark a given app as having been removed so that it doesn't get reinstalled on updates
63
 function remove_app {
66
 function remove_app {
64
     app_name=$1
67
     app_name=$1
65
     if [ ! -f $REMOVED_APPS_FILE ]; then
68
     if [ ! -f $REMOVED_APPS_FILE ]; then
70
     fi
73
     fi
71
 }
74
 }
72
 
75
 
76
+# returns 1 if an app has been marked as removed
73
 function app_is_removed {
77
 function app_is_removed {
74
     app_name="$1"
78
     app_name="$1"
75
     if [ ! -f $REMOVED_APPS_FILE ]; then
79
     if [ ! -f $REMOVED_APPS_FILE ]; then
84
     fi
88
     fi
85
 }
89
 }
86
 
90
 
91
+# Allows an app to be reinstalled even if it was previously marked as being removed
87
 function reinstall_app {
92
 function reinstall_app {
88
     app_name=$1
93
     app_name=$1
89
     if [ ! -f $REMOVED_APPS_FILE ]; then
94
     if [ ! -f $REMOVED_APPS_FILE ]; then
94
     fi
99
     fi
95
 }
100
 }
96
 
101
 
102
+# returns 1 if an app is installed
97
 function app_is_installed {
103
 function app_is_installed {
98
     app_name="$1"
104
     app_name="$1"
99
 
105
 
109
         return
115
         return
110
     fi
116
     fi
111
 
117
 
118
+    # check the completion file to see if it was installed
112
     if [ ! -f $COMPLETION_FILE ]; then
119
     if [ ! -f $COMPLETION_FILE ]; then
113
         echo "0"
120
         echo "0"
114
         return
121
         return
121
     fi
128
     fi
122
 }
129
 }
123
 
130
 
131
+# called at the end of the install section of an app script
124
 function install_completed {
132
 function install_completed {
125
     if [ ! ${1} ]; then
133
     if [ ! ${1} ]; then
126
         exit 673935
134
         exit 673935
128
     echo "install_${1}" >> $COMPLETION_FILE
136
     echo "install_${1}" >> $COMPLETION_FILE
129
 }
137
 }
130
 
138
 
139
+# populates an array of "0" or "1" for whether apps are installed
131
 function get_apps_installed {
140
 function get_apps_installed {
132
     for a in "${APPS_AVAILABLE[@]}"
141
     for a in "${APPS_AVAILABLE[@]}"
133
     do
142
     do
135
     done
144
     done
136
 }
145
 }
137
 
146
 
147
+# populates an array of installed app names
138
 function get_apps_installed_names {
148
 function get_apps_installed_names {
139
     APPS_INSTALLED_NAMES=()
149
     APPS_INSTALLED_NAMES=()
140
     for a in "${APPS_AVAILABLE[@]}"
150
     for a in "${APPS_AVAILABLE[@]}"
145
     done
155
     done
146
 }
156
 }
147
 
157
 
158
+# detects what apps are available
148
 function detect_apps {
159
 function detect_apps {
149
     FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
160
     FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
150
 
161
 
166
     get_apps_installed_names
177
     get_apps_installed_names
167
 }
178
 }
168
 
179
 
180
+# detects what apps are available and can be installed
181
+# If the variants list within an app script is an empty string then
182
+# it is considered to be too experimental to be installable
169
 function detect_installable_apps {
183
 function detect_installable_apps {
170
     FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
184
     FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
171
 
185
 
182
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
196
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
183
         if [[ $(item_in_array ${app_name} ${APPS_AVAILABLE[@]}) != 0 ]]; then
197
         if [[ $(item_in_array ${app_name} ${APPS_AVAILABLE[@]}) != 0 ]]; then
184
             variants_list=$(app_variants $filename)
198
             variants_list=$(app_variants $filename)
199
+            # check for empty string
185
             if [ ${#variants_list} -gt 0 ]; then
200
             if [ ${#variants_list} -gt 0 ]; then
186
                 APPS_AVAILABLE+=("${app_name}")
201
                 APPS_AVAILABLE+=("${app_name}")
187
                 APPS_CHOSEN+=("0")
202
                 APPS_CHOSEN+=("0")
236
     get_apps_installed
251
     get_apps_installed
237
 }
252
 }
238
 
253
 
254
+# show a list of apps which have been chosen
239
 function list_chosen_apps {
255
 function list_chosen_apps {
240
     app_index=0
256
     app_index=0
241
     for a in "${APPS_AVAILABLE[@]}"
257
     for a in "${APPS_AVAILABLE[@]}"
270
     app_index=0
286
     app_index=0
271
     for a in "${APPS_AVAILABLE[@]}"
287
     for a in "${APPS_AVAILABLE[@]}"
272
     do
288
     do
273
-        if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
274
-            if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
275
-                if [ ${is_interactive} ]; then
276
-                    # interactively obtain settings for this app
277
-                    if [[ $(function_exists install_interactive_${a}) == "1" ]]; then
278
-                        if [[ $(app_is_removed ${a}) == "0" ]]; then
289
+        if [[ $(app_is_removed ${a}) == "0" ]]; then
290
+            if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
291
+                if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
292
+                    if [ ${is_interactive} ]; then
293
+                        # interactively obtain settings for this app
294
+                        if [[ $(function_exists install_interactive_${a}) == "1" ]]; then
279
                             install_interactive_${a}
295
                             install_interactive_${a}
280
                         fi
296
                         fi
281
                     fi
297
                     fi