Write and exec a shell script for configuration

This is less error-prone.  Also, use AnyEvent::Util::run_cmd for exit value and output.