service_install::install

Struct 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,

Source

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,

Source

pub fn path( self, path: impl Into<PathBuf>, ) -> Spec<Set, Name, TriggerSet, InstallType>

Source

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.

Source

pub fn service_name( self, service_name: impl Display, ) -> Spec<Path, Set, TriggerSet, InstallType>

Name to give the systemd service or cron job

Only needed for install. During uninstall we recognize the service or con job by the special comment service-install leaves at the top of each

Source

pub fn on_schedule( self, schedule: Schedule, ) -> Spec<Path, Name, Set, InstallType>

Source

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

Source

pub fn description(self, description: impl Display) -> Self

The description for the installed service

Source

pub fn overwrite_existing(self, overwrite: bool) -> Self

Should the installer overwrite existing files? Default is false

Source

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

Source

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

Source

pub fn working_dir(self, dir: PathBuf) -> Self

The working directory of the program when it is started on a schedule

Source

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>

Source

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 executed 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 non-existing user.
  • no suitable install directory could be found.
  • the path for the executable does not point to a file.
Source§

impl<M: ToAssign, P: ToAssign, T: ToAssign, I: ToAssign> Spec<M, P, T, I>

Source

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 executed 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.

Trait Implementations§

Source§

impl<Path, Name, TriggerSet, InstallType> Debug for Spec<Path, Name, TriggerSet, InstallType>
where Path: ToAssign + Debug, Name: ToAssign + Debug, TriggerSet: ToAssign + Debug, InstallType: ToAssign + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Path, Name, TriggerSet, InstallType> Freeze for Spec<Path, Name, TriggerSet, InstallType>

§

impl<Path, Name, TriggerSet, InstallType> RefUnwindSafe for Spec<Path, Name, TriggerSet, InstallType>
where Path: RefUnwindSafe, Name: RefUnwindSafe, TriggerSet: RefUnwindSafe, InstallType: RefUnwindSafe,

§

impl<Path, Name, TriggerSet, InstallType> Send for Spec<Path, Name, TriggerSet, InstallType>
where Path: Send, Name: Send, TriggerSet: Send, InstallType: Send,

§

impl<Path, Name, TriggerSet, InstallType> Sync for Spec<Path, Name, TriggerSet, InstallType>
where Path: Sync, Name: Sync, TriggerSet: Sync, InstallType: Sync,

§

impl<Path, Name, TriggerSet, InstallType> Unpin for Spec<Path, Name, TriggerSet, InstallType>
where Path: Unpin, Name: Unpin, TriggerSet: Unpin, InstallType: Unpin,

§

impl<Path, Name, TriggerSet, InstallType> UnwindSafe for Spec<Path, Name, TriggerSet, InstallType>
where Path: UnwindSafe, Name: UnwindSafe, TriggerSet: UnwindSafe, InstallType: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more