Struct service_install::install::Spec
source · pub struct Spec<Path, Name, TriggerSet, InstallType>where
Path: ToAssign,
Name: ToAssign,
TriggerSet: ToAssign,
InstallType: ToAssign,{ /* private fields */ }Expand description
The configuration for the current install, needed to perform the
installation or remove an existing one. Create this by using the
install_system or
install_user macros.
Implementations§
source§impl<Path, Name, TriggerSet> Spec<Path, Name, TriggerSet, SystemInstall>where
Path: ToAssign,
Name: ToAssign,
TriggerSet: ToAssign,
impl<Path, Name, TriggerSet> Spec<Path, Name, TriggerSet, SystemInstall>where
Path: ToAssign,
Name: ToAssign,
TriggerSet: ToAssign,
sourcepub fn run_as(self, user: impl Into<String>) -> Self
pub fn run_as(self, user: impl Into<String>) -> Self
Only available for install_system
source§impl<Path, Name, TriggerSet, InstallType> Spec<Path, Name, TriggerSet, InstallType>where
Path: ToAssign,
Name: ToAssign,
TriggerSet: ToAssign,
InstallType: ToAssign,
impl<Path, Name, TriggerSet, InstallType> Spec<Path, Name, TriggerSet, InstallType>where
Path: ToAssign,
Name: ToAssign,
TriggerSet: ToAssign,
InstallType: ToAssign,
pub fn path( self, path: impl Into<PathBuf>, ) -> Spec<Set, Name, TriggerSet, InstallType>
sourcepub fn current_exe(
self,
) -> Result<Spec<Set, Name, TriggerSet, InstallType>, Error>
pub fn current_exe( self, ) -> Result<Spec<Set, Name, TriggerSet, InstallType>, Error>
Install a copy of the currently running exe.
§Errors
Will return an error if the path to the current executable could not be gotten. This can fail for a number of reasons such as filesystem operations and syscall failures.
pub fn name( self, name: impl Display, ) -> Spec<Path, Set, TriggerSet, InstallType>
pub fn on_schedule( self, schedule: Schedule, ) -> Spec<Path, Name, Set, InstallType>
sourcepub fn on_boot(self) -> Spec<Path, Name, Set, InstallType>
pub fn on_boot(self) -> Spec<Path, Name, Set, InstallType>
Start the job on boot. When cron is used as init the system needs to be rebooted before this applies
sourcepub fn description(self, description: impl Display) -> Self
pub fn description(self, description: impl Display) -> Self
The description for the installed service
sourcepub fn overwrite_existing(self, overwrite: bool) -> Self
pub fn overwrite_existing(self, overwrite: bool) -> Self
Should the installer overwrite existing files? Default is false
sourcepub fn args(self, args: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn args(self, args: impl IntoIterator<Item = impl Into<String>>) -> Self
These args will be shell escaped. If any arguments where already set this adds to them
sourcepub fn arg(self, arg: impl Into<String>) -> Self
pub fn arg(self, arg: impl Into<String>) -> Self
The argument will be shell escaped. This does not clear previous set arguments but adds to it
pub fn working_dir(self, dir: PathBuf) -> Self
sourcepub fn allowed_inits(self, allowed: impl AsRef<[System]>) -> Self
pub fn allowed_inits(self, allowed: impl AsRef<[System]>) -> Self
By default all supported init systems will be tried Can be set multiple times to try multiple init systems in the order in which this was set.
Note: setting this for an uninstall might cause it to fail
source§impl<T: ToAssign> Spec<Set, Set, Set, T>
impl<T: ToAssign> Spec<Set, Set, Set, T>
sourcepub fn prepare_install(self) -> Result<InstallSteps, PrepareInstallError>
pub fn prepare_install(self) -> Result<InstallSteps, PrepareInstallError>
Prepare for installing. This makes a number of checks and if they are
passed it returns the InstallSteps. These implement IntoIterator and
can be inspected and executated one by one or executed in one step using
InstallSteps::install.
§Errors
Returns an error if:
- the install is set to be system wide install while not running as admin/superuser
- the service should run as another user then the current one while not running as admin/superuser
- the service should run for a nonexisting user
- no suitable install directory could be found
- the path for the executable does not point to a file
source§impl<P: ToAssign, T: ToAssign, I: ToAssign> Spec<P, Set, T, I>
impl<P: ToAssign, T: ToAssign, I: ToAssign> Spec<P, Set, T, I>
sourcepub fn prepare_remove(self) -> Result<RemoveSteps, PrepareRemoveError>
pub fn prepare_remove(self) -> Result<RemoveSteps, PrepareRemoveError>
Prepare for removing an install. This makes a number of checks and if
they are passed it returns the RemoveSteps. These implement
IntoIterator and can be inspected and executated one by one or
executed in one step using RemoveSteps::remove.
§Errors
Returns an error if:
- trying to remove a system install while not running as admin/superuser
- no install is found
- anything goes wrong setting up the removal