gssh 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66ba9c0cffcfafcabf7f788a7fb0725eb8786a1e
4
+ data.tar.gz: e0d8f537c0a2f3469a0d1017280247f82d55410c
5
+ SHA512:
6
+ metadata.gz: cb8de28162cb92602dc18e75ae8aa51e028f6358e0ab7b718ef6d4b153f09dd98f119889f62ec1d2d64d7ee0aba0f9ce96584a84b3d39858a979a81d01dae97b
7
+ data.tar.gz: ff4e3278943076c55b0c77160f2e26a696223cca5131e4b135ac502543b3e09010deb0d25e698351bfde5007b5da9901c44b6d290627281065c5b497802565c7
@@ -0,0 +1 @@
1
+ # gssh
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+ require 'resolv'
3
+ require 'net/ssh'
4
+ require 'net/scp'
5
+
6
+ $PSWD = nil
7
+
8
+ if ARGV[0].nil?
9
+ print "Hostname blank\n" # Exit if no hostname is passed #FIXME Put a --help like example
10
+ exit 1
11
+ else
12
+ $hostname = ARGV[0] # Mandatory
13
+ end
14
+
15
+ BASEDIR = File.dirname(__FILE__) + '/..'
16
+
17
+ $file_list = ["#{BASEDIR}/profile/version","#{BASEDIR}/profile/bash_profile","#{BASEDIR}/profile/vimrc"] #Profile files
18
+
19
+ if ARGV[1].nil? # Is Username passed ??
20
+ require 'etc'
21
+ $userid = Etc.getlogin() # No ?? Get username from system
22
+ print "UserID: " + $userid + "\n"
23
+ else
24
+ $userid = ARGV[1].chomp # Oh so its passed !! Sanitise it !!
25
+ end
26
+
27
+ LOCALVERSION = File.read($file_list[0]).to_i # Read, Convert and Close the file
28
+ print "LOCALVERSION:", LOCALVERSION, "\n" # Profile's Local version Incremented everytime you change the profile files
29
+
30
+ def askPassword(prompt="Enter Password : ")
31
+ ask(prompt) {|q| q.echo = false}
32
+ end
33
+
34
+
35
+ def genSSHObject(host)
36
+ begin
37
+ $ssh = Net::SSH.start(host, $userid)
38
+ return $ssh
39
+ rescue Net::SSH::AuthenticationFailed #FIXME Get more exceptions
40
+ begin
41
+ $PSWD = askPassword() if $PSWD.nil?
42
+ $ssh = Net::SSH.start(host, $userid, :password => $PSWD, :paranoid => Net::SSH::Verifiers::Null.new)
43
+ return $ssh
44
+ rescue Net::SSH::AuthenticationFailed
45
+ print "Password Auth too Failed. Exiting..."
46
+ exit 1
47
+ end
48
+ end
49
+ end
50
+
51
+ def getVersion(host) # Get Remote Profile version
52
+ current_version = $ssh.exec! "cat ~/.version"
53
+ return current_version
54
+ end
55
+
56
+ def do_SCP(host) # Do the SCP work
57
+ print "SCP'ing " + $userid + "@" + host + "\n"
58
+
59
+ $file_list.each do |filename|
60
+ #puts File.exists? filename
61
+ rpath = "./." + File.basename(filename)
62
+ print "Uploading " + filename + " as " + rpath + "\n"
63
+ $ssh.scp.upload! filename, rpath # Do the SCP thing !!
64
+ end
65
+
66
+ end
67
+
68
+ genSSHObject($hostname) #Get $ssh object or exit
69
+
70
+ REMOTEVERSION = getVersion(host = $hostname).to_i
71
+ print "REMOTEVERSION:" ,REMOTEVERSION, "\n"
72
+
73
+ if REMOTEVERSION < LOCALVERSION
74
+ do_SCP(host = $hostname) # Do whatcha born for !!
75
+ else
76
+ print "Skipping Profile Copy \n" # Phew !! Nothing to do here
77
+ end
78
+
79
+ print "SSHing now ..\n"
80
+
81
+ system '/usr/bin/ssh', $hostname # Execute ssh
@@ -0,0 +1,47 @@
1
+
2
+ # -*- encoding: utf-8 -*-
3
+ $:.push('lib')
4
+ require "gssh/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "gssh"
8
+ s.version = Gssh::VERSION.dup
9
+ s.date = "2015-04-12"
10
+ s.summary = "Copies Profile files before ssh'ing"
11
+ s.email = "todo@project.com"
12
+ s.homepage = "https://github.com/GaryCarneiro/gssh"
13
+ s.authors = ['Garfield Carneiro']
14
+ s.license = "MIT"
15
+
16
+ s.description = <<-EOF
17
+ Given a hostname and list of files it copies to remote host before spawning ssh client.
18
+ EOF
19
+
20
+ dependencies = [
21
+ # Examples:
22
+ # [:runtime, "rack", "~> 1.1"],
23
+ [:runtime, "net-ssh", "~> 2.9", ">= 2.9.2"],
24
+ [:runtime, "net-scp", "~> 1.2", ">= 1.2.1"],
25
+ [:runtime, "highline", "~> 1.7", ">=1.7.1"],
26
+ # [:development, "rspec", "~> 2.1"],
27
+ ]
28
+
29
+ s.files = Dir['**/*']
30
+ s.test_files = Dir['test/**/*'] + Dir['spec/**/*']
31
+ s.executables = Dir['bin/*'].map { |f| File.basename(f) }
32
+ s.require_paths = ["lib"]
33
+
34
+
35
+ ## Make sure you can build the gem on older versions of RubyGems too:
36
+ s.rubygems_version = "2.4.5"
37
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
38
+ s.specification_version = 3 if s.respond_to? :specification_version
39
+
40
+ dependencies.each do |type, name, version|
41
+ if s.respond_to?("add_#{type}_dependency")
42
+ s.send("add_#{type}_dependency", name, version)
43
+ else
44
+ s.add_dependency(name, version)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,4 @@
1
+ require 'net/ssh'
2
+ require 'net/scp'
3
+ require 'highline/import'
4
+ require 'resolv'
@@ -0,0 +1,3 @@
1
+ module Gssh
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+
3
+ alias rm='rm -i'
4
+ alias mv='mv -i'
5
+ alias cp='cp -i'
6
+ alias ..='cd ..'
7
+ alias l='ls -F'
8
+ alias ll='ls -alFrt'
9
+ alias grep='fgrep -i --color'
10
+ alias top='top -c'
11
+
12
+
13
+
14
+ case "$TERM" in
15
+ screen)
16
+ export PROMPT_COMMAND='echo -ne "\033k$HOSTNAME\033\\"'
17
+ ;;
18
+ esac
19
+
20
+ export HISTSIZE=2000
21
+ export HISTIGNORE="&:ls:[bf]g:exit"
22
+ export HISTTIMEFORMAT="%d/%m/%y %T "
23
+ export PS1='\[\033[0;31m\][\@]\[\033[0;m\][\[\033[0;36m\]\u@\[\033[0;33m\]\H\[\033[0;m\] \W]\[\033[0;32m\]\$ '
24
+
25
+ cat ~/.version
@@ -0,0 +1 @@
1
+ 11
@@ -0,0 +1,28 @@
1
+ set hlsearch
2
+
3
+ colorscheme desert
4
+ syntax enable
5
+
6
+ filetype indent on
7
+
8
+ set et
9
+ set sw=4
10
+ set smarttab
11
+ set ruler
12
+ set ignorecase
13
+
14
+ if v:version >= 703
15
+ set cursorline
16
+ endif
17
+
18
+ if has("autocmd")
19
+ " Enable filetype detection
20
+ filetype plugin indent on
21
+
22
+ " Restore cursor position
23
+ autocmd BufReadPost *
24
+ \ if line("'\"") > 1 && line("'\"") <= line("$") |
25
+ \ exe "normal! g`\"" |
26
+ \ endif
27
+ endif
28
+
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gssh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Garfield Carneiro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-ssh
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-scp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ description: |2
56
+ Given a hostname and list of files it copies to remote host before spawning ssh client.
57
+ email: todo@project.com
58
+ executables:
59
+ - gssh
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - README.md
64
+ - bin/gssh
65
+ - gssh.gemspec
66
+ - lib/gssh.rb
67
+ - lib/gssh/version.rb
68
+ - profile/bash_profile
69
+ - profile/version
70
+ - profile/vimrc
71
+ homepage: https://github.com/GaryCarneiro/gssh
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Copies Profile files before ssh'ing
95
+ test_files: []