Sha256: 014069b05d6bf98d8693912ca0f08892f81e94a12b37de2a8eb800693695865c
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
class Setup def initialize @thisdir = File.join File.dirname(__FILE__) end def with_systemd copy_sample_conf install_systemd_service puts "Installed." puts "\nEdit #{SysWatchdog::DEFAULT_CONF_FILE} and start:" puts "systemctl start sys-watchdog" puts "\nTo check daemon status:" puts "systemctl status sys-watchdog" end def with_cron copy_sample_conf add_cron_line puts "Installed." puts "\nEdit #{SysWatchdog::DEFAULT_CONF_FILE} and uncomment the cron line added." end private def add_cron_line run "echo '#* * * * * root /bin/bash -lc \'sys_watchdog once\' >> /etc/crontab" end def install_systemd_service services_dir = "/lib/systemd/system/" if `which systemctl`.empty? STDERR.puts "SysWatchdog install requires systemctl. Aborting." exit 1 end unless File.exist? services_dir STDERR.puts "SysWatchdog install requires dir #{services_dir}. Aborting." exit 1 end copy "#{@thisdir}/../../util/sys-watchdog.service", services_dir run 'systemctl enable sys-watchdog' end def copy_sample_conf copy "#{@thisdir}/../../util/sys_watchdog_sample.yml", SysWatchdog::DEFAULT_CONF_FILE end def copy from, to, mod = 0600 puts "Copying #{from} to #{to}..." FileUtils.cp from, to FileUtils.chmod mod, to end def run cmd puts "Running #{cmd}..." system cmd end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sys_watchdog-0.1.8 | lib/sys_watchdog/setup.rb |
sys_watchdog-0.1.7 | lib/sys_watchdog/setup.rb |