move common part into one script

Change-Id: I74f646a92bf72f5d0081c1cf10adc54727fa4603