baze 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fixperms +3 -6
- data/bin/rrtmux +22 -0
- data/bin/shellescape +2 -2
- data/bin/shost +3 -3
- data/bin/suc +38 -0
- metadata +6 -2
data/bin/fixperms
CHANGED
@@ -7,15 +7,13 @@ require 'yaml'
|
|
7
7
|
optparse = OptionParser.new do |opts|
|
8
8
|
opts.banner = "Usage: fixperms [config file ...]\n" \
|
9
9
|
" Apply files permissions and ownership rules using YAML specifications"
|
10
|
-
opts.on '-l', '--lowercase', 'Use lowercase digits' do
|
11
|
-
format = '%x'
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
13
|
optparse.parse!
|
16
14
|
|
17
15
|
if ARGV.empty?
|
18
|
-
specpaths = Dir.glob '/etc/fixperms.d
|
16
|
+
specpaths = Dir.glob '/etc/fixperms.d/**/*'
|
19
17
|
else
|
20
18
|
specpaths = ARGV
|
21
19
|
end
|
@@ -25,6 +23,7 @@ specpaths.each do |specpath|
|
|
25
23
|
|
26
24
|
spec.each do |glob, infos|
|
27
25
|
files = Dir.glob glob
|
26
|
+
next if files.empty?
|
28
27
|
|
29
28
|
user, group, mod = infos['user'], infos['group'], infos['mod']
|
30
29
|
|
@@ -33,9 +32,7 @@ specpaths.each do |specpath|
|
|
33
32
|
|
34
33
|
puts "#{files.join ', '} -> #{descr}"
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
FileUtils.chown user, group, files
|
35
|
+
FileUtils.chown user, group, files unless user.nil? and group.nil?
|
39
36
|
FileUtils.chmod mod, files if mod
|
40
37
|
end
|
41
38
|
end
|
data/bin/rrtmux
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
def help
|
6
|
+
print "Usage: rrtmux [ssh options] hostname\n" \
|
7
|
+
" Connects over ssh, attaches or creates a tmux session, handles disconnects\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
timeout = 0.125
|
11
|
+
|
12
|
+
if ARGV.empty? or ARGV.find {|arg| arg == '-h' or arg == '--help'}
|
13
|
+
help
|
14
|
+
else
|
15
|
+
while true
|
16
|
+
system 'ssh', '-t', *ARGV, 'tmux att || tmux new'
|
17
|
+
exit if $?.exitstatus == 0
|
18
|
+
sleep timeout
|
19
|
+
STDERR.puts "ssh failed, waiting for #{timeout} secs..."
|
20
|
+
timeout *= 2 if timeout < 4
|
21
|
+
end
|
22
|
+
end
|
data/bin/shellescape
CHANGED
@@ -5,7 +5,7 @@ require 'shellwords'
|
|
5
5
|
|
6
6
|
optparse = OptionParser.new do |opts|
|
7
7
|
opts.banner = "Usage: shellescape [string]\n" \
|
8
|
-
" Escapes the provided string (or standard input) for
|
8
|
+
" Escapes the provided string (or standard input) for Bourne shells"
|
9
9
|
end
|
10
10
|
|
11
11
|
optparse.parse!
|
@@ -16,4 +16,4 @@ else
|
|
16
16
|
str = ARGV.join ' '
|
17
17
|
end
|
18
18
|
|
19
|
-
puts Shellwords::escape str
|
19
|
+
puts Shellwords::escape str
|
data/bin/shost
CHANGED
@@ -6,7 +6,7 @@ require 'optparse'
|
|
6
6
|
reverse = false
|
7
7
|
|
8
8
|
optparse = OptionParser.new do |opts|
|
9
|
-
opts.banner = "Usage:
|
9
|
+
opts.banner = "Usage: shost [-r] host\n" \
|
10
10
|
" Resolves names"
|
11
11
|
|
12
12
|
opts.on '-r', '--reverse', 'Display reverse lookups' do
|
@@ -18,10 +18,10 @@ optparse.parse!
|
|
18
18
|
|
19
19
|
raise 'host expected' if ARGV.empty?
|
20
20
|
|
21
|
-
infos = Socket.getaddrinfo(ARGV[0],
|
21
|
+
infos = Socket.getaddrinfo(ARGV[0], nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, 0, reverse)
|
22
22
|
|
23
23
|
if reverse
|
24
24
|
infos.each {|r| puts r[2]}
|
25
25
|
else
|
26
26
|
infos.each {|r| puts r[3]}
|
27
|
-
end
|
27
|
+
end
|
data/bin/suc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
reverse = false
|
7
|
+
|
8
|
+
optparse = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: suc [-r] [file]\n" \
|
10
|
+
" Scale-friendlier equivalent of sort | uniq -c | sort -n"
|
11
|
+
opts.on '-r', '--reverse', 'Sort from most to least frequent' do
|
12
|
+
reverse = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
optparse.parse!
|
17
|
+
|
18
|
+
if ARGV.empty?
|
19
|
+
io = STDIN
|
20
|
+
else
|
21
|
+
io = File.open ARGV[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
counts = Hash.new 0
|
25
|
+
|
26
|
+
io.each_line do |line|
|
27
|
+
counts[line] += 1
|
28
|
+
end
|
29
|
+
|
30
|
+
if reverse
|
31
|
+
sorted = counts.sort_by {|k,v| -v}
|
32
|
+
else
|
33
|
+
sorted = counts.sort_by {|k,v| v}
|
34
|
+
end
|
35
|
+
|
36
|
+
sorted.each do |line, count|
|
37
|
+
printf "%7i %s", count, line
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -19,8 +19,10 @@ executables:
|
|
19
19
|
- hex2ip
|
20
20
|
- ip2hex
|
21
21
|
- randmac
|
22
|
+
- rrtmux
|
22
23
|
- shellescape
|
23
24
|
- shost
|
25
|
+
- suc
|
24
26
|
- urldecode
|
25
27
|
- urlencode
|
26
28
|
extensions: []
|
@@ -30,8 +32,10 @@ files:
|
|
30
32
|
- bin/hex2ip
|
31
33
|
- bin/ip2hex
|
32
34
|
- bin/randmac
|
35
|
+
- bin/rrtmux
|
33
36
|
- bin/shellescape
|
34
37
|
- bin/shost
|
38
|
+
- bin/suc
|
35
39
|
- bin/urldecode
|
36
40
|
- bin/urlencode
|
37
41
|
- COPYING
|