more bash fixes in upgrade.sh