|  | @@ -40,6 +40,9 @@ APPS_CHOSEN=()
 | 
	
		
			
			| 40 | 40 |  # A list of the names of installed apps
 | 
	
		
			
			| 41 | 41 |  APPS_INSTALLED_NAMES=()
 | 
	
		
			
			| 42 | 42 |  
 | 
	
		
			
			|  | 43 | +# file containing a list of removed apps
 | 
	
		
			
			|  | 44 | +REMOVED_APPS_FILE=/root/removed
 | 
	
		
			
			|  | 45 | +
 | 
	
		
			
			| 43 | 46 |  function app_variants {
 | 
	
		
			
			| 44 | 47 |      filename=$1
 | 
	
		
			
			| 45 | 48 |      variants_line=$(cat ${filename} | grep "VARIANTS=")
 | 
	
	
		
			
			|  | @@ -57,6 +60,40 @@ function item_in_array {
 | 
	
		
			
			| 57 | 60 |      return 1
 | 
	
		
			
			| 58 | 61 |  }
 | 
	
		
			
			| 59 | 62 |  
 | 
	
		
			
			|  | 63 | +function remove_app {
 | 
	
		
			
			|  | 64 | +    app_name=$1
 | 
	
		
			
			|  | 65 | +    if [ ! -f $REMOVED_APPS_FILE ]; then
 | 
	
		
			
			|  | 66 | +        touch $REMOVED_APPS_FILE
 | 
	
		
			
			|  | 67 | +    fi
 | 
	
		
			
			|  | 68 | +    if ! grep -Fxq "$app_name" $REMOVED_APPS_FILE; then
 | 
	
		
			
			|  | 69 | +        echo "$app_name" >> $REMOVED_APPS_FILE
 | 
	
		
			
			|  | 70 | +    fi
 | 
	
		
			
			|  | 71 | +}
 | 
	
		
			
			|  | 72 | +
 | 
	
		
			
			|  | 73 | +function app_is_removed {
 | 
	
		
			
			|  | 74 | +    app_name="$1"
 | 
	
		
			
			|  | 75 | +    if [ ! -f $REMOVED_APPS_FILE ]; then
 | 
	
		
			
			|  | 76 | +        echo "0"
 | 
	
		
			
			|  | 77 | +        return
 | 
	
		
			
			|  | 78 | +    fi
 | 
	
		
			
			|  | 79 | +
 | 
	
		
			
			|  | 80 | +    if ! grep -Fxq "$app_name" $REMOVED_APPS_FILE; then
 | 
	
		
			
			|  | 81 | +        echo "0"
 | 
	
		
			
			|  | 82 | +    else
 | 
	
		
			
			|  | 83 | +        echo "1"
 | 
	
		
			
			|  | 84 | +    fi
 | 
	
		
			
			|  | 85 | +}
 | 
	
		
			
			|  | 86 | +
 | 
	
		
			
			|  | 87 | +function reinstall_app {
 | 
	
		
			
			|  | 88 | +    app_name=$1
 | 
	
		
			
			|  | 89 | +    if [ ! -f $REMOVED_APPS_FILE ]; then
 | 
	
		
			
			|  | 90 | +        return
 | 
	
		
			
			|  | 91 | +    fi
 | 
	
		
			
			|  | 92 | +    if [[ $(app_is_removed $app_name) == "1" ]]; then
 | 
	
		
			
			|  | 93 | +        sed -i "/${app_name}/d" $REMOVED_APPS_FILE
 | 
	
		
			
			|  | 94 | +    fi
 | 
	
		
			
			|  | 95 | +}
 | 
	
		
			
			|  | 96 | +
 | 
	
		
			
			| 60 | 97 |  function app_is_installed {
 | 
	
		
			
			| 61 | 98 |      app_name="$1"
 | 
	
		
			
			| 62 | 99 |  
 | 
	
	
		
			
			|  | @@ -213,6 +250,7 @@ function remove_apps {
 | 
	
		
			
			| 213 | 250 |          if [[ ${APPS_INSTALLED[$app_index]} == "1" ]]; then
 | 
	
		
			
			| 214 | 251 |              if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
 | 
	
		
			
			| 215 | 252 |                  echo $"Removing application: ${a}"
 | 
	
		
			
			|  | 253 | +                remove_app ${a}
 | 
	
		
			
			| 216 | 254 |                  remove_${a}
 | 
	
		
			
			| 217 | 255 |                  echo $"${a} was removed"
 | 
	
		
			
			| 218 | 256 |              fi
 | 
	
	
		
			
			|  | @@ -246,9 +284,20 @@ function install_apps {
 | 
	
		
			
			| 246 | 284 |      do
 | 
	
		
			
			| 247 | 285 |          if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
 | 
	
		
			
			| 248 | 286 |              if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
 | 
	
		
			
			| 249 |  | -                echo $"Installing application: ${a}"
 | 
	
		
			
			| 250 |  | -                install_${a}
 | 
	
		
			
			| 251 |  | -                echo $"${a} was installed"
 | 
	
		
			
			|  | 287 | +                if [ ${is_interactive} ]; then
 | 
	
		
			
			|  | 288 | +                    reinstall_app ${a}
 | 
	
		
			
			|  | 289 | +                    echo $"Installing application: ${a}"
 | 
	
		
			
			|  | 290 | +                    install_${a}
 | 
	
		
			
			|  | 291 | +                    echo $"${a} was installed"
 | 
	
		
			
			|  | 292 | +                else
 | 
	
		
			
			|  | 293 | +                    if [[ $(app_is_removed ${a}) == "0" ]]; then
 | 
	
		
			
			|  | 294 | +                        echo $"Installing application: ${a}"
 | 
	
		
			
			|  | 295 | +                        install_${a}
 | 
	
		
			
			|  | 296 | +                        echo $"${a} was installed"
 | 
	
		
			
			|  | 297 | +                    else
 | 
	
		
			
			|  | 298 | +                        echo $"${a} has been removed and so will not be reinstalled"
 | 
	
		
			
			|  | 299 | +                    fi
 | 
	
		
			
			|  | 300 | +                fi
 | 
	
		
			
			| 252 | 301 |              fi
 | 
	
		
			
			| 253 | 302 |          fi
 | 
	
		
			
			| 254 | 303 |          app_index=$[app_index+1]
 |