add _km.lib and move functions to it

On branch master
Changes to be committed:

	new file:   _km.lib
	modified:   init.sh
	modified:   scripts/middleman.sh
	modified:   scripts/server_ssh.sh
	modified:   setup.sh