[SPARK-2964] [SQL] Remove duplicated code from spark-sql and start-thriftserver.sh