52 cout <<
"-- dtntrigger (IBR-DTN) --" << endl;
53 cout <<
"Syntax: dtntrigger [options] <name> <shell> [trigger-script]" << endl;
54 cout <<
"<name> The application name" << endl;
55 cout <<
"<shell> Shell to execute the trigger script" << endl;
56 cout <<
"[trigger-script] The trigger script to execute on incoming bundle (optional)" << endl << endl;
57 cout <<
"* optional parameters *" << endl;
58 cout <<
" -h Display this text" << endl;
59 cout <<
" -g <group> Join a group" << endl;
60 cout <<
" -w Temporary work directory" << endl;
61 cout <<
" -s Process signed bundles only" << endl;
64 int init(
int argc,
char** argv)
71 while ((c = getopt (argc, argv,
"hw:g:s")) != -1)
79 group = std::string(optarg);
84 fprintf (stderr,
"Option -%c requires an argument.\n", optopt);
85 else if (isprint (optopt))
86 fprintf (stderr,
"Unknown option `-%c'.\n", optopt);
89 "Unknown option character `\\x%x'.\n",
103 for (index = optind; index < argc; ++index)
108 _appname = std::string(argv[index]);
112 _shell = std::string(argv[index]);
116 _script = std::string(argv[index]);
140 if (_conn != NULL) _conn->
close();
147 int main(
int argc,
char** argv)
151 sighandler.
handle(SIGINT);
152 sighandler.
handle(SIGTERM);
155 if (
init(argc, argv) > 0)
157 return (EXIT_FAILURE);
164 unsigned int backoff = 2;
204 std::fstream out(file.
getPath().c_str(), ios::out|ios::binary|ios::trunc);
205 out.exceptions(std::ios::badbit | std::ios::eofbit);
211 ::system(cmd.c_str());
215 }
catch (
const ios_base::failure&) {
234 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
241 backoff = backoff * 2;
250 cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << endl;
257 backoff = backoff * 2;
260 }
catch (
const std::exception&) {
266 return (EXIT_SUCCESS);