Skip to content

Commit

Permalink
fixup: service_name
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Dec 9, 2024
1 parent 68a27d5 commit 53c8e28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/action/common/configure_init_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Action for ConfigureInitService {
let service_dest = service_dest
.as_ref()
.expect("service_dest should be set for Launchd");
let service = service_name
let service_name = service_name
.as_ref()
.expect("service_name should be set for Launchd");
let domain = DARWIN_LAUNCHD_DOMAIN;
Expand All @@ -259,27 +259,27 @@ impl Action for ConfigureInitService {
})?;
}

crate::action::macos::retry_bootstrap(domain, service, service_dest)
crate::action::macos::retry_bootstrap(domain, service_name, service_dest)
.await
.map_err(Self::error)?;

let is_disabled = crate::action::macos::service_is_disabled(domain, service)
let is_disabled = crate::action::macos::service_is_disabled(domain, service_name)
.await
.map_err(Self::error)?;
if is_disabled {
execute_command(
Command::new("launchctl")
.process_group(0)
.arg("enable")
.arg(format!("{domain}/{service}"))
.arg(format!("{domain}/{service_name}"))
.stdin(std::process::Stdio::null()),
)
.await
.map_err(Self::error)?;
}

if *start_daemon {
crate::action::macos::retry_kickstart(domain, service)
crate::action::macos::retry_kickstart(domain, service_name)
.await
.map_err(Self::error)?;
}
Expand Down
24 changes: 12 additions & 12 deletions src/action/macos/bootstrap_launchctl_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ Bootstrap and kickstart an APFS volume
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
#[serde(tag = "action_name", rename = "bootstrap_launchctl_service")]
pub struct BootstrapLaunchctlService {
service: String,
service_name: String,
path: PathBuf,
is_present: bool,
is_disabled: bool,
}

impl BootstrapLaunchctlService {
#[tracing::instrument(level = "debug", skip_all)]
pub async fn plan(service: &str, path: &str) -> Result<StatefulAction<Self>, ActionError> {
let service = service.to_owned();
pub async fn plan(service_name: &str, path: &str) -> Result<StatefulAction<Self>, ActionError> {
let service_name = service_name.to_owned();
let path = PathBuf::from(path);

let is_present = {
let mut command = Command::new("launchctl");
command.process_group(0);
command.arg("print");
command.arg(format!("{DARWIN_LAUNCHD_DOMAIN}/{service}"));
command.arg(format!("{DARWIN_LAUNCHD_DOMAIN}/{service_name}"));
command.stdin(std::process::Stdio::null());
command.stdout(std::process::Stdio::piped());
command.stderr(std::process::Stdio::piped());
Expand All @@ -44,12 +44,12 @@ impl BootstrapLaunchctlService {
command_output.status.success()
};

let is_disabled = service_is_disabled(DARWIN_LAUNCHD_DOMAIN, &service)
let is_disabled = service_is_disabled(DARWIN_LAUNCHD_DOMAIN, &service_name)
.await
.map_err(Self::error)?;

Ok(StatefulAction::uncompleted(Self {
service,
service_name,
path,
is_present,
is_disabled,
Expand All @@ -66,7 +66,7 @@ impl Action for BootstrapLaunchctlService {
fn tracing_synopsis(&self) -> String {
format!(
"Bootstrap the `{}` service via `launchctl bootstrap {} {}`",
self.service,
self.service_name,
DARWIN_LAUNCHD_DOMAIN,
self.path.display()
)
Expand All @@ -89,7 +89,7 @@ impl Action for BootstrapLaunchctlService {
#[tracing::instrument(level = "debug", skip_all)]
async fn execute(&mut self) -> Result<(), ActionError> {
let Self {
service,
service_name,
path,
is_present,
is_disabled,
Expand All @@ -100,20 +100,20 @@ impl Action for BootstrapLaunchctlService {
Command::new("launchctl")
.process_group(0)
.arg("enable")
.arg(format!("{DARWIN_LAUNCHD_DOMAIN}/{service}"))
.arg(format!("{DARWIN_LAUNCHD_DOMAIN}/{service_name}"))
.stdin(std::process::Stdio::null()),
)
.await
.map_err(Self::error)?;
}

if *is_present {
crate::action::macos::retry_bootout(DARWIN_LAUNCHD_DOMAIN, service)
crate::action::macos::retry_bootout(DARWIN_LAUNCHD_DOMAIN, service_name)
.await
.map_err(Self::error)?;
}

crate::action::macos::retry_bootstrap(DARWIN_LAUNCHD_DOMAIN, service, path)
crate::action::macos::retry_bootstrap(DARWIN_LAUNCHD_DOMAIN, service_name, path)
.await
.map_err(Self::error)?;

Expand All @@ -133,7 +133,7 @@ impl Action for BootstrapLaunchctlService {

#[tracing::instrument(level = "debug", skip_all)]
async fn revert(&mut self) -> Result<(), ActionError> {
crate::action::macos::retry_bootout(DARWIN_LAUNCHD_DOMAIN, &self.service)
crate::action::macos::retry_bootout(DARWIN_LAUNCHD_DOMAIN, &self.service_name)
.await
.map_err(Self::error)?;

Expand Down

0 comments on commit 53c8e28

Please sign in to comment.