53 cout <<
"-- dtntrigger (IBR-DTN) --" << endl;
54 cout <<
"Syntax: dtntrigger [options] <name> <shell> [trigger-script]" << endl;
55 cout <<
"<name> the application name" << endl;
56 cout <<
"<shell> shell to execute the trigger script" << endl;
57 cout <<
"[trigger-script] optional: the trigger script to execute on incoming bundle" << endl;
58 cout <<
"* optional parameters *" << endl;
59 cout <<
" -h display this text" << endl;
60 cout <<
" -g <group> join a group" << endl;
61 cout <<
" -w temporary work directory" << endl;
62 cout <<
" -s process signed bundles only" << endl;
65 int init(
int argc,
char** argv)
72 while ((c = getopt (argc, argv,
"hw:g:s")) != -1)
80 group = std::string(optarg);
85 fprintf (stderr,
"Option -%c requires an argument.\n", optopt);
86 else if (isprint (optopt))
87 fprintf (stderr,
"Unknown option `-%c'.\n", optopt);
90 "Unknown option character `\\x%x'.\n",
104 for (index = optind; index < argc; ++index)
109 _appname = std::string(argv[index]);
113 _shell = std::string(argv[index]);
117 _script = std::string(argv[index]);
141 if (_conn != NULL) _conn->
close();
148 int main(
int argc,
char** argv)
151 signal(SIGINT,
term);
152 signal(SIGTERM,
term);
155 if (
init(argc, argv) > 0)
157 return (EXIT_FAILURE);
161 unsigned int backoff = 2;
201 std::fstream out(file.
getPath().c_str(), ios::out|ios::binary|ios::trunc);
202 out.exceptions(std::ios::badbit | std::ios::eofbit);
208 ::system(cmd.c_str());
212 }
catch (
const ios_base::failure&) {
231 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
238 backoff = backoff * 2;
247 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
254 backoff = backoff * 2;
257 }
catch (
const std::exception&) {
263 return (EXIT_SUCCESS);