bmc-tools 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/bin-other/autobackup +70 -0
  3. data/bin-other/autobackup.inc +157 -0
  4. data/bin-other/bob/ExtractPagesFromPDF +0 -0
  5. data/bin-other/bob/backupsync +46 -0
  6. data/bin-other/bob/cachesync +58 -0
  7. data/bin-other/bob/deb +55 -0
  8. data/bin-other/bob/debmirror +2551 -0
  9. data/bin-other/bob/debmirror.marlin +2551 -0
  10. data/bin-other/bob/exif_rotate.sh +34 -0
  11. data/bin-other/bob/exif_rotate_dates.sh +35 -0
  12. data/bin-other/bob/git-big-objects +85 -0
  13. data/bin-other/bob/git-commit-details +22 -0
  14. data/bin-other/bob/git-commit-sizes +16 -0
  15. data/bin-other/bob/git-show-biggest.sh +33 -0
  16. data/bin-other/bob/git_remove_history.sh +24 -0
  17. data/bin-other/bob/git_staged_status.sh +29 -0
  18. data/bin-other/bob/identify_extra_raws +137 -0
  19. data/bin-other/bob/wallpaper_restore.sh +1 -0
  20. data/bin-other/bob/watch_olsr.sh +1 -0
  21. data/bin-other/bob/watch_rbpm_node_status +1 -0
  22. data/bin-other/bob/watermark_bmphoto_large.sh +32 -0
  23. data/bin-other/bob/watermark_bmphoto_small.sh +32 -0
  24. data/bin-other/bubbles/deb +42 -0
  25. data/bin-other/bubbles/firewall.sh +134 -0
  26. data/bin-other/bubbles/kernel-mirror.sh +15 -0
  27. data/bin-other/deb +42 -0
  28. data/bin-other/exif_dates.sh +35 -0
  29. data/bin-other/git-large-files +62 -0
  30. data/bin-other/git_add_upto.sh +54 -0
  31. data/bin-other/git_find_big.sh +33 -0
  32. data/bin-other/git_staged_status.sh +29 -0
  33. data/bin-other/image_resize +43 -0
  34. data/bin-other/kernel-mirror.sh +15 -0
  35. data/bin-other/marlin/deb +42 -0
  36. data/bin-other/marlin/firewall.sh +134 -0
  37. data/bin-other/mysql2svn.sh +36 -0
  38. data/bin-other/syno-cleanup.sh +31 -0
  39. data/bin/dockerize +35 -23
  40. data/bin/image_exif +30 -0
  41. data/bin/image_process +156 -0
  42. data/bin/image_process_wname +138 -0
  43. data/bin/tgv_to_pdf +206 -0
  44. data/bmc-tools.gemspec +1 -1
  45. data/lib/cli.rb +8 -0
  46. data/lib/constants.rb +1 -0
  47. data/lib/docker.rb +15 -0
  48. data/lib/git.rb +21 -0
  49. data/lib/runner.rb +19 -0
  50. metadata +52 -2
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+ SAVEIFS=$IFS
3
+ IFS=$(echo -en "\n\b")
4
+
5
+ # Get total size of staged files
6
+ total=0
7
+ count=0
8
+ for filename in $(git diff --staged --name-only --relative)
9
+ do
10
+ filesize=$(stat -f "%z" "$filename")
11
+ total=$(($total + $filesize))
12
+ count=$(($count + 1))
13
+ done
14
+ echo "staged ..... $(($total /1024)) KB, $count file(s)"
15
+
16
+ # Get total size of staged files
17
+ total=0
18
+ count=0
19
+ for filename in $(git ls-files -o)
20
+ do
21
+ filesize=$(stat -f "%z" "$filename")
22
+ count=$(($count + 1))
23
+ total=$(($total + $filesize))
24
+ done
25
+ echo "unstaged ... $(($total /1024)) KB, $count file(s)"
26
+
27
+ # End
28
+ IFS=$SAVEIFS
29
+
@@ -0,0 +1,43 @@
1
+ #!/bin/bash
2
+
3
+ # Initialize context
4
+ suffix="resized"
5
+ targetsize="$1x$1>"
6
+ shift
7
+ total=$#
8
+
9
+ # Welcome
10
+ echo
11
+ echo "###################################";
12
+ echo "# IMAGE PROCESSOR";
13
+ echo "###################################";
14
+ echo "# "
15
+ echo "# number of files: $total";
16
+ echo "# output size: $targetsize";
17
+ echo "# "
18
+ echo
19
+
20
+ # Start processing
21
+ while [[ -n "$1" ]]; do
22
+ percent=`expr 100 \* $current / $total`
23
+ sedfilter="s/^\(.*\)\.\([^\.]*\)$/\1.${suffix}.\2/"
24
+ temp="$1.temp"
25
+ target=`echo "$1" | sed -e "$sedfilter"`
26
+
27
+ sourcename="`basename \"$1\"`"
28
+ targetname="`basename \"${target}\"`"
29
+
30
+ echo "* $sourcename => ${targetname} ($current/$total, $percent%)"
31
+
32
+ if [[ -f "$1" ]]; then
33
+ convert -resize "${targetsize}" "$1" "${temp}" > /dev/null || exit 1
34
+ mv "$temp" "$target" || exit 1
35
+ fi
36
+
37
+ shift
38
+ let current=current+1
39
+ done
40
+
41
+ echo
42
+ echo "All files have been processed.";
43
+ echo
@@ -0,0 +1,15 @@
1
+ #!/bin/sh
2
+
3
+ DEST="/data/kernel/pub/"
4
+ export RSYNC_PASSWORD="eqSiyOon"
5
+
6
+ rsync mirrors@filehub.kernel.org::pub $DEST \
7
+ --verbose --recursive --times \
8
+ --links --hard-links --delete --delete-after \
9
+ --sparse --force \
10
+ --exclude "/pub/dist"
11
+
12
+ # --links --hard-links --compress --sparse
13
+ # --exclude "*.gz" --exclude "*.gz.sign" --exclude "git" --exclude "scm" \
14
+ # --exclude "*.gz" --exclude "*.gz.sign"
15
+
@@ -0,0 +1,42 @@
1
+ #! /bin/sh
2
+ set -ere
3
+ TASK=$1
4
+ P2=$2
5
+ P3=$3
6
+
7
+ # Config
8
+ #HTTP_MIRROR=gulus.usherbrooke.ca
9
+ #HTTP_MIRROR=non-us.debian.org
10
+ #HTTP_MIRROR=ftp.proxad.net
11
+ #HTTP_MIRROR=mir2.ovh.net
12
+ #HTTP_MIRROR=debian.ens-cachan.fr
13
+ #HTTP_MIRROR=ftp.thaios.net
14
+ #HTTP_MIRROR=ftp.be.debian.org
15
+ HTTP_MIRROR=ftp.fr.debian.org
16
+ LOCALDIR=/mirrors/debian/
17
+ RSYNC_UPDATE_ATTRIBS="--recursive --times --progress --delete --links"
18
+
19
+
20
+ case $TASK in
21
+
22
+ update | up)
23
+ debmirror $LOCALDIR \
24
+ --host=$HTTP_MIRROR \
25
+ --method=http \
26
+ --progress --cleanup --no-source --getcontents \
27
+ --dist=testing,unstable,lenny,sid -arch=i386,amd64 \
28
+ --exclude-deb-section=embedded,hamradio \
29
+ --section=main,contrib,non-free,non-us,main/debian-installer \
30
+ --ignore-release-gpg --pdiff=mirror -\
31
+ --exclude='openarena.*' \
32
+ --exclude='supertuxkart' \
33
+ --exclude='wesnoth'
34
+ ;;
35
+ *)
36
+ echo "usage: $0 {up|update|to-nemo|to-hector|from-nemo|from-hector}"
37
+ exit 1
38
+ ;;
39
+ esac
40
+
41
+ # --dist=testing,unstable,lenny,sid/non-US -arch=i386 \
42
+
@@ -0,0 +1,134 @@
1
+ #!/bin/bash
2
+ # set -x
3
+ #
4
+ ### BEGIN INIT INFO
5
+ # Provides: firewall
6
+ # Required-Start: $named $network $syslog
7
+ # Required-Stop: $named $network $syslog
8
+ # Should-Start:
9
+ # Should-Stop:
10
+ # Default-Start: 2 3 4 5
11
+ # Default-Stop: 0 1 6
12
+ # Short-Description: Firewall script
13
+ # Description: Initializes simple iptables rules for this specific server
14
+ ### END INIT INFO
15
+ #
16
+ IPT=/sbin/iptables
17
+ IF=eth0
18
+ #set -x
19
+
20
+ acceptboth () {
21
+ accept tcp $1 $2
22
+ accept udp $1 $2
23
+ }
24
+ accept () {
25
+ local proto="$1"
26
+ local port="$2"
27
+ local source="$3"
28
+
29
+ for int in $IF
30
+ do
31
+ if [ -z "$source" ]
32
+ then $IPT -A INPUT -i $int -p $proto --dport $port -j ACCEPT
33
+ else $IPT -A INPUT -i $int -p $proto --dport $port --source "$source" -j ACCEPT
34
+ fi
35
+ done
36
+ }
37
+ reset () {
38
+ $IPT -F
39
+ $IPT -F INPUT
40
+ $IPT -F OUTPUT
41
+ $IPT -F FORWARD
42
+ $IPT -F -t nat
43
+ $IPT -X
44
+ $IPT -P INPUT ACCEPT
45
+ $IPT -P OUTPUT ACCEPT
46
+ $IPT -P FORWARD ACCEPT
47
+ }
48
+ prepare () {
49
+ $IPT -A INPUT -i $IF -m state --state ESTABLISHED,RELATED -j ACCEPT
50
+ $IPT -A INPUT -i $IF -p icmp -j ACCEPT
51
+ $IPT -t nat -A POSTROUTING -o $IF -j MASQUERADE
52
+ echo 1 > /proc/sys/net/ipv4/ip_forward
53
+ }
54
+ lock () {
55
+ #$IPT -A INPUT -j LOG
56
+ $IPT -A INPUT -i $IF -j DROP
57
+ #$IPT -P INPUT DROP
58
+ }
59
+
60
+ case "$1" in
61
+ start)
62
+ reset
63
+ prepare
64
+
65
+ # simple services
66
+ accept tcp 22
67
+ acceptboth 123
68
+ accept tcp 21
69
+
70
+ # port-forarding CDN
71
+ accept tcp 22130
72
+ accept tcp 2240
73
+ accept tcp 8040
74
+
75
+ # vmware
76
+ accept tcp 8222
77
+ accept tcp 8333
78
+ accept tcp 902
79
+
80
+ # dns for iodined
81
+ accept udp 53
82
+
83
+ # ldap
84
+ accept tcp 389
85
+ accept tcp 636
86
+
87
+ # web
88
+ accept tcp 80
89
+ accept tcp 443
90
+
91
+ # web
92
+ accept tcp 16514
93
+
94
+ # mysql replication
95
+ accept tcp 3306 crush.bmconseil.com
96
+
97
+ # email
98
+ #accept tcp 25 bourse.brunom.net
99
+ accept tcp 25
100
+ accept tcp 143
101
+ accept tcp 993
102
+ accept tcp 8080
103
+
104
+ # teamspeak
105
+ accept udp 8767
106
+ accept tcp 14534
107
+
108
+ # rsync
109
+ accept tcp 873
110
+ accept tcp 873 bourse.brunom.net
111
+ accept tcp 873 crush.bmconseil.com
112
+
113
+ # icmp
114
+ #accept icmp proxy.ovh.net
115
+ #accept icmp proxy.p19.ovh.net
116
+ #accept icmp proxy.rbx.ovh.net
117
+ #accept icmp ping.ovh.net
118
+ #accept icmp lille.brunom.net
119
+
120
+
121
+ lock
122
+ exit 0
123
+ ;;
124
+
125
+ stop)
126
+ $IPT -F INPUT
127
+ exit 0
128
+ ;;
129
+
130
+ *)
131
+ echo "Usage: $0 {start|stop}"
132
+ exit 1
133
+ ;;
134
+ esac
@@ -0,0 +1,36 @@
1
+ #!/bin/bash
2
+
3
+ TARGET="/home/bruno/mysql2svn/mysql"
4
+ #DUMPFILE="$TARGET/marlin.sql"
5
+ MYSQLDUMP="mysqldump -c --extended-insert=false --compact --hex-blob -u backup"
6
+ MYSQL="mysql -u backup"
7
+ SVNADD="svn -q --force add"
8
+ HOST="`hostname`"
9
+
10
+ echo "* initializing"
11
+ NOW=$(date +%Y%m%d%H%M)
12
+ set -e
13
+ mkdir -p "$TARGET"
14
+ cd "$TARGET"
15
+
16
+
17
+ echo "* listing databases"
18
+ databases=`$MYSQL -e 'SHOW DATABASES;' | grep -Ev '(Database|information_schema|performance_schema)'`
19
+ #echo $databases
20
+
21
+ echo "* dumping databases to files"
22
+ #$MYSQLDUMP -A > "$DUMPFILE"
23
+ for db in $databases; do
24
+ echo " $db"
25
+ dumpfile="$TARGET/$HOST.$db.sql"
26
+ $MYSQLDUMP "$db" > "$dumpfile"
27
+ $SVNADD "$dumpfile"
28
+ done
29
+
30
+
31
+ echo "* committing files to subversion repository"
32
+ #svn add "$DUMPFILE"
33
+ svn commit -m "mysqldump bubbles $NOW" "$DUMPFILE"
34
+
35
+
36
+ echo "* ended"
@@ -0,0 +1,31 @@
1
+ #!/bin/sh
2
+ #find /volume1/photo/ -type d -name @eaDir -exec rm -rfv "{}" \;
3
+
4
+ #ORIGIN="/volume2/files/"
5
+ ORIGIN="./"
6
+ TRASH="/volume2/data/TRASH/cleanup-$(date +%Y%m%d%H%M%S)"
7
+
8
+ mkdir -p "$TRASH"
9
+
10
+ echo "=== REMOVING @eaDir dirs from $ORIGIN"
11
+ i=0
12
+ find "$ORIGIN" -type d -name '@eaDir' | while read FILE
13
+ do
14
+ #echo rm -v "$FILE"
15
+ echo $i - "$FILE"
16
+ mv "$FILE" "$TRASH/eadir-$i"
17
+ i=$(($i + 1))
18
+ done
19
+ echo
20
+
21
+ echo "=== REMOVING .DS_Store dirs from $ORIGIN"
22
+ i=0
23
+ find "$ORIGIN" -type d -name '.DS_Store' | while read FILE
24
+ do
25
+ #echo rm -v "$FILE"
26
+ echo $i - "$FILE"
27
+ mv "$FILE" "$TRASH/dsstore-$i"
28
+ i=$(($i + 1))
29
+ done
30
+ echo
31
+
@@ -1,21 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- DOCKER_REPO = "bmconseil/dummy"
4
-
5
3
  # Try to load external libs, helpers and constants
