Class: Argosnap::Install
- Inherits:
-
Object
- Object
- Argosnap::Install
- Defined in:
- lib/argosnap/install.rb
Overview
Install configuration and log files on the system. All program files to go ‘$HOME/.argosnap’
Instance Method Summary collapse
- #cron_entry ⇒ Object
-
#ensure_compatibility ⇒ Object
Check OS support and configuration file.
- #ensure_installation ⇒ Object
-
#install ⇒ Object
Install configuration files in the system.
Instance Method Details
#cron_entry ⇒ Object
59 60 61 62 63 64 |
# File 'lib/argosnap/install.rb', line 59 def cron_entry puts "\nA standard cron entry looks like this:\n" puts "\n5 8 * * 6 <user> <command>\n" puts "\nFor detailed instructions see here: <wiki-link>" puts "" end |
#ensure_compatibility ⇒ Object
Check OS support and configuration file
67 68 69 70 71 72 |
# File 'lib/argosnap/install.rb', line 67 def ensure_compatibility # Check the operating system. Windows is not supported at this time. unless %w{ darwin linux freebsd openbsd netbsd }.include? Gem::Platform.local.os Kernel.abort("\nThis gem is made for UNIX! Please check the website for details #{url} !\n\n") end end |
#ensure_installation ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/argosnap/install.rb', line 74 def ensure_installation if File.exist?(configuration.files[:home]) if (File.exist?(configuration.files[:logfile]) && File.exist?(configuration.files[:config])) true else Kernel.abort("\nNo configuration files found! Please run 'argosnap -i config'\n\n") end else Kernel.abort("\nNo configuration directory found! Please run 'argosnap -i config'\n\n") end end |
#install ⇒ Object
Install configuration files in the system
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/argosnap/install.rb', line 11 def install ensure_compatibility begin # permissions are a-rwx, u+rwx if File.exists? configuration.files[:config] puts "Config file exists!" puts "Please remove config: #{configuration.files[:config]} manually and re-install the configuration file." else Dir.mkdir(File.join(Dir.home, ".argosnap"), 0700) unless File.exist? configuration.files[:home] FileUtils.touch(configuration.files[:logfile]) unless File.exist? configuration.files[:logfile] config = { email: 'tarsnap_email', password: 'tarsnap_password', threshold: 10, seconds: 86400, notifications_osx: false, notifications_email: false, smtp: { email_delivery_method: 'sendmail', smtpd_user: 'username', smtpd_password: 'password', smtpd_address: "gmail.google.com", smtpd_port: 587, smtpd_from: '[email protected]', smtpd_to: '[email protected]', format: 'txt'}, notifications_pushover: false, pushover: { key: 'user_key', token: 'app_token'} } File.open(configuration.files[:config], "w") {|f| f.write(config.to_yaml)} puts "" puts "Configuration file created! To setup argosnap: " puts "1. Edit the configuration file: #{configuration.files[:config]}" puts "2. Run argosnap by typing in the terminal 'argosnap -p' to fetch current balance" puts "3. To configure notifications see: https://github.com/atmosx/argosnap/wiki" puts "" end rescue Errno::ENOENT => e puts "Can't configuration locate file!" puts e. puts e.backtrace end end |