kickstart/lib/kickstart-deploy

29 lines
597 B
Plaintext
Raw Normal View History

2014-02-20 16:19:43 +00:00
#!/bin/bash -e
2014-02-21 18:59:46 +00:00
[[ "$1" == "--sudo" ]] && prefix="sudo " && shift
2014-02-22 00:27:32 +00:00
[[ "$1" == "--password" ]] && shift && prefix="echo \"$1\" | sudo -S " && shift
2014-02-21 18:59:46 +00:00
2014-02-20 16:19:43 +00:00
target=$1
[ "$target" ] || echo "Please, provide an ssh target"
shift
2014-02-22 00:14:39 +00:00
[ "$DEBUG" ] && debug="-x"
2014-02-21 18:59:46 +00:00
2014-02-20 16:19:43 +00:00
remote_command=$(
cat <<CMD
{
deploy_folder=\$(mktemp -d -t kickstart.XXXXX)
mkdir -p "\$deploy_folder"
cd "\$deploy_folder"
2014-02-20 16:19:43 +00:00
tar xz
exit_status=0
$prefix bash $debug install.sh || exit_status=\$?
rm -rf "\$deploy_folder"
exit \$exit_status
}
2014-02-20 16:19:43 +00:00
CMD
)
2015-05-20 20:16:16 +00:00
kickstart compile "$@"
tar chz -C compile . | ssh $target "bash -c '$remote_command'"