6
4
  begin
5
+ LIB_DIR = File.expand_path(File.dirname(__FILE__) + "/../lib/")
7
6
  require "rubygems"
8
7
  require "optparse"
9
8
  require 'tempfile'
9
+ require "#{LIB_DIR}/constants"
10
+ require "#{LIB_DIR}/cli"
11
+ require "#{LIB_DIR}/git"
12
+ require "#{LIB_DIR}/docker"
10
13
  rescue LoadError => e
11
14
  raise "EXITING: some basic libs were not found (#{e.message})"
12
15
  end
16
+ include Helpers
13
17
 
14
18
 
15
19
  # Some helpers
16
- def git_check_tag tag
17
- system("git tag -l #{tag}")
20
+ def output_lines popen
21
+ popen.read.lines.map(&:strip)
18
22
  end
23
+
19
24
  def run_cmd command, title
20
25
  puts "* #{title}"
21
26
  puts command
@@ -27,13 +32,15 @@ end
27
32
  # Handle configuration
28
33
  begin
29
34
  # Defaults
30
- opt_tag = nil
31
- opt_latest = false
32
- opt_push = false
35
+ opt_tag = nil
36
+ opt_latest = false
37
+ opt_push = false
38
+ opt_list_tags = false
33
39
 
34
40
  # Parse options and check compliance
