module SyncWrap::Distro
Support module and interface for distribution components.
Attributes
The root directory for local, non-distro managed installs (default: /usr/local)
Public Class Methods
# File lib/syncwrap/distro.rb, line 28 def initialize( *args ) @local_root = '/usr/local' super( *args ) end
Public Instance Methods
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
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
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
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
Is the Distro running systemd?
# File lib/syncwrap/distro.rb, line 97 def systemd? false end
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