7 ssh -i vm-key "$to" "$@"
10 function install_nre {
11 ./installNRE "$targetHost"
13 function read_activation_link {
14 read -rp "Link: " link
18 ssh_target -t 'bash conf-puppet --force'
19 ssh_target 'sed -i "s%\$signerLocation = '".*'"'%\$signerLocation = '"'$signerLocation'"'%" environments/production/manifests/ip.pp'
21 function do_reset_vm {
22 read -rp "Please reset your VM and confirm by pressing enter." _
24 function execute-bootstrap-user {
25 ssh_target -t 'bash bootstrap-user'
28 source "$targetHost/config"
31 trap "eval \$(ssh-agent -k)" EXIT
34 printf '\e]0;%s\007' "$1"
38 if ! [[ -f reset-vm-key ]]; then
39 ssh-keygen -f reset-vm-key -t ed25519 -N ""
42 printf "command=\"bash reset1\" "
46 ssh_target -t 'ip a show dev enp0s3; sudo poweroff'
50 echo "Waiting for VM to respond: "
51 while ! ping -c 1 -W 1 "${to#*@}" > /dev/null; do
55 while ! ssh_target 'echo Got into VM'; do
57 echo "Please open the VM for my key"
61 title 'S1: apt-get; clone'
62 ssh_target -t "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo -E apt-get upgrade -o Dpkg::Options::=\"--force-confold\" -y && sudo apt-get install -y git curl $devPkgs"
64 ssh_target -t '[[ -d .git ]] || git init;'
66 git bundle create .fullBundle HEAD
67 cat .fullBundle | ssh_target 'cat > .fullBundle'
68 ssh_target 'git fetch .fullBundle HEAD:refs/remotes/origin/master; rm .fullBundle'
71 ssh_target -t 'if ! git rev-parse --verify master &> /dev/null; then git checkout origin/master; else git merge --ff-only origin/master; fi'
77 if [[ $first == "true" ]]; then
80 echo "Please provide the NRE archives in 'nre-results/*.tar.gz' or install them manually into the target."
81 read -p "press enter to continue" tmp
84 if ssh_target '[ -d modules/cassiopeia_client/files/profiles ] && [ -d modules/nre/files/config/profiles ]'; then
85 echo cassiopeia-client and nre-conf files found
87 echo cassiopeia-client or nre-conf files not found
90 if [[ "$signerLocation" == "self" ]]; then
91 if ssh_target '[ -d modules/cassiopeia_signer/files/profiles ]'; then
92 echo cassiopeia-signer files found
94 echo cassiopeia-signer files not found
97 if ssh_target '[ -d modules/cassiopeia/files ]'; then
98 echo external keys with self-signer?? wrong!
100 #TODO make more intelligent... only allow if key-pair exists
103 if ssh_target '[ -d modules/cassiopeia/files ]'; then
104 echo external keys with self-signer found
106 echo external keys with self-signer not found
113 function execute-bootstrap-user-auto {
116 ssh_target -t -t 'bash bootstrap-user'
118 echo "waiting for bootstrap-user..."
119 if [[ $need_sudo == "true" ]]; then
120 read -sp "sudo: " sudo
121 if [[ $sudo != "" ]]; then
122 printf '%s\n' "$sudo" >&${COPROC[1]}
126 while [[ $line != "We need a first "* ]]; do
127 if ! read -r line <&${COPROC[0]}; then
128 echo "Error, bootstrap terminated early"
133 bootstrapper_details >&${COPROC[1]}
135 while [[ $line != "You should now have been sent an activation link to the email"* ]]; do
136 if ! read -r line <&${COPROC[0]}; then
137 echo "Error, bootstrap terminated early"
140 printf '%s\n' "$line"
142 read_activation_link >&${COPROC[1]}
146 if [[ "$2" == "fresh" ]]; then
150 if ssh_target "sudo -n whoami" > /dev/null; then
151 echo "Sudo does not need a password, great!"
156 if [[ "$2" == "update" ]]; then
162 ssh_target -t 'sudo ./bootstrap'
164 ssh_target -t 'sudo ./bootstrap'
166 [[ -f ../../migrate ]] && ( cd ../.. && bash migrate "$targetHost")
167 if [[ -f tricks ]]; then
168 cat tricks | ssh_target 'cat > tricks && chmod +x tricks'
169 ssh_target -t 'bash tricks'
172 if [[ $signerLocation == "self" ]] && [[ $(ssh_target 'ps -ef | grep tcpseria[l] | wc -l') != "2" ]]; then
173 echo "Error some services weren't started"
177 execute-bootstrap-user