diff --git a/docker/create_image.sh b/docker/create_image.sh index f73000b..65f5bda 100755 --- a/docker/create_image.sh +++ b/docker/create_image.sh @@ -7,10 +7,13 @@ cd "${scriptdir}/.." ./scripts/install.sh mkdir -p "${scriptdir}/tmp/.detee/cli/vms" touch "${scriptdir}/tmp/.detee/cli/vms/uuid_list" +mkdir -p "${scriptdir}/tmp/.detee/cli/apps" +touch "${scriptdir}/tmp/.detee/cli/apps/uuid_list" cp -r "${HOME}/.detee/artefacts" "${scriptdir}/tmp/.detee" cp -r "${HOME}/.detee/bin" "${scriptdir}/tmp/.detee" cp -r "${HOME}/.detee/deps" "${scriptdir}/tmp/.detee" cp -r "${HOME}/.detee/samples" "${scriptdir}/tmp/.detee" +cp -r "${HOME}/.detee/certs" "${scriptdir}/tmp/.detee" ${HOME}/.detee/bin/detee-cli completion fish > "${scriptdir}/tmp/.detee/detee-cli.fish" cd "${scriptdir}" diff --git a/scripts/install.sh b/scripts/install.sh index 11aeb2b..1ead112 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -19,10 +19,16 @@ echo_red() { mkdir -p ${HOME}/.detee/bin mkdir -p ${HOME}/.detee/tmp mkdir -p ${HOME}/.detee/deps -mkdir -p ${HOME}/.detee/ +mkdir -p ${HOME}/.detee/certs/ echo_blue "Make sure you add ${HOME}/.detee/bin to your path!" +install_certs() { + [[ -f "${HOME}/.detee/certs/root_ca.pem" ]] || { + wget -O "${HOME}/.detee/certs/root_ca.pem" https://registry.detee.ltd/root_ca.pem + } +} + install_sev-snp-measure() { [[ -e "${HOME}/.detee/bin/sev-snp-measure.py" ]] && { echo_yellow "${HOME}/.detee/bin/sev-snp-measure.py already found. Delete the file to reinstall." @@ -56,9 +62,6 @@ install_detee-cli() { } cargo build --release cp ./target/release/detee-cli ${HOME}/.detee/bin - [[ -f "${HOME}/.detee/cli/root_ca.pem" ]] || { - wget -O "${HOME}/.detee/cli/root_ca.pem" https://registry.detee.ltd/root_ca.pem - } } install_super-detee-cli() { @@ -90,6 +93,7 @@ install_fish_completion() { super-detee-cli completion fish > ${HOME}/.config/fish/completions/super-detee-cli.fish } +install_certs install_sev-snp-measure install_snpguest install_detee-cli diff --git a/src/config.rs b/src/config.rs index 43d51d3..6c09d2b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -304,13 +304,13 @@ impl Config { } pub fn get_root_ca_path() -> Result { - Ok(Self::cli_dir_path()? + "/root_ca.pem") + Ok(Self::home_dir() + "/.detee/certs/root_ca.pem") } pub fn get_brain_info() -> (String, String) { match Self::init_config().network.as_str() { "staging" => ("https://159.65.58.38:31337".to_string(), "staging-brain".to_string()), - _ => ("https://164.92.249.180:31337".to_string(), "testing-brain".to_string()), + _ => ("https://164.92.249.180:31337".to_string(), "testnet-brain".to_string()), } } diff --git a/src/general/cli_handler.rs b/src/general/cli_handler.rs index 5fcd1c9..8b91863 100644 --- a/src/general/cli_handler.rs +++ b/src/general/cli_handler.rs @@ -63,21 +63,24 @@ pub fn handle_account(matches: &ArgMatches) { } } +const FISH_COMPLETION: &str = r#" +complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from delete' -a '(cat ~/.detee/cli/vms/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from update' -a '(cat ~/.detee/cli/vms/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from inspect' -a '(cat ~/.detee/cli/vms/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from ssh' -a '(cat ~/.detee/cli/vms/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app config update' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app config get' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app delete' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app inspect' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +"#; + pub fn handle_completion(matches: &ArgMatches, cmd: Command) { let mut cmd = disable_help_for_all_subcommands(cmd); if let Some(shell) = matches.get_one::("shell") { let shell: Shell = shell.parse().expect("Invalid shell type"); generate(shell, &mut cmd, "detee-cli", &mut io::stdout()); if shell.to_string() == "fish" { - println!("complete -c detee-cli -n '__fish_seen_subcommand_from vm delete' -a '(cat ~/.detee/cli/vms/uuid_list)' -f"); - println!("complete -c detee-cli -n '__fish_seen_subcommand_from vm update' -a '(cat ~/.detee/cli/vms/uuid_list)' -f"); - println!("complete -c detee-cli -n '__fish_seen_subcommand_from vm inspect' -a '(cat ~/.detee/cli/vms/uuid_list)' -f"); - println!("complete -c detee-cli -n '__fish_seen_subcommand_from vm ssh' -a '(cat ~/.detee/cli/vms/uuid_list)' -f"); - - println!("complete -c detee-cli -n '__fish_seen_subcommand_from app config update' -a '(cat ~/.detee/cli/apps/uuid_list)' -f"); - println!("complete -c detee-cli -n '__fish_seen_subcommand_from app config get' -a '(cat ~/.detee/cli/apps/uuid_list)' -f"); - println!("complete -c detee-cli -n '__fish_seen_subcommand_from app delete' -a '(cat ~/.detee/cli/apps/uuid_list)' -f"); - println!("complete -c detee-cli -n '__fish_seen_subcommand_from app inspect' -a '(cat ~/.detee/cli/apps/uuid_list)' -f"); + println!("{FISH_COMPLETION}"); } } }