k 5 test: cac -> cac-api, cacpanel -> cac-panel
This commit is contained in:
parent
f7d979b21f
commit
cc1a230fd2
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, coreutils,makeWrapper, cac, cacpanel, gnumake, gnused, jq, openssh, ... }:
|
{ stdenv, coreutils,makeWrapper, cac-api, cac-panel, gnumake, gnused, jq, openssh, ... }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "${shortname}-${version}";
|
name = "${shortname}-${version}";
|
||||||
@ -14,8 +14,8 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
path = stdenv.lib.makeSearchPath "bin" [
|
path = stdenv.lib.makeSearchPath "bin" [
|
||||||
coreutils
|
coreutils
|
||||||
cac
|
cac-api
|
||||||
cacpanel
|
cac-panel
|
||||||
gnumake
|
gnumake
|
||||||
gnused
|
gnused
|
||||||
jq
|
jq
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# nix-shell -p gnumake jq openssh cac cacpanel
|
# nix-shell -p gnumake jq openssh cac-api cac-panel
|
||||||
set -eufx
|
set -eufx
|
||||||
|
|
||||||
# 2 secrets are required:
|
# 2 secrets are required:
|
||||||
@ -40,22 +40,22 @@ defer "rm -r $krebs_secrets"
|
|||||||
|
|
||||||
cat > $sec_file <<EOF
|
cat > $sec_file <<EOF
|
||||||
cac_login="$(jq -r .email $krebs_cred)"
|
cac_login="$(jq -r .email $krebs_cred)"
|
||||||
cac_key="$(cac-cli --config $krebs_cred panel settings | jq -r .apicode)"
|
cac_key="$(cac-panel --config $krebs_cred settings | jq -r .apicode)"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
export cac_secrets=$sec_file
|
export cac_secrets=$sec_file
|
||||||
cac-cli --config $krebs_cred panel add-api-ip
|
cac-panel --config $krebs_cred add-api-ip
|
||||||
|
|
||||||
# test login:
|
# test login:
|
||||||
cac update
|
cac-api update
|
||||||
cac servers
|
cac-api servers
|
||||||
|
|
||||||
# preserve old trap
|
# preserve old trap
|
||||||
old_trapstr=$(clear_defer)
|
old_trapstr=$(clear_defer)
|
||||||
while true;do
|
while true;do
|
||||||
# Template 26: CentOS7
|
# Template 26: CentOS7
|
||||||
# TODO: use cac templates to determine the real Centos7 template in case it changes
|
# TODO: use cac templates to determine the real Centos7 template in case it changes
|
||||||
out=$(cac build cpu=1 ram=512 storage=10 os=26 2>&1)
|
out=$(cac-api build cpu=1 ram=512 storage=10 os=26 2>&1)
|
||||||
if name=$(echo "$out" | jq -r .servername);then
|
if name=$(echo "$out" | jq -r .servername);then
|
||||||
id=servername:$name
|
id=servername:$name
|
||||||
echo "got a working machine, id=$id"
|
echo "got a working machine, id=$id"
|
||||||
@ -87,7 +87,7 @@ while true;do
|
|||||||
# die on timeout
|
# die on timeout
|
||||||
if ! wait_login_cac $id;then
|
if ! wait_login_cac $id;then
|
||||||
echo "unable to boot a working system within time frame, retrying..." >&2
|
echo "unable to boot a working system within time frame, retrying..." >&2
|
||||||
echo "Cleaning up old image,last status: $(cac update;cac getserver $id | jq -r .status)"
|
echo "Cleaning up old image,last status: $(cac-api update;cac-api getserver $id | jq -r .status)"
|
||||||
eval "$(clear_defer | sed 's/;exit//')"
|
eval "$(clear_defer | sed 's/;exit//')"
|
||||||
sleep 15
|
sleep 15
|
||||||
else
|
else
|
||||||
@ -96,17 +96,17 @@ while true;do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
clear_defer >/dev/null
|
clear_defer >/dev/null
|
||||||
defer "cac delete $id;$old_trapstr"
|
defer "cac-api delete $id;$old_trapstr"
|
||||||
|
|
||||||
mkdir -p shared/2configs/temp
|
mkdir -p shared/2configs/temp
|
||||||
cac generatenetworking $id > \
|
cac-api generatenetworking $id > \
|
||||||
shared/2configs/temp/networking.nix
|
shared/2configs/temp/networking.nix
|
||||||
# new temporary ssh key we will use to log in after infest
|
# new temporary ssh key we will use to log in after infest
|
||||||
ssh-keygen -f $krebs_ssh -N ""
|
ssh-keygen -f $krebs_ssh -N ""
|
||||||
cp $retiolum_key $krebs_secrets/retiolum.rsa_key.priv
|
cp $retiolum_key $krebs_secrets/retiolum.rsa_key.priv
|
||||||
# we override the directories for secrets and stockholm
|
# we override the directories for secrets and stockholm
|
||||||
# additionally we set the ssh key we generated
|
# additionally we set the ssh key we generated
|
||||||
ip=$(cac getserver $id | jq -r .ip)
|
ip=$(cac-api getserver $id | jq -r .ip)
|
||||||
|
|
||||||
cat > shared/2configs/temp/dirs.nix <<EOF
|
cat > shared/2configs/temp/dirs.nix <<EOF
|
||||||
_: {
|
_: {
|
||||||
@ -123,13 +123,13 @@ EOF
|
|||||||
|
|
||||||
LOGNAME=shared make eval get=krebs.infest \
|
LOGNAME=shared make eval get=krebs.infest \
|
||||||
target=derp system=test-centos7 filter=json \
|
target=derp system=test-centos7 filter=json \
|
||||||
| sed -e "s#^ssh.*<<#cac ssh $id<<#" \
|
| sed -e "s#^ssh.*<<#cac-api ssh $id<<#" \
|
||||||
-e "/^rsync/a -e 'cac ssh $id' \\\\" \
|
-e "/^rsync/a -e 'cac-api ssh $id' \\\\" \
|
||||||
-e "s#root.derp:#:#" > $krebs_secrets/infest
|
-e "s#root.derp:#:#" > $krebs_secrets/infest
|
||||||
sh -x $krebs_secrets/infest
|
sh -x $krebs_secrets/infest
|
||||||
|
|
||||||
# TODO: generate secrets directory $krebs_secrets for nix import
|
# TODO: generate secrets directory $krebs_secrets for nix import
|
||||||
cac powerop $id reset
|
cac-api powerop $id reset
|
||||||
|
|
||||||
wait_login(){
|
wait_login(){
|
||||||
# timeout
|
# timeout
|
||||||
|
Loading…
Reference in New Issue
Block a user