3 targetHost=${targetHost%/}
5 source "$targetHost/config"
8 trap "eval \$(ssh-agent -k)" EXIT
11 printf '\e]0;%s\007' "$1"
15 if ! [[ -f reset-vm-key ]]; then
16 ssh-keygen -f reset-vm-key -t ed25519 -N ""
19 printf "command=\"bash reset1\" "
23 ssh_target -t 'ip a show dev enp0s3; sudo poweroff'
27 echo "Waiting for VM to respond: "
28 while ! ping -c 1 -W 1 "${to#*@}" > /dev/null; do
32 while ! ssh_target 'echo Got into VM'; do
34 echo "Please open the VM for my key"
38 title 'S1: apt-get; clone'
39 ssh_target -t "( sudo apt-get update | cat ) && ( DEBIAN_FRONTEND=noninteractive sudo -E apt-get upgrade -o Dpkg::Options::=\"--force-confold\" -y | cat ) && ( sudo apt-get install -y git curl $devPkgs | cat )"
41 ssh_target -t '[[ -d .git ]] || git init;'
43 git bundle create .fullBundle HEAD
44 cat .fullBundle | ssh_target 'cat > .fullBundle'
45 ssh_target 'git fetch .fullBundle HEAD:refs/remotes/origin/master; rm .fullBundle'
48 ssh_target -t 'if ! git rev-parse --verify master &> /dev/null; then git checkout origin/master; else git merge --ff-only origin/master; fi'
54 if [[ $first == "true" ]]; then
57 echo "Please provide the NRE archives in 'nre-results/*.tar.gz' or install them manually into the target."
58 read -p "press enter to continue" tmp
61 if ssh_target '[ -d modules/cassiopeia_client/files/profiles ] && [ -d modules/nre/files/config/profiles ]'; then
62 echo cassiopeia-client and nre-conf files found
64 echo cassiopeia-client or nre-conf files not found
67 if [[ "$signerLocation" == "self" ]]; then
68 if ssh_target '[ -d modules/cassiopeia_signer/files/profiles ]'; then
69 echo cassiopeia-signer files found
71 echo cassiopeia-signer files not found
74 if ssh_target '[ -d modules/cassiopeia/files ]'; then
75 echo external keys with self-signer?? wrong!
77 #TODO make more intelligent... only allow if key-pair exists
80 if ssh_target '[ -d modules/cassiopeia/files ]'; then
81 echo external keys with self-signer found
83 echo external keys with self-signer not found
90 function execute-bootstrap-user-auto {
93 ssh_target -t -t 'bash bootstrap-user'
95 echo "waiting for bootstrap-user..."
96 if [[ $need_sudo == "true" ]]; then
97 read -sp "sudo: " sudo
98 if [[ $sudo != "" ]]; then
99 printf '%s\n' "$sudo" >&${COPROC[1]}
103 while [[ $line != "We need a first "* ]]; do
104 if ! read -r line <&${COPROC[0]}; then
105 echo "Error, bootstrap terminated early"
110 bootstrapper_details >&${COPROC[1]}
112 while [[ $line != "You should now have been sent an activation link to the email"* ]]; do
113 if ! read -r line <&${COPROC[0]}; then
114 echo "Error, bootstrap terminated early"
117 printf '%s\n' "$line"
119 read_activation_link >&${COPROC[1]}
123 if [[ "$2" == "fresh" ]]; then
127 if ssh_target "sudo -n whoami" > /dev/null; then
128 echo "Sudo does not need a password, great!"
133 if [[ "$2" == "update" ]]; then
142 ssh_target -t 'sudo ./bootstrap'
144 ssh_target -t 'sudo ./bootstrap'
146 if [[ -f tricks ]]; then
147 cat tricks | ssh_target 'cat > tricks && chmod +x tricks'
148 ssh_target -t 'bash tricks'
151 if [[ $signerLocation == "self" ]] && [[ $(ssh_target 'ps -ef | grep tcpseria[l] | wc -l') != "2" ]]; then
152 echo "Error some services weren't started"