caa3a7378b
To have some interactions on the script we need to allocate a tty. This adds a pseudo-tty to the ssh session. This enables `read -s` on deployment scripts.
39 lines
751 B
Bash
Executable File
39 lines
751 B
Bash
Executable File
#!/bin/bash -e
|
|
|
|
[[ "$1" == "--sudo" ]] && prefix="sudo " && shift
|
|
[[ "$1" == "--password" ]] && shift && prefix="echo \"$1\" | sudo -S true && sudo " && shift
|
|
|
|
target=$1
|
|
[ "$target" ] || echo "Please, provide an ssh target"
|
|
shift
|
|
|
|
[ "$DEBUG" ] && debug="-x"
|
|
|
|
kickstart compile "$@"
|
|
|
|
copy_command=$(
|
|
cat <<CMD
|
|
{
|
|
deploy_folder=\$(mktemp -d -t kickstart.XXXXX)
|
|
mkdir -p "\$deploy_folder"
|
|
cd "\$deploy_folder"
|
|
tar xz
|
|
echo "\$deploy_folder"
|
|
}
|
|
CMD
|
|
)
|
|
deploy_folder=$(tar chz -C compile . | ssh $target "bash -c '$copy_command'")
|
|
|
|
execute_command=$(
|
|
cat <<CMD
|
|
{
|
|
cd $deploy_folder
|
|
exit_status=0
|
|
$prefix bash $debug install.sh || exit_status=\$?
|
|
rm -rf "$deploy_folder"
|
|
exit \$exit_status
|
|
}
|
|
CMD
|
|
)
|
|
ssh -t $target "bash -c '$execute_command'"
|