2014-02-20 15:49:57 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2014-03-02 23:09:25 +00:00
|
|
|
image_name=${1:-$KICKSTART_DOCKER_IMAGE}
|
|
|
|
image_name=${image_name:-moul/sshd}
|
|
|
|
|
2014-02-20 15:49:57 +00:00
|
|
|
pull_sshd_image() {
|
2014-03-02 23:09:25 +00:00
|
|
|
docker pull $image_name
|
2014-02-20 15:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
remove_running_sshd() {
|
2014-03-02 23:09:25 +00:00
|
|
|
runnig_sshd=$(docker ps -q $image_name)
|
2014-02-20 15:49:57 +00:00
|
|
|
[ "$runnig_sshd" ] && docker kill "$runnig_sshd" && docker rm "$runnig_sshd"
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
run_sshd() {
|
2014-03-02 23:09:25 +00:00
|
|
|
id=$(docker run -p 22 -d $image_name)
|
2014-02-20 15:49:57 +00:00
|
|
|
|
|
|
|
[ -z "$id" ] && echo "Docker container did't start" && return 1
|
|
|
|
|
|
|
|
echo "Connect using root:root on " `docker port $id 22`
|
|
|
|
port=`docker port $id 22 | cut -f 2 -d :`
|
2014-02-21 19:02:39 +00:00
|
|
|
echo For ssh: kickstart docker-ssh
|
2014-02-20 15:49:57 +00:00
|
|
|
echo For deploy: kickstart deploy \"-p $port root@localhost\" '[roles]'
|
|
|
|
}
|
|
|
|
|
|
|
|
pull_sshd_image
|
|
|
|
remove_running_sshd
|
|
|
|
run_sshd
|