35
41
  parser = OptionParser.new do |opts|
36
42
  opts.banner = "Usage: #{File.basename $PROGRAM_NAME} [options] start|stop"
43
+ opts.on("", "--tags", "List all available tags") { |value| opt_list_tags = true }
37
44
  opts.on("-t", "--tag VERSION") { |value| opt_tag = value.to_s }
38
45
  opts.on("-l", "--latest", "Tag build with :latest") { |value| opt_latest = true }
39
46
  opts.on("-p", "--push", "Push the build(s)") { |value| opt_push = true }
@@ -52,28 +59,36 @@ rescue StandardError => e
52
59
  end
53
60
 
54
61
 
55
- # Check context
56
- unless opt_tag
57
- puts "EXITING: params: missing tag"
58
- exit 1
62
+ # Check tag validiy
63
+ available_tags = Git.fetch_tags
64
+ if opt_list_tags
65
+ end_with_tags = "please specify tag to build"
66
+ elsif !opt_tag
67
+ end_with_tags = "please specify tag to build"
68
+ elsif available_tags.include? opt_tag
69
+ end_with_tags = "the specified tag [#{opt_tag}] not found"
70
+ else
71
+ end_with_tags = "all good"
59
72
  end
60
-
61
- # Check tag in git
62
- unless git_check_tag(opt_tag)
63
- puts "EXITING: tag [#{opt_tag}] not found in git"
73
+ if end_with_tags || true
74
+ puts "EXITING: tag: #{end_with_tags}"
75
+ Git.list_tags available_tags
64
76
  exit 1
