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,32 @@
1
+ #!/bin/bash
2
+ #
3
+ # watermark.sh
4
+ # $Id: watermark,v 1.1 2004/10/03 10:52:21 ullgren Exp $
5
+ #
6
+ # Add a defined watermark to a series of pictures
7
+ #
8
+
9
+ # Absolute Location of the Watermark file
10
+ WM="/home/bruno/watermark-bmphoto-small.png"
11
+
12
+ if [ ! -n "$1" ]
13
+ then
14
+ zenity --error --text "Please select pics to be watermarked!"
15
+ exit $E_BADARGS
16
+ fi
17
+
18
+ typeset -i CNT=1
19
+ typeset -i CUR=0
20
+
21
+ (
22
+ for pic in "$@"
23
+ do
24
+ echo "#Watermarking $pic"
25
+
26
+ composite -dissolve 40% -gravity SouthEast -geometry +0+10 "$WM" "$pic" "$pic"
27
+
28
+ CUR=$CNT*100/$#
29
+ echo $CUR
30
+ CNT=$CNT+1
31
+ done
32
+ ) | zenity --progress --auto-close --percentage=0
@@ -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,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 -e
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=/mnt/big2/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=squeeze,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 \
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,35 @@
1
+ #!/bin/bash
2
+ total=$#
3
+ current=0
4
+ percent=0
5
+
6
+ (
7
+ while [[ -n "$1" ]]; do
8
+ # update progress bar
9
+ percent=`expr 100 \* $current / $total`
10
+ echo "$percent" ;
11
+ echo "# Processing ($current/$total): $1 "
12
+ #sleep 1
13
+
14
+ # process current file, if a file and not a dir
15
+ if [[ -f "$1" ]]; then
16
+ jhead -ft "$1"
17
+ if [ "$?" = -1 ] ; then
18
+ zenity --error --text="Processing failed"
19
+ fi
20
+ fi
21
+
22
+ # go to next file
23
+ shift
24
+ $((current+=1))
25
+ done
26
+
27
+ echo "# DONE - $total files processed.";
28
+
29
+ ) |
30
+ zenity --progress \
31
+ --title="Changing dates from EXIF" \
32
+ --text="Processing files ..." \
33
+ --percentage=0 --auto-kill
34
+
35
+
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/perl
2
+ use 5.008;
3
+ use strict;
4
+ use Memoize;
5
+
6
+ # usage:
7
+ # git-large-files 500k
8
+ # git-large-files 0.5m
9
+ # git-large-files 5b
10
+
11
+ sub usage { die "usage: git-large-files <size[b|k|m]> [<git-log arguments ...>]\n" }
12
+
13
+ @ARGV or usage();
14
+ my ( $max_size, $unit ) = ( shift =~ /^(\d+)([bkm]?)\z/ ) ? ( $1, $2 ) : usage();
15
+
16
+ my $exp = 10 * ( $unit eq 'b' ? 0 : $unit eq 'k' ? 1 : 2 );
17
+ my $cutoff = $max_size * 2**$exp;
18
+
19
+ sub walk_tree {
20
+ my ( $tree, @path ) = @_;
21
+ my @subtree;
22
+ my @r;
23
+
24
+ {
25
+ open my $ls_tree, '-|', git => 'ls-tree' => -l => $tree
26
+ or die "Couldn't open pipe to git-ls-tree: $!\n";
27
+
28
+ while ( <$ls_tree> ) {
29
+ my ( $type, $sha1, $size, $name ) = /\A[0-7]{6} (\S+) (\S+) +(\S+)\t(.*)/;
30
+ if ( $type eq 'tree' ) {
31
+ push @subtree, [ $sha1, $name ];
32
+ }
33
+ elsif ( $type eq 'blob' and $size >= $cutoff ) {
34
+ push @r, [ $size, @path, $name ];
35
+ }
36
+ }
37
+ }
38
+
39
+ push @r, walk_tree( $_->[0], @path, $_->[1] )
40
+ for @subtree;
41
+
42
+ return @r;
43
+ }
44
+
45
+ memoize 'walk_tree';
46
+
47
+ open my $log, '-|', git => log => @ARGV, '--pretty=format:%T %h %cr'
48
+ or die "Couldn't open pipe to git-log: $!\n";
49
+
50
+ my %seen;
51
+ while ( <$log> ) {
52
+ chomp;
53
+ my ( $tree, $commit, $age ) = split " ", $_, 3;
54
+ my $is_header_printed;
55
+ for ( walk_tree( $tree ) ) {
56
+ my ( $size, @path ) = @$_;
57
+ my $path = join '/', @path;
58
+ next if $seen{ $path }++;
59
+ print "$commit $age\n" if not $is_header_printed++;
60
+ print "\t$size\t$path\n";
61
+ }
62
+ }
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+ max_size_mb=$1
3
+ SAVEIFS=$IFS
4
+ IFS=$(echo -en "\n\b")
5
+
6
+ # Init
7
+ if [ -z "$max_size_mb" ] ; then
8
+ echo "usage: `basename $0` {max size in MB}"
9
+ exit
10
+ fi
11
+ if [[ "$max_size_mb" = *[^0-9]* ]]
12
+ then
13
+ echo "usage: `basename $0` {max size in MB - numeric values only}"
14
+ exit 1
15
+ fi
16
+ if [ "$max_size_mb" -lt "1" ]
17
+ then
18
+ echo "usage: `basename $0` {max size in MB - greater than 1 MB}"
19
+ exit 1
20
+ fi
21
+ max_size=$(($max_size_mb*1024*1024))
22
+ count=0
23
+ echo "* max total: $(($max_size_mb)) MB"
24
+
25
+ # Get total size of staged files
26
+ staged_size=0
27
+ for filename in $(git diff --staged --name-only --relative)
28
+ do
29
+ filesize=$(stat -f "%z" "$filename")
30
+ staged_size=$(($staged_size + $filesize))
31
+ done
32
+ echo "* current staged total: $(($staged_size /(1024*1024))) MB"
33
+
34
+ # Evaluate size with more files
35
+ for filename in $(git ls-files --o)
36
+ do
37
+ filesize=$(stat -f "%z" "$filename")
38
+ future_size=$(($staged_size + $filesize ))
39
+ echo "* considering: $filename"
40
+ if [ "$future_size" -lt "$max_size" ]
41
+ then
42
+ echo " adding $(($filesize/1024)) KB"
43
+ git add "$filename"
44
+ staged_size=$future_size
45
+ else
46
+ echo " not adding $(($filesize/1024)) KB - would exceed $max_size_mb MB limit"
47
+ break 2
48
+ fi
49
+ #echo " size is $current_file_size, total is $staged_size bytes, future is $future_size bytes, max is $max_size bytes"
50
+ done
51
+
52
+ # End
53
+ echo "* total staged is now $(($staged_size /(1024*1024))) MB"
54
+ IFS=$SAVEIFS
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+ #set -x
3
+
4
+ # Shows you the largest objects in your repo's pack file.
5
+ # Written for osx.
6
+ #
7
+ # @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
8
+ # @author Antony Stubbs
9
+
10
+ # set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
11
+ IFS=$'\n';
12
+
13
+ # list all objects including their size, sort by size, take top 10
14
+ objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head -n 30`
15
+
16
+ echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."
17
+
18
+ output="size,pack,SHA,location"
19
+ for y in $objects
20
+ do
21
+ # extract the size in bytes
22
+ size=$((`echo $y | cut -f 5 -d ' '`/1024))
23
+ # extract the compressed size in bytes
24
+ compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
25
+ # extract the SHA
26
+ sha=`echo $y | cut -f 1 -d ' '`
27
+ # find the objects location in the repository tree
28
+ other=`git rev-list --all --objects | grep $sha`
29
+ #lineBreak=`echo -e "\n"`
30
+ output="${output}\n${size},${compressedSize},${other}"
31
+ done
32
+
33
+ echo -e $output | column -t -s ', '