I incorporated your changes and then added some logic to handle a 'bug' I identified.. So now the script will look at
swap_size in the config file, if it is unset, then it looks at the
deviceinfo_swap_size_recommended variable. It then writes the value of this deviceinfo variable to the config file (if deviceinfo var is not set, then it writes 0 to config).
The reason I did this is because it allows the value in
deviceinfo_swap_size_recommended to actually be used by default. The user can then override this by editing the config file and then whatever is in
deviceinfo_swap_size_recommended would have no effect on the swap size at that point (including device package updates, those would not override user-specific configuration).