Class: Space::Architect::CLI::Architect::Sessions::Agent::Install
Instance Method Summary
collapse
Methods included from Helpers
#format_failure, #plist_path
Methods inherited from BaseCommand
commit_message_options, phase
Instance Method Details
#call(host: nil, token: nil, interval: "900", **opts) ⇒ Object
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
|
# File 'lib/space_architect/cli/architect.rb', line 1004
def call(host: nil, token: nil, interval: "900", **opts)
setup_terminal(**opts.slice(:color, :colors))
handle_errors do
Sessions.require_credentials!(host, token)
resolved_token = token.start_with?("op://") ? SessionSync.resolve_token(token) : token
pp = plist_path
xml = SessionSync::Plist.call(
label: SessionSync::LABEL,
refresh_interval: interval.to_i,
log_dir: SessionSync.log_dir,
bin_path: SessionSync::BinPath.detect,
host: host,
env: {SessionSync::TOKEN_ENV => resolved_token}
)
FileUtils.mkdir_p(File.dirname(pp))
File.write(pp, xml)
File.chmod(0o600, pp)
result = Space::Src::Launchd::Agent.new(label: SessionSync::LABEL).install(pp)
raise Space::Core::Error, "bootstrap failed: #{format_failure(result.failure)}" if result.failure?
terminal.say "Installed: #{terminal.path(pp)}"
CLI.record_outcome(Outcome.new(exit_code: 0))
end
end
|