Skip to content

Commit d0e55df

Browse files
committed
initial commit
0 parents  commit d0e55df

21 files changed

+520
-0
lines changed

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This is a good default: files that are auto-detected by git to be text are
2+
# converted to the platform-native line ending (LF on Unix, CRLF on Windows)
3+
# in the working tree and to LF in the repository.
4+
#
5+
* text=auto
6+
7+
# Use `eol=crlf` for files that should have the CRLF line ending both in the
8+
# working tree (even on Unix) and in the repository.
9+
#
10+
#*.bat text eol=crlf
11+
12+
# Use `eol=lf` for files that should have the LF line ending both in the
13+
# working tree (even on Windows) and in the repository.
14+
#
15+
#*.sh text eol=lf
16+
17+
# Use `binary` to make sure certain files are never auto-detected as text.
18+
#
19+
#*.png binary

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.bdep/
2+
3+
# Local default options files.
4+
#
5+
.build2/local/
6+
7+
# Compiler/linker output.
8+
#
9+
*.d
10+
*.t
11+
*.i
12+
*.i.*
13+
*.ii
14+
*.ii.*
15+
*.o
16+
*.obj
17+
*.gcm
18+
*.pcm
19+
*.ifc
20+
*.so
21+
*.dll
22+
*.a
23+
*.lib
24+
*.exp
25+
*.pdb
26+
*.ilk
27+
*.exe
28+
*.exe.dlls/
29+
*.exe.manifest
30+
*.pc

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# crails-deploy
2+
3+
C++ executable

build/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/config.build
2+
/root/
3+
/bootstrap/
4+
build/

build/bootstrap.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
project = crails-deploy
2+
3+
using version
4+
using config
5+
using test
6+
using install
7+
using dist

build/root.build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Uncomment to suppress warnings coming from external libraries.
2+
#
3+
#cxx.internal.scope = current
4+
5+
cxx.std = latest
6+
7+
using cxx
8+
9+
hxx{*}: extension = hpp
10+
ixx{*}: extension = ixx
11+
txx{*}: extension = txx
12+
cxx{*}: extension = cpp
13+
14+
# Assume headers are importable unless stated otherwise.
15+
#
16+
hxx{*}: cxx.importable = true
17+
18+
# The test target for cross-testing (running tests under Wine, etc).
19+
#
20+
test.target = $cxx.target

buildfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./: {*/ -build/} doc{README.md} manifest

crails-deploy/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
crails-deploy
2+
3+
# Testscript output directory (can be symlink).
4+
#
5+
test-crails-deploy

crails-deploy/buildfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
libs =
2+
import libs += libcrails-cli%lib{crails-cli}
3+
import libs += libcrails-ssh%lib{crails-ssh}
4+
import libs += libcrails-logger%lib{crails-logger}
5+
6+
exe{crails-deploy}: {hxx ixx txx cxx}{**} $libs testscript
7+
8+
cxx.poptions =+ "-I$out_root" "-I$src_root"
9+
cxx.loptions =+ "-Wl,--start-group" -lssh -lcrypto -lssl -lboost_program_options
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "deploy_application.hpp"
2+
3+
using namespace Crails;
4+
using namespace std;
5+
6+
void ApplicationPackageDeploy::install_application()
7+
{
8+
deploy_package();
9+
create_runtime_directory();
10+
create_log_directory();
11+
}
12+
13+
void ApplicationPackageDeploy::deploy_package()
14+
{
15+
stringstream command;
16+
int rc;
17+
18+
if (sudo) command << "sudo ";
19+
command << "tar xf \"" << tmp_filepath << "\" --directory /";
20+
ssh.make_scp_session("/tmp", Ssh::WriteMode)->push_file(package, tmp_filename);
21+
rc = ssh.exec(command.str(), std_out);
22+
if (rc != 0)
23+
throw std::runtime_error("could not extract package");
24+
ssh.exec("rm \"" + tmp_filepath + '"', null_output);
25+
}
26+
27+
void ApplicationPackageDeploy::create_runtime_directory()
28+
{
29+
if (mkdir(runtime_directory) != 0)
30+
throw std::runtime_error("could not create runtime directory");
31+
}
32+
33+
void ApplicationPackageDeploy::create_log_directory()
34+
{
35+
if (mkdir(log_directory) != 0)
36+
throw std::runtime_error("could not create log directory");
37+
}
38+
39+
int ApplicationPackageDeploy::mkdir(const std::string& path)
40+
{
41+
stringstream command;
42+
43+
if (sudo) command << "sudo ";
44+
command << "mkdir -p \"" << path << '"';
45+
return ssh.exec(command.str(), null_output);
46+
}

0 commit comments

Comments
 (0)