sakuric 2.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.
- data/CHANGELOG +13 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +60 -0
- data/HISTORY.yml +13 -0
- data/INSTALL +5 -0
- data/LICENSE +1 -0
- data/Makefile +19 -0
- data/Manifest +405 -0
- data/README.md +72 -0
- data/Rakefile +4 -0
- data/TODO +3 -0
- data/VERSION +1 -0
- data/bashrc +30 -0
- data/bashrc.d/00-functions.include +7 -0
- data/bashrc.d/01-sakura_checks.include +15 -0
- data/bashrc.d/02-uname.include +11 -0
- data/bashrc.d/80-ruby.include +4 -0
- data/bashrc.d/99-dirs.include +11 -0
- data/bashrc.d/aliases.include +20 -0
- data/bashrc.d/common.include +7 -0
- data/bashrc.d/local.d/README +1 -0
- data/bashrc.d/local.d/nothing.include +0 -0
- data/bashrc.d/uname.d/Darwin +6 -0
- data/bashrc.d/uname.d/Linux +0 -0
- data/bashrc.local.sample +11 -0
- data/bin/10 +7 -0
- data/bin/10times +7 -0
- data/bin/1every +22 -0
- data/bin/1everyN +22 -0
- data/bin/1suN +22 -0
- data/bin/2 +5 -0
- data/bin/act +24 -0
- data/bin/amarelo +2 -0
- data/bin/arancio +4 -0
- data/bin/arcobaleno +10 -0
- data/bin/bianco +3 -0
- data/bin/black +2 -0
- data/bin/brew-install +3 -0
- data/bin/cache +50 -0
- data/bin/cache3 +50 -0
- data/bin/cheorae +4 -0
- data/bin/colorastdouterr +37 -0
- data/bin/cp2desktop +3 -0
- data/bin/create-git-repo.sh +24 -0
- data/bin/csoe +37 -0
- data/bin/data +3 -0
- data/bin/derive +90 -0
- data/bin/dimmi +31 -0
- data/bin/dimmiora +4 -0
- data/bin/doppioni +48 -0
- data/bin/du- +9 -0
- data/bin/duplicates +48 -0
- data/bin/echodo +7 -0
- data/bin/ensure_line_present +82 -0
- data/bin/epoch2date +5 -0
- data/bin/fanout +100 -0
- data/bin/find-broken-symlink +26 -0
- data/bin/find-duplicates +48 -0
- data/bin/find-special-chars-within-filenames +12 -0
- data/bin/fix-terminal +5 -0
- data/bin/gce-create-centos-instance +5 -0
- data/bin/gce-create-custom-image +8 -0
- data/bin/gce-curl-get-instances-for-project +7 -0
- data/bin/gce-get-token +3 -0
- data/bin/gce-getproject-metadata +35 -0
- data/bin/gce-public-ip +4 -0
- data/bin/gcutil-fetch +36 -0
- data/bin/giallo +2 -0
- data/bin/git-clone-in-non-empty-dir +21 -0
- data/bin/git-ignore +3 -0
- data/bin/git-repos +98 -0
- data/bin/git-repos.py +99 -0
- data/bin/gitinfo +2 -0
- data/bin/google-spreadsheet-cat +40 -0
- data/bin/google_ips +5 -0
- data/bin/gray +3 -0
- data/bin/green +2 -0
- data/bin/grigio +3 -0
- data/bin/gsutil-debug-bucket +12 -0
- data/bin/gsutil-get-oauth2-token +4 -0
- data/bin/gugol-image +74 -0
- data/bin/hamachi-ubuntu-install +17 -0
- data/bin/head-1^-1 +5 -0
- data/bin/ifdownup +13 -0
- data/bin/immature/ok2 +25 -0
- data/bin/immature/twice-still-broken +9 -0
- data/bin/install-gic-repo +13 -0
- data/bin/install-sakura-on-debian-latest +6 -0
- data/bin/iphoto_big_files.sh +37 -0
- data/bin/itunes +140 -0
- data/bin/jason-xpath.rb +54 -0
- data/bin/jsawk +1128 -0
- data/bin/json-xpath.rb +54 -0
- data/bin/keepup +13 -0
- data/bin/lsof-top10 +3 -0
- data/bin/minicook +218 -0
- data/bin/mv2. +2 -0
- data/bin/mv2desktop +2 -0
- data/bin/mv2dropbox +2 -0
- data/bin/mv2here +2 -0
- data/bin/mvto +39 -0
- data/bin/nero +2 -0
- data/bin/never_as_root +18 -0
- data/bin/not +16 -0
- data/bin/ok +42 -0
- data/bin/orange +4 -0
- data/bin/pink +2 -0
- data/bin/polygen-dell +7 -0
- data/bin/polygen-heanet +6 -0
- data/bin/polygen-labs +4 -0
- data/bin/print_key_val +4 -0
- data/bin/rainbow +10 -0
- data/bin/recipe +19 -0
- data/bin/red +2 -0
- data/bin/remember-command +140 -0
- data/bin/remember-command.rb +140 -0
- data/bin/richelp +99 -0
- data/bin/ricorda-comando +140 -0
- data/bin/rosa +2 -0
- data/bin/rosso +2 -0
- data/bin/run-parts.sh +50 -0
- data/bin/sakura-check-version +48 -0
- data/bin/sakura-init.DRAFT +5 -0
- data/bin/sakura-version +2 -0
- data/bin/sano +5 -0
- data/bin/sbianca +3 -0
- data/bin/sblua +2 -0
- data/bin/setterm-reset +5 -0
- data/bin/sgialla +2 -0
- data/bin/sgrigia +2 -0
- data/bin/split +37 -0
- data/bin/split.rb +37 -0
- data/bin/srosa +1 -0
- data/bin/srossa +2 -0
- data/bin/strip-white-spaces +2 -0
- data/bin/stty-sane +5 -0
- data/bin/sudo^-1 +18 -0
- data/bin/sverda +6 -0
- data/bin/swift-saio-install.sh +336 -0
- data/bin/synergyc +0 -0
- data/bin/synergys +0 -0
- data/bin/syracuse.pl +29 -0
- data/bin/tail-n+2 +5 -0
- data/bin/tellme +31 -0
- data/bin/tellme-time +4 -0
- data/bin/timeout3 +91 -0
- data/bin/top5 +4 -0
- data/bin/trim +4 -0
- data/bin/trova-broken-symlink +26 -0
- data/bin/twice +5 -0
- data/bin/twice.rb +5 -0
- data/bin/ubuntu-install-hamachi64 +17 -0
- data/bin/ultimo +5 -0
- data/bin/upload.py +2380 -0
- data/bin/usleep +0 -0
- data/bin/varia +90 -0
- data/bin/verde +2 -0
- data/bin/vermelho +2 -0
- data/bin/vim-whereveritis +5 -0
- data/bin/viola +1 -0
- data/bin/virsh-list-all-vms.py +21 -0
- data/bin/virtualbox-manage +41 -0
- data/bin/weekend +12 -0
- data/bin/whattimeisit +4 -0
- data/bin/whereis-ip +5 -0
- data/bin/white +3 -0
- data/bin/whitefy +3 -0
- data/bin/yellow +2 -0
- data/bin/yellowfy +2 -0
- data/bin/zombies +25 -0
- data/docz/polygen/dell.grm +100 -0
- data/docz/polygen/frati.grm +85 -0
- data/docz/polygen/heanet.grm +54 -0
- data/docz/richelp/gcompute.yml +52 -0
- data/docz/richelp/gcutil.yml +52 -0
- data/docz/richelp/gmail.yml +2 -0
- data/docz/richelp/ruby.yml +81 -0
- data/docz/richelp/sakura.yml +20 -0
- data/docz/richelp/sql.yml +12 -0
- data/docz/richelp/ubuntu.yml +22 -0
- data/docz/richelp/yaml.yml +39 -0
- data/docz/richelp/yml.yml +39 -0
- data/etc/sakura/devel.yml +36 -0
- data/etc/synergy.conf.example +37 -0
- data/images/color-sample.png +0 -0
- data/images/google.jpg +0 -0
- data/images/icons/toilet.png +0 -0
- data/images/sakura.jpg +0 -0
- data/images/sakura2.jpg +0 -0
- data/init.rb +5 -0
- data/lib/classes/arrays.rb +246 -0
- data/lib/classes/debug_ric.rb +196 -0
- data/lib/classes/fake_data.rb +8 -0
- data/lib/classes/ric_debug.rb +0 -0
- data/lib/classes/ricconf.rb +110 -0
- data/lib/classes/richelp.rb +70 -0
- data/lib/classes/strings.rb +284 -0
- data/lib/facter/google_compute_engine.rb +10 -0
- data/lib/recipes/20120411-puppet-rump-palladius.recipe +2 -0
- data/lib/recipes/20120726-skype.ubuntu.recipe +16 -0
- data/lib/recipes/20130206-puppet3.ubuntu.recipe +32 -0
- data/lib/recipes/20130206-redis.linux.recipe +17 -0
- data/lib/recipes/20130208-vanilla.linux.recipe +37 -0
- data/lib/recipes/Makefile +4 -0
- data/lib/recipes/README.md +29 -0
- data/lib/recipes/scripts/redis.sh +14 -0
- data/lib/ric.rb +156 -0
- data/lib/ric_colors.rb +313 -0
- data/lib/ric_strings.rb +285 -0
- data/lib/sonice-players/itunes_mac.rb +43 -0
- data/lib/sonice-players/itunes_win.rb +47 -0
- data/lib/sonice-players/mpd.rb +45 -0
- data/lib/sonice-players/rhythmbox.rb +38 -0
- data/profile +1 -0
- data/sakuric.gemspec +40 -0
- data/sbin/install-sakura-on-debian +25 -0
- data/sbin/make-install.sh +10 -0
- data/sbin/mate-createsymlink +4 -0
- data/sounds/0.ogg +0 -0
- data/sounds/0.wav +0 -0
- data/sounds/01.ogg +0 -0
- data/sounds/02.ogg +0 -0
- data/sounds/03.ogg +0 -0
- data/sounds/08.ogg +0 -0
- data/sounds/09.ogg +0 -0
- data/sounds/1.ogg +0 -0
- data/sounds/1.wav +0 -0
- data/sounds/10.ogg +0 -0
- data/sounds/100.ogg +0 -0
- data/sounds/11.ogg +0 -0
- data/sounds/12.ogg +0 -0
- data/sounds/13.ogg +0 -0
- data/sounds/14.ogg +0 -0
- data/sounds/15.ogg +0 -0
- data/sounds/16.ogg +0 -0
- data/sounds/17.ogg +0 -0
- data/sounds/18.ogg +0 -0
- data/sounds/19.ogg +0 -0
- data/sounds/2.ogg +0 -0
- data/sounds/2.wav +0 -0
- data/sounds/20.ogg +0 -0
- data/sounds/21.ogg +0 -0
- data/sounds/22.ogg +0 -0
- data/sounds/23.ogg +0 -0
- data/sounds/24.ogg +0 -0
- data/sounds/26.ogg +0 -0
- data/sounds/3.ogg +0 -0
- data/sounds/3.wav +0 -0
- data/sounds/30.ogg +0 -0
- data/sounds/34.ogg +0 -0
- data/sounds/4.ogg +0 -0
- data/sounds/4.wav +0 -0
- data/sounds/40.ogg +0 -0
- data/sounds/42.ogg +0 -0
- data/sounds/45.ogg +0 -0
- data/sounds/47.ogg +0 -0
- data/sounds/5.ogg +0 -0
- data/sounds/5.wav +0 -0
- data/sounds/50.ogg +0 -0
- data/sounds/6.ogg +0 -0
- data/sounds/6.wav +0 -0
- data/sounds/60.ogg +0 -0
- data/sounds/7.ogg +0 -0
- data/sounds/7.wav +0 -0
- data/sounds/70.ogg +0 -0
- data/sounds/8.ogg +0 -0
- data/sounds/8.wav +0 -0
- data/sounds/80.ogg +0 -0
- data/sounds/9.ogg +0 -0
- data/sounds/9.wav +0 -0
- data/sounds/90.ogg +0 -0
- data/sounds/a.ogg +0 -0
- data/sounds/aaahhh.ogg +0 -0
- data/sounds/abologna.ogg +0 -0
- data/sounds/adargenta.ogg +0 -0
- data/sounds/alzatiecammina.ogg +0 -0
- data/sounds/apache.ogg +0 -0
- data/sounds/attenzione.ogg +0 -0
- data/sounds/awesome.m4a +0 -0
- data/sounds/bazinga.mp3 +0 -0
- data/sounds/bazinga.ogg +0 -0
- data/sounds/bela regaz.wav +0 -0
- data/sounds/benvenuti.wav +0 -0
- data/sounds/benvenuti2.wav +0 -0
- data/sounds/bergonz.ogg +0 -0
- data/sounds/boh.ogg +0 -0
- data/sounds/buahah.ogg +0 -0
- data/sounds/buonasera.ogg +0 -0
- data/sounds/buongiorno.ogg +0 -0
- data/sounds/burp.ogg +0 -0
- data/sounds/carlo.ogg +0 -0
- data/sounds/cena.ogg +0 -0
- data/sounds/che figata.m4a +0 -0
- data/sounds/che figlio di puttana.m4a +0 -0
- data/sounds/che.ogg +0 -0
- data/sounds/ciao.ogg +0 -0
- data/sounds/ciao.wav +0 -0
- data/sounds/da.ogg +0 -0
- data/sounds/davide.ogg +0 -0
- data/sounds/demone.ogg +0 -0
- data/sounds/dhcp.ogg +0 -0
- data/sounds/dinuovo.ogg +0 -0
- data/sounds/dns.ogg +0 -0
- data/sounds/dopo.ogg +0 -0
- data/sounds/e'.ogg +0 -0
- data/sounds/eattivo.ogg +0 -0
- data/sounds/ee.ogg +0 -0
- data/sounds/ehi.ogg +0 -0
- data/sounds/eoragiu.ogg +0 -0
- data/sounds/eorasu.ogg +0 -0
- data/sounds/eripartita.ogg +0 -0
- data/sounds/estato.ogg +0 -0
- data/sounds/estatoriavviato.ogg +0 -0
- data/sounds/fratro.ogg +0 -0
- data/sounds/frozenbubble.ogg +0 -0
- data/sounds/funziona.ogg +0 -0
- data/sounds/go raibh mile maith agaibh.m4a +0 -0
- data/sounds/grazie.ogg +0 -0
- data/sounds/h1.ogg +0 -0
- data/sounds/hainuovaposta.ogg +0 -0
- data/sounds/hogiamangiato.ogg +0 -0
- data/sounds/host.ogg +0 -0
- data/sounds/il.ogg +0 -0
- data/sounds/ilcomputer.ogg +0 -0
- data/sounds/ilnumerodaleiselezionatoe.ogg +0 -0
- data/sounds/ilprocesso.ogg +0 -0
- data/sounds/ilprogramma.ogg +0 -0
- data/sounds/ilservizio.ogg +0 -0
- data/sounds/imap.ogg +0 -0
- data/sounds/imieisuperpoterimidiconoche.ogg +0 -0
- data/sounds/infunzione.ogg +0 -0
- data/sounds/inpunto.ogg +0 -0
- data/sounds/ipmon.ogg +0 -0
- data/sounds/laconnessioneadinternet.ogg +0 -0
- data/sounds/lastampante.ogg +0 -0
- data/sounds/lazzaron.ogg +0 -0
- data/sounds/ldap.ogg +0 -0
- data/sounds/linterfaccia.ogg +0 -0
- data/sounds/lucilla.ogg +0 -0
- data/sounds/ma vaffanculo.m4a +0 -0
- data/sounds/majjal.wav +0 -0
- data/sounds/mamma.ogg +0 -0
- data/sounds/mauro.ogg +0 -0
- data/sounds/max.ogg +0 -0
- data/sounds/meerda.wav +0 -0
- data/sounds/meno.ogg +0 -0
- data/sounds/merda clo.wav +0 -0
- data/sounds/mezza.ogg +0 -0
- data/sounds/mila.ogg +0 -0
- data/sounds/mille.ogg +0 -0
- data/sounds/minuti.ogg +0 -0
- data/sounds/named.ogg +0 -0
- data/sounds/no.ogg +0 -0
- data/sounds/nohofame.ogg +0 -0
- data/sounds/nonfunziona.ogg +0 -0
- data/sounds/nonriescoatrovare.ogg +0 -0
- data/sounds/nonsarebbeoradilavorare.ogg +0 -0
- data/sounds/nonstalavorando.ogg +0 -0
- data/sounds/numero.wav +0 -0
- data/sounds/ooohhh.ogg +0 -0
- data/sounds/pinger.ogg +0 -0
- data/sounds/pocofa.ogg +0 -0
- data/sounds/pop3.ogg +0 -0
- data/sounds/porca puttana.m4a +0 -0
- data/sounds/porcapupazza.ogg +0 -0
- data/sounds/ppp.ogg +0 -0
- data/sounds/pranzo.ogg +0 -0
- data/sounds/prego.ogg +0 -0
- data/sounds/prima.ogg +0 -0
- data/sounds/qualcosamidice.ogg +0 -0
- data/sounds/raggiungibile.ogg +0 -0
- data/sounds/riccardo.ogg +0 -0
- data/sounds/salsa ridge.wav +0 -0
- data/sounds/scusa.ogg +0 -0
- data/sounds/seriously man.m4a +0 -0
- data/sounds/si.ogg +0 -0
- data/sounds/sito porno con sonoro.wav +0 -0
- data/sounds/socmel.wav +0 -0
- data/sounds/sono.ogg +0 -0
- data/sounds/sonoacasa.ogg +0 -0
- data/sounds/sonole.ogg +0 -0
- data/sounds/sputo.ogg +0 -0
- data/sounds/ssh.ogg +0 -0
- data/sounds/stagiocando.ogg +0 -0
- data/sounds/statospento.ogg +0 -0
- data/sounds/stopaiodipalle.ogg +0 -0
- data/sounds/thesedicks.wav +0 -0
- data/sounds/tornatosu.ogg +0 -0
- data/sounds/trapoco.ogg +0 -0
- data/sounds/trequarti.ogg +0 -0
- data/sounds/tutti.ogg +0 -0
- data/sounds/una.ogg +0 -0
- data/sounds/unquarto.ogg +0 -0
- data/sounds/virgola.ogg +0 -0
- data/sources/c/usleep.c +50 -0
- data/spec/my_first_spec.rb +6 -0
- data/tasks/sakuric-gem.rake +21 -0
- data/tasks/testing.rake +15 -0
- data/templates/bashrc.inject +10 -0
- data/templates/happy_christmas.ascii_art +5 -0
- data/test/roodi.sh +10 -0
- data/test/test_mini_failing.rb +3 -0
- data/test/test_mini_ok.rb +3 -0
- data/test/test_ruby_syntax.sh +12 -0
- data/third-party/jsawk/README.markdown +437 -0
- data/third-party/jsawk/jsawk +1128 -0
- metadata +835 -0
data/bin/json-xpath.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
Try also the Oauth playground: http://googlecodesamples.com/oauth_playground/
|
6
|
+
|
7
|
+
Solves this problem with GCE. It was:
|
8
|
+
|
9
|
+
curl -s http://metadata/0.1/meta-data/network | python -c "import sys,json; print json.load(sys.stdin)['networkInterface'][0]['accessConfiguration'][0]['externalIp']"
|
10
|
+
|
11
|
+
It becomes:
|
12
|
+
|
13
|
+
curl -s http://metadata/0.1/meta-data/network |json-xpath.rb networkInterface.0.accessConfiguration.0.externalIp
|
14
|
+
|
15
|
+
=end
|
16
|
+
$default_arg = "networkInterface.0.accessConfiguration.0.externalIp"
|
17
|
+
|
18
|
+
class String
|
19
|
+
def is_number?
|
20
|
+
true if Float(self) rescue false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def usage
|
26
|
+
print "Usage: #{$0} <xpath>
|
27
|
+
|
28
|
+
Example: #{$0} #{ $default_arg } # this will find your public IP from GCE metadata
|
29
|
+
(Try to use this in pipe with 'curl http://metadata.google.internal/0.1/meta-data/network'
|
30
|
+
"
|
31
|
+
exit(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
def process_args(dotted_arg)
|
35
|
+
arr_args = dotted_arg.split '.'
|
36
|
+
python_program_original = "import sys, json; print json.load(sys.stdin)['networkInterface'][0]['accessConfiguration'][0]['externalIp'] "
|
37
|
+
python_program = "import sys, json; print json.load(sys.stdin)"
|
38
|
+
args = arr_args.map { |arg| arg.to_s.is_number? ? arg.to_s : "'" + arg + "'" }.map{|x| "[#{x}]" }
|
39
|
+
my_program = python_program + args.join('')
|
40
|
+
|
41
|
+
cmd_exec = "/usr/bin/python -c \"#{my_program}\" 2>/dev/null"
|
42
|
+
myin = $stdin.read
|
43
|
+
%x( #{cmd_exec} )
|
44
|
+
IO.popen(cmd_exec, mode='w') do |io|
|
45
|
+
io.write(myin)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def main
|
50
|
+
usage unless ARGV[0]
|
51
|
+
process_args(ARGV[0])
|
52
|
+
end
|
53
|
+
|
54
|
+
main()
|
data/bin/keepup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
SLEEPTIME=${1:-5}
|
4
|
+
SENTENCE="keepup{$HOSTNAME} "
|
5
|
+
|
6
|
+
echo "One dot every $SLEEPTIME seconds... Useful on lame ssh connections to keep them up"
|
7
|
+
echo -en "$SENTENCE"
|
8
|
+
while true; do
|
9
|
+
echo -en .
|
10
|
+
sleep $SLEEPTIME;
|
11
|
+
done
|
12
|
+
|
13
|
+
echo Ciao by carlesso. You should never see this
|
data/bin/lsof-top10
ADDED
data/bin/minicook
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
#!/usr/bin/ruby1.8
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
############################################################
|
6
|
+
@author: Riccardo Carlesso
|
7
|
+
@email: riccardo.carlesso@gmail.com
|
8
|
+
@maturity: development
|
9
|
+
@language: Ruby
|
10
|
+
@synopsis: Brief Description here
|
11
|
+
@tags: development, rcarlesso, test
|
12
|
+
@description: See description
|
13
|
+
############################################################
|
14
|
+
|
15
|
+
=end
|
16
|
+
|
17
|
+
require 'optparse' # http://ruby.about.com/od/advancedruby/a/optionparser.htm
|
18
|
+
require 'yaml'
|
19
|
+
require 'facter'
|
20
|
+
|
21
|
+
require ENV['SAKURADIR'] + '/lib/ric.rb'
|
22
|
+
|
23
|
+
# Program constants, automagically picked up by RicLib
|
24
|
+
# More configuration could be written in:
|
25
|
+
# $SVNHOME/etc/ricsvn/<FILENAME>.yml
|
26
|
+
# That would go into the variable '$prog_conf_d'
|
27
|
+
$myconf = {
|
28
|
+
:app_name => "minicook",
|
29
|
+
:description => "This is a minimal configuration manager for Linux, inspired by Chef and Puppet.
|
30
|
+
Tries to be more agile, to Get things Done (TM)",
|
31
|
+
:recipes_dir => ENV['SAKURADIR'] + '/lib/recipes/',
|
32
|
+
:available_commands => %w{apply help list} ,
|
33
|
+
}
|
34
|
+
|
35
|
+
$PROG_VER = '0.1.1'
|
36
|
+
$DEBUG = false
|
37
|
+
|
38
|
+
def usage(comment=nil)
|
39
|
+
puts $optparse.banner
|
40
|
+
puts $optparse.summarize
|
41
|
+
pred comment if comment
|
42
|
+
puts "Description: #{ $myconf[:description] }"
|
43
|
+
exit 11
|
44
|
+
end
|
45
|
+
|
46
|
+
=begin
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
TODO: locks in case many things access it
|
51
|
+
|
52
|
+
=end
|
53
|
+
class Recipe
|
54
|
+
@prerequisite_checked = false
|
55
|
+
@postrequisite_checked = false
|
56
|
+
|
57
|
+
def initialize(file)
|
58
|
+
@yaml = YAML.load_file(file)
|
59
|
+
puts "Initializing CookBook module: #{yellow @yaml['name']}"
|
60
|
+
validate
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_facter_prerequisites
|
64
|
+
deb 'check facter'
|
65
|
+
if @yaml['prerequisites']['facter']
|
66
|
+
Facter.loadfacts
|
67
|
+
@yaml['prerequisites']['facter'].each do |k,wanted|
|
68
|
+
deb "Checking facter: #{k} => #{wanted}"
|
69
|
+
puts "I have this: #{Facter.send(k)}"
|
70
|
+
puts "I want this: #{wanted}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def check_prerequisites
|
76
|
+
deb @yaml['prerequisites'].inspect
|
77
|
+
# verify FACTER
|
78
|
+
check_facter_prerequisites
|
79
|
+
# verify MODULES
|
80
|
+
deb 'check module'
|
81
|
+
@prerequisite_checked = true
|
82
|
+
true
|
83
|
+
end
|
84
|
+
|
85
|
+
def check_postrequisites
|
86
|
+
#deb @yaml['prerequisites'].inspect
|
87
|
+
if test()
|
88
|
+
green "TEST OK!"
|
89
|
+
else
|
90
|
+
pred "Some error in testing => Rolling back"
|
91
|
+
return false
|
92
|
+
end
|
93
|
+
@postrequisite_checked = true
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def valid?
|
99
|
+
begin
|
100
|
+
validate
|
101
|
+
true
|
102
|
+
rescue
|
103
|
+
false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def execute
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
def install
|
113
|
+
# manage code HERE
|
114
|
+
code = @yaml['code']
|
115
|
+
# manage code FILE
|
116
|
+
pred code.inspect
|
117
|
+
end
|
118
|
+
|
119
|
+
def name
|
120
|
+
@yaml['name']
|
121
|
+
end
|
122
|
+
def description
|
123
|
+
@yaml['description']
|
124
|
+
end
|
125
|
+
|
126
|
+
def test
|
127
|
+
true
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_s(verbose=true)
|
131
|
+
ret = "MiniBookRecipe(#{name})"
|
132
|
+
return ret unless verbose
|
133
|
+
ret += "\nName: #{name}"
|
134
|
+
ret += "\nDescription: #{description}"
|
135
|
+
ret
|
136
|
+
end
|
137
|
+
|
138
|
+
def validate()
|
139
|
+
necessary_fields = %w{ name description prerequisites install uninstall }
|
140
|
+
necessary_fields.each do |key|
|
141
|
+
throw "Missing field: '#{key}' in the yaml file!" unless @yaml[key]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
# include it in main if you want a custome one
|
149
|
+
def init() # see lib_autoinit in lib/util.rb
|
150
|
+
$opts = {}
|
151
|
+
$opts[:recipes_dir] = $myconf[:recipes_dir]
|
152
|
+
$optparse = OptionParser.new do |opts|
|
153
|
+
opts.banner = "#{$0} v.#{$PROG_VER}\n Usage: #{File.basename $0} [directive] [...]\nDirectives are: #{ $myconf[:available_commands].join(',') }"
|
154
|
+
opts.on( '-d', '--debug', 'enables debug (DFLT=false)' ) { $opts[:debug] = true ; $DEBUG = true }
|
155
|
+
opts.on( '-h', '--help', 'Display this screen' ) { puts(opts); exit 1 }
|
156
|
+
opts.on( '-n', '--dryrun', "Don't really execute code" ) { $opts[:dryrun] = true }
|
157
|
+
opts.on( '-l', '--recipes-dir DIR', 'Recipes dir from DIR (dflt:)' ) {|dir| $opts[:recipes_dir] = dir }
|
158
|
+
opts.on( '-v', '--verbose', 'Output more information' ) { $opts[:verbose] = true}
|
159
|
+
end
|
160
|
+
$optparse.parse!
|
161
|
+
end
|
162
|
+
|
163
|
+
def list(dir)
|
164
|
+
files = Dir.glob("#{dir}/*.recipe")
|
165
|
+
puts files.join("\n")
|
166
|
+
files
|
167
|
+
end
|
168
|
+
|
169
|
+
def apply(filename)
|
170
|
+
puts("apply: #{azure filename}")
|
171
|
+
recipe = Recipe.new(filename)
|
172
|
+
puts recipe.to_s(true)
|
173
|
+
# prerequisites
|
174
|
+
pwhite "1. Prerequisites"
|
175
|
+
recipe.check_prerequisites
|
176
|
+
pwhite "2. INSTALL "
|
177
|
+
recipe.install unless $opts[:dryrun]
|
178
|
+
pwhite "3. POSTREQUISITES"
|
179
|
+
recipe.check_postrequisites
|
180
|
+
pwhite "4. finished, reprinting object just for the craic"
|
181
|
+
puts recipe.to_s(true)
|
182
|
+
end
|
183
|
+
|
184
|
+
def real_program
|
185
|
+
debug_on 'Just created script, presuming u need some debug. TODO REMOVE ME when everything works!' if $DEBUG
|
186
|
+
# Maybe you may want to check on ARGV
|
187
|
+
# unless ARGV.size == 2
|
188
|
+
# usage "Give me 2 arguments!"
|
189
|
+
# end
|
190
|
+
deb("Hello world from a templated '#{yellow $0 }'")
|
191
|
+
deb "+ Options are: #{gray $opts}"
|
192
|
+
deb "+ Depured args: #{azure ARGV}"
|
193
|
+
deb "+ Your configuration: #{purple $myconf.inspect}"
|
194
|
+
directive = ARGV[0]
|
195
|
+
case directive
|
196
|
+
#when 1..5
|
197
|
+
# puts "Its between 1 and 5"
|
198
|
+
when 'apply'
|
199
|
+
apply(ARGV[1])
|
200
|
+
when ''
|
201
|
+
when nil
|
202
|
+
usage('give me at least one argument!')
|
203
|
+
when 'help'
|
204
|
+
usage
|
205
|
+
when 'list'
|
206
|
+
list($opts[:recipes_dir])
|
207
|
+
else
|
208
|
+
puts "You gave me unknown directive ('#{directive}') -- I have no idea what to do with that."
|
209
|
+
exit 1
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def main()
|
214
|
+
init
|
215
|
+
real_program
|
216
|
+
end
|
217
|
+
|
218
|
+
main
|
data/bin/mv2.
ADDED
data/bin/mv2desktop
ADDED
data/bin/mv2dropbox
ADDED
data/bin/mv2here
ADDED
data/bin/mvto
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
############################################################
|
4
|
+
# $Id: script.rb 5961 2011-03-30 16:04:21Z rcarlesso $
|
5
|
+
VER=1.0
|
6
|
+
FILES=""
|
7
|
+
|
8
|
+
# check ARGV
|
9
|
+
#echo DEBUG mvto v$VER: NARGS=$#
|
10
|
+
|
11
|
+
if [ $# -lt 2 ]; then
|
12
|
+
echo "Usage: echo $0 <DIR_DEST> [FILE1] [FILE2] .. [FILE_N]"
|
13
|
+
exit 1
|
14
|
+
fi
|
15
|
+
|
16
|
+
DESTDIR="$1"
|
17
|
+
shift
|
18
|
+
|
19
|
+
echo "# Moving files: $(blue "$*") to dir: $(green "$DESTDIR")"
|
20
|
+
|
21
|
+
if [ ! -d "$DESTDIR" ] ; then
|
22
|
+
echo "Sorry, I need a directory and '$DESTDIR' doesnt seem one"
|
23
|
+
exit 2
|
24
|
+
fi
|
25
|
+
|
26
|
+
for F in "$@" ; do
|
27
|
+
#echodo
|
28
|
+
mv -nv "$F" "$DESTDIR"
|
29
|
+
done
|
30
|
+
# FILES="$FILES \"$FILENAME\""
|
31
|
+
# echo "Moving single file '$FILENAME' to $1.. ($(ls -alh "$FILENAME"|awk '{print $5}'|sgialla))"
|
32
|
+
# mv -nv "$FILENAME" "$1" # doesnt overwrite and is verbose..
|
33
|
+
|
34
|
+
#echo "DEBUG: mvto ''$FILES'' => ''$1''"
|
35
|
+
#echo mv $FILES "$1"
|
36
|
+
PWD=$(pwd)
|
37
|
+
echo "To reverse:"
|
38
|
+
echo " cd $DESTDIR"
|
39
|
+
echo " mvto $FILES \"$PWD\""
|
data/bin/nero
ADDED
data/bin/never_as_root
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
usage() {
|
4
|
+
echo "Usage: $(basename $0) [command to be executes not as root]"
|
5
|
+
exit 1
|
6
|
+
}
|
7
|
+
|
8
|
+
if [ $# = 0 ]; then
|
9
|
+
usage
|
10
|
+
fi
|
11
|
+
|
12
|
+
if id |grep -q root ; then
|
13
|
+
echo "$(basename $0): Refusing to exec: '$*'"
|
14
|
+
exit 2
|
15
|
+
fi
|
16
|
+
|
17
|
+
$@
|
18
|
+
|
data/bin/not
ADDED
data/bin/ok
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
FILE=`mktemp -t okidok.XXXXX`
|
4
|
+
LOGFILE=/var/log/riccardo/ok.log
|
5
|
+
touch "$LOGFILE"
|
6
|
+
|
7
|
+
# logs and prints output!
|
8
|
+
oklog() {
|
9
|
+
MSG="$1"
|
10
|
+
logger -f "$LOGFILE" -p info -t ok "$MSG"
|
11
|
+
}
|
12
|
+
|
13
|
+
oklog "Started with args: '$*'"
|
14
|
+
|
15
|
+
if [ "$1" = '-' ] ; then
|
16
|
+
echo 'Called ok with -, assuming STDIN!' >&2
|
17
|
+
oklog "called from stdin"
|
18
|
+
cat | ricnotify yellow "OK from STDIN '$*'"
|
19
|
+
RET=$?
|
20
|
+
oklog "End STDIN RET=$RET for: '$*'"
|
21
|
+
exit $RET
|
22
|
+
fi
|
23
|
+
|
24
|
+
echo "`data` Start '$*'"
|
25
|
+
|
26
|
+
# The 2 followign must NOT be separated!!!
|
27
|
+
"$@" 2>&1 | tee "$FILE"
|
28
|
+
RET=$PIPESTATUS
|
29
|
+
|
30
|
+
MSG=_NONE_
|
31
|
+
|
32
|
+
if [ 0 = $RET ] ; then
|
33
|
+
verde "OK: $*"
|
34
|
+
tail -20 "$FILE" | ricnotify green "OK '$*'"
|
35
|
+
echo "`data` End OK"
|
36
|
+
else
|
37
|
+
rosso "NO(ret=$RET): $*"
|
38
|
+
echo "`data` End (ERR) '$*'"
|
39
|
+
echo "There were some errors which returned: $RET" | ricnotify red "Err with '$*'"
|
40
|
+
fi
|
41
|
+
oklog "End $MSG($RET): '$*'"
|
42
|
+
exit $RET
|
data/bin/orange
ADDED
data/bin/pink
ADDED