65
77
  end
66
78
 
79
+
67
80
  # Prepare some context vars
68
81
  temp_archive = "dockerize-archive-#{opt_tag}.tar"
69
82
  release_name = "#{DOCKER_REPO}:#{opt_tag}"
70
83
  release_latest = "#{DOCKER_REPO}:latest"
71
84
 
72
85
  # Prepare commands
73
- cmd_build = "docker build -f Dockerfile --build-arg CODE_ARCHIVE=\"#{temp_archive}\" . -t \"#{release_name}\""
74
- cmd_tag = "docker tag \"#{release_name}\" \"#{release_latest}\""
75
- opt_push = "docker push \"#{release_name}\""
76
- opt_push_latest = "docker push \"#{release_latest}\""
86
+ cmd_archive = Git.cmd_archive temp_archive, opt_tag
87
+ cmd_build = Docker.cmd_build temp_archive, release_name
88
+ cmd_tag = Docker.cmd_tag release_name, release_latest
89
+ opt_push = Docker.cmd_push release_name
90
+ opt_push_latest = Docker.cmd_push release_latest
91
+
77
92
 
78
93
  # Config summary
79
94
  puts "--- DOCKERIZE CONFIG"
@@ -84,10 +99,7 @@ puts
84
99
 
85
100
 
86
101
  # Checkout tag code in temp archive
87
- run_cmd(
88
- "Creating code archive",
89
- "git archive --format=tar -o \"#{temp_archive}\" --prefix=/ #{opt_tag}"
90
- )
102
+ run_cmd cmd_archive, "Creating code archive"
91
103
  archive_size = File.size(temp_archive)
92
104
  puts "> archive size: #{archive_size}"
93
105