2014-02-20 16:19:43 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2014-02-21 18:59:46 +00:00
|
|
|
[[ "$1" == "--sudo" ]] && prefix="sudo " && shift
|
2015-09-27 02:35:05 +00:00
|
|
|
[[ "$1" == "--password" ]] && shift && prefix="echo \"$1\" | sudo -S true && sudo " && 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
|
|
|
|
2015-09-27 01:30:55 +00:00
|
|
|
kickstart compile "$@"
|
|
|
|
|
|
|
|
copy_command=$(
|
2014-02-20 16:19:43 +00:00
|
|
|
cat <<CMD
|
2015-09-26 03:51:19 +00:00
|
|
|
{
|
2015-09-26 03:31:38 +00:00
|
|
|
deploy_folder=\$(mktemp -d -t kickstart.XXXXX)
|
|
|
|
mkdir -p "\$deploy_folder"
|
|
|
|
cd "\$deploy_folder"
|
2014-02-20 16:19:43 +00:00
|
|
|
tar xz
|
2015-09-27 01:30:55 +00:00
|
|
|
echo "\$deploy_folder"
|
|
|
|
}
|
|
|
|
CMD
|
|
|
|
)
|
|
|
|
deploy_folder=$(tar chz -C compile . | ssh $target "bash -c '$copy_command'")
|
|
|
|
|
|
|
|
execute_command=$(
|
|
|
|
cat <<CMD
|
|
|
|
{
|
|
|
|
cd $deploy_folder
|
2015-06-26 15:13:41 +00:00
|
|
|
exit_status=0
|
|
|
|
$prefix bash $debug install.sh || exit_status=\$?
|
2015-09-27 01:30:55 +00:00
|
|
|
rm -rf "$deploy_folder"
|
2015-06-26 15:13:41 +00:00
|
|
|
exit \$exit_status
|
2015-09-26 03:51:19 +00:00
|
|
|
}
|
2014-02-20 16:19:43 +00:00
|
|
|
CMD
|
|
|
|
)
|
2015-09-27 02:44:25 +00:00
|
|
|
ssh -t $target "bash -c '$execute_command'"
|