kamukabi-kash 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/kash +5 -201
- data/kamukabi-kash-0.1.1.gem +0 -0
- data/lib/kamukabi/kash/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc7188db156242f1715fd57060b63273b70c2e21
|
4
|
+
data.tar.gz: c2bc37e9e72d2cc64b146779ba8d9234b9133f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc1986fc3549d0d4295d54d097ec6e8322ec11b14f705df3bb8506274af7eb71dd27a95c422630cd467698e9506143437e572b755539b6c12ab43da68e5f6ee
|
7
|
+
data.tar.gz: 8e1da004558977038fb81daf91ec9942df0090f1e501d99bfcc045d532cfde2b8fa6aa0612c45b0fb9629e1ea25e53b954c0935763c3ccc6c4d23efc85bbba9a
|
data/exe/kash
CHANGED
@@ -1,201 +1,5 @@
|
|
1
|
-
#!/usr/bin/
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
use Getopt::Std;
|
7
|
-
|
8
|
-
my $root_path = "";
|
9
|
-
my $app = "";
|
10
|
-
my $version = "0.3.2";
|
11
|
-
my $app_domain = "kamukabi.com";
|
12
|
-
my $remotes = "kamukabi";
|
13
|
-
my $quoted_domain = quotemeta $app_domain;
|
14
|
-
my $stage = "";
|
15
|
-
|
16
|
-
my %opt = ();
|
17
|
-
getopts( "si:", \%opt );
|
18
|
-
my %stages = get_stages();
|
19
|
-
if ( defined $opt{s} ) {
|
20
|
-
my @stages = sort keys %stages;
|
21
|
-
print "@stages\n";
|
22
|
-
exit(0);
|
23
|
-
}
|
24
|
-
|
25
|
-
my $identity = "";
|
26
|
-
my $gsc = "ssh";
|
27
|
-
if ( $opt{i} && $opt{i} ne "" ) {
|
28
|
-
die "identity file $opt{i} not exists.\n" unless -f $opt{i};
|
29
|
-
$identity = "-i " . $opt{i};
|
30
|
-
$gsc = "ssh $identity";
|
31
|
-
}
|
32
|
-
|
33
|
-
my %commands = (
|
34
|
-
'autoupdate' => {
|
35
|
-
type => "local",
|
36
|
-
appname_not_required => 1,
|
37
|
-
desc => "automatically download and install new kash",
|
38
|
-
run => sub {
|
39
|
-
my $tmp = `mktemp -d`;
|
40
|
-
chomp($tmp);
|
41
|
-
system( "git", "clone", "git\@bitbucket.org:kamukabi/kash.git",
|
42
|
-
$tmp );
|
43
|
-
chdir $tmp;
|
44
|
-
exec("./install.sh");
|
45
|
-
},
|
46
|
-
},
|
47
|
-
'clone' => {
|
48
|
-
type => "local",
|
49
|
-
min_args => 1,
|
50
|
-
desc => "clone application repository",
|
51
|
-
|
52
|
-
run => sub {
|
53
|
-
my $app = $ARGV[1];
|
54
|
-
print
|
55
|
-
`git clone --origin $remotes$stage git\@$app.$app_domain:$app`;
|
56
|
-
},
|
57
|
-
},
|
58
|
-
'init' => {
|
59
|
-
type => "local",
|
60
|
-
min_args => 1,
|
61
|
-
appname_not_required => 1,
|
62
|
-
desc => "initialize git repo in current directory and set remotes",
|
63
|
-
run => sub {
|
64
|
-
my $app = $ARGV[1];
|
65
|
-
die "First initialize git in this folder. Use: git init\n"
|
66
|
-
unless ( -d ".git" );
|
67
|
-
print
|
68
|
-
`GIT_SSH_COMMAND='$gsc' git remote add $remotes$stage git\@$app.$app_domain:$app`;
|
69
|
-
},
|
70
|
-
},
|
71
|
-
'deploy' => {
|
72
|
-
type => "local",
|
73
|
-
desc => "send code to kamukabi server",
|
74
|
-
run => sub {
|
75
|
-
system("GIT_SSH_COMMAND='$gsc' git push $remotes$stage `git branch --no-color 2>/dev/null | grep '*' | sed -e 's/\\* //'`:master");
|
76
|
-
if ( $? == 0 ) {
|
77
|
-
print
|
78
|
-
"Your build went fine. Let's attach to your app output. (Ctrl+c to exit)\n";
|
79
|
-
exec
|
80
|
-
"ssh $identity -t cmd\@$app.$app_domain $app $version logs -f";
|
81
|
-
}
|
82
|
-
},
|
83
|
-
},
|
84
|
-
'ftp' => {
|
85
|
-
type => "sftp",
|
86
|
-
desc => "start ftp shell on your app storage",
|
87
|
-
},
|
88
|
-
'run' => {
|
89
|
-
min_args => 1,
|
90
|
-
desc => "send command to aplication",
|
91
|
-
},
|
92
|
-
'restart' => { desc => "restart your aplication", },
|
93
|
-
'rebuild' => { desc => "restart build process", },
|
94
|
-
'logs' => { desc => "show app output", args => "[{-f|-n NUM}]", },
|
95
|
-
'pg' => {
|
96
|
-
desc => "Shared postgresql managment",
|
97
|
-
childs => {
|
98
|
-
'backup' => { desc => "backup your database to ftp", },
|
99
|
-
'restore' =>
|
100
|
-
{ desc => "restore your database from database.sql on ftp", },
|
101
|
-
'console' => { desc => "open pgsql console", },
|
102
|
-
}
|
103
|
-
},
|
104
|
-
'mysql' => {
|
105
|
-
desc => "Shared mysql managment",
|
106
|
-
childs => {
|
107
|
-
'backup' => { desc => "backup your database to ftp", },
|
108
|
-
'restore' =>
|
109
|
-
{ desc => "restore your database from database.sql on ftp", },
|
110
|
-
'console' => { desc => "open mysql console", },
|
111
|
-
}
|
112
|
-
},
|
113
|
-
);
|
114
|
-
|
115
|
-
usage() if scalar @ARGV == 0;
|
116
|
-
|
117
|
-
if ( scalar @ARGV > 1 && defined $commands{ $ARGV[1] } ) {
|
118
|
-
$stage = "$ARGV[0]";
|
119
|
-
shift @ARGV;
|
120
|
-
}
|
121
|
-
|
122
|
-
my $command = $ARGV[0];
|
123
|
-
my $c = $commands{$command};
|
124
|
-
usage() if not defined $c;
|
125
|
-
while ( defined $c->{childs} ) {
|
126
|
-
usage() if scalar @ARGV == 1;
|
127
|
-
usage() if not defined $c->{childs}->{ $ARGV[1] };
|
128
|
-
$command = "$ARGV[0]:$ARGV[1]";
|
129
|
-
$c = $c->{childs}->{ $ARGV[1] };
|
130
|
-
shift @ARGV;
|
131
|
-
}
|
132
|
-
|
133
|
-
my @args = @ARGV[ 1 .. $#ARGV ];
|
134
|
-
if ( $c->{min_args} && scalar @args < $c->{min_args} ) {
|
135
|
-
die("Command ($command) require at least $c->{min_args} arguments.\n");
|
136
|
-
}
|
137
|
-
if ( !defined $c->{appname_not_required} ) {
|
138
|
-
die("Unknow stage: $stage\n")
|
139
|
-
if $stage ne "" && not defined $stages{$stage};
|
140
|
-
die("First initialize project or clone it!\n")
|
141
|
-
if not defined $stages{$stage};
|
142
|
-
$app = $stages{$stage};
|
143
|
-
}
|
144
|
-
$stage = "-$stage" if $stage ne "";
|
145
|
-
$c->{type} //= 'ssh';
|
146
|
-
for ( $c->{type} ) {
|
147
|
-
exit( $c->{run}() ) if /local/;
|
148
|
-
exec "sftp $identity -P2222 $app\@$app.$app_domain" if /ftp/;
|
149
|
-
exec
|
150
|
-
"ssh $identity -t cmd\@$app.$app_domain $app $version $command @args";
|
151
|
-
}
|
152
|
-
|
153
|
-
sub get_stages {
|
154
|
-
$root_path = `git rev-parse --show-toplevel 2>/dev/null`;
|
155
|
-
return () if ( $root_path eq "\n" );
|
156
|
-
chomp($root_path);
|
157
|
-
open( my $fh, "<", ".git/config" ) or return ();
|
158
|
-
my %stages;
|
159
|
-
my $st;
|
160
|
-
while (<$fh>) {
|
161
|
-
if (/^\[(.+)\]$/) {
|
162
|
-
$st = undef;
|
163
|
-
}
|
164
|
-
if (/\[remote "$remotes-?(.*)"\]/) {
|
165
|
-
$st = $1;
|
166
|
-
}
|
167
|
-
if (/url = git@(.+)\.$quoted_domain:/) {
|
168
|
-
$stages{$st} = $1 if defined $st;
|
169
|
-
}
|
170
|
-
}
|
171
|
-
return %stages;
|
172
|
-
}
|
173
|
-
|
174
|
-
sub usage {
|
175
|
-
print "Kamukabi toolbox $version\nUsage: \n";
|
176
|
-
print " kash [-i key.pub] [-s] [STAGE] COMMAND\n";
|
177
|
-
print "Stage is a sufix used in git remote definition.\n";
|
178
|
-
print
|
179
|
-
" -i Selects a file from which the identity (private key) for public key authentication is read.\n";
|
180
|
-
print " -s List known stages in this project.\n";
|
181
|
-
print "Supported commands:\n";
|
182
|
-
usage_commands( " ", \%commands );
|
183
|
-
exit 0;
|
184
|
-
}
|
185
|
-
|
186
|
-
sub usage_commands {
|
187
|
-
my ( $i, $commands_ref ) = @_;
|
188
|
-
for ( sort keys %{$commands_ref} ) {
|
189
|
-
$commands_ref->{$_}->{args} //= "";
|
190
|
-
printf(
|
191
|
-
"$i%-11s %-14s - %s\n",
|
192
|
-
$_,
|
193
|
-
$commands_ref->{$_}->{args},
|
194
|
-
$commands_ref->{$_}->{desc}
|
195
|
-
);
|
196
|
-
if ( defined $commands_ref->{$_}->{childs} ) {
|
197
|
-
usage_commands( " $i", $commands_ref->{$_}->{childs} );
|
198
|
-
}
|
199
|
-
}
|
200
|
-
}
|
201
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
dir = File.expand_path File.dirname(__FILE__)
|
5
|
+
Bundler.clean_exec("#{dir}/perl-kash/kash")
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamukabi-kash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Polewski
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- contributors.txt
|
78
78
|
- exe/kash
|
79
79
|
- kamukabi-kash-0.1.0.gem
|
80
|
+
- kamukabi-kash-0.1.1.gem
|
80
81
|
- kamukabi-kash.gemspec
|
81
82
|
- lib/kamukabi/kash.rb
|
82
83
|
- lib/kamukabi/kash/version.rb
|