experimental attempt at converting setup.sh to JS

I'm leaving setup.sh as is for now, until this stabilizes. See issue
#273