module SyncWrap::Distro

Support module and interface for distribution components.

Attributes

local_root[RW]

The root directory for local, non-distro managed installs (default: /usr/local)

Public Class Methods

new( *args ) click to toggle source
Calls superclass method
# File lib/syncwrap/distro.rb, line 28
def initialize( *args )
  @local_root = '/usr/local'

  super( *args )
end

Public Instance Methods

dist_install( *pkgs ) click to toggle source

Install the specified package names. A trailing hash is interpreted as options, see below.

Options

:check_install

Short-circuit if packages are already installed. Thus no upgrades will be performed. (Default: true)

:minimal

Avoid additional “optional” packages when possible

Options are also passed to the sudo calls.

# File lib/syncwrap/distro.rb, line 51
def dist_install( *pkgs )
  raise "Include a distro-specific component, e.g. Debian, RHEL"
end
dist_install_init_service( name ) click to toggle source

Install a System V style init.d script (already placed at remote /etc/init.d/<name>) via distro-specific command. Note that this should not be called and may fail on a distro running systemd. A rough equivalent in this case is:

systemctl( 'enable', 'name.service' )

See systemd?, SyncWrap::SystemD#systemctl

# File lib/syncwrap/distro.rb, line 69
def dist_install_init_service( name )
  raise "Include a distro-specific component, e.g. Debian, RHEL"
end
dist_service( *args ) click to toggle source

Run via sudo as root, either a System V (distro specific) `service` command or the systemd `systemctl` equivalent. In the System V case arguments are passed verbatim and are in the form: (name, command, options…) Typically supported commands include: start, stop, restart, reload and status. For maximum compatibility, in the systemd case only two arguments are allowed: shortname, command. Note the order is reversed from the use of systemctl.

# File lib/syncwrap/distro.rb, line 81
def dist_service( *args )
  raise "Include a distro-specific component, e.g. Debian, RHEL"
end
dist_uninstall( *pkgs ) click to toggle source

Uninstall the specified package names. A trailing hash is interpreted as options and passed to the sudo calls.

# File lib/syncwrap/distro.rb, line 57
def dist_uninstall( *pkgs )
  raise "Include a distro-specific component, e.g. Debian, RHEL"
end
distro() click to toggle source

Return self, and in Context, the specific Distro component.

# File lib/syncwrap/distro.rb, line 35
def distro
  self
end
systemd?() click to toggle source

Is the Distro running systemd?

# File lib/syncwrap/distro.rb, line 97
def systemd?
  false
end
unmount_device( dev ) click to toggle source

If found mounted, unmount the specified device and also remove it from fstab.

# File lib/syncwrap/distro.rb, line 87
def unmount_device( dev )
  sudo <<-SH
    if mount | grep -q '^#{dev} '; then
      umount #{dev}
      sed -r -i '\\|^#{dev}\\s|d' /etc/fstab
    fi
  SH
end