Add the tincctl exchange and exchange-all commands.
These are identical to an export/export-all followed by an import, and make it simpler to exchange host config files with other nodes.
This commit is contained in:
parent
dd07c9fc1f
commit
b50a92d0c3
3 changed files with 33 additions and 5 deletions
|
@ -1513,11 +1513,12 @@ tincctl -n @var{netname} import
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
If you are the owner of bar yourself, and you have SSH access to that computer,
|
If you are the owner of bar yourself, and you have SSH access to that computer,
|
||||||
you can also swap the host configuration files using the following commands:
|
you can also swap the host configuration files using the following command:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
tincctl -n @var{netname} export | ssh bar.example.org tincctl -n @var{netname} import
|
tincctl -n @var{netname} export \
|
||||||
ssh bar.example.org tincctl -n @var{netname} export | tincctl -n @var{netname} import
|
| ssh bar.example.org tincctl -n @var{netname} exchange \
|
||||||
|
| tincctl -n @var{netname} import
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
You should repeat this for all nodes you ConnectTo, or which ConnectTo you.
|
You should repeat this for all nodes you ConnectTo, or which ConnectTo you.
|
||||||
|
@ -2202,6 +2203,12 @@ Export all host configuration files to standard output.
|
||||||
Import host configuration file(s) generated by the tincctl export command from standard input.
|
Import host configuration file(s) generated by the tincctl export command from standard input.
|
||||||
Already existing host configuration files are not overwritten unless the option --force is used.
|
Already existing host configuration files are not overwritten unless the option --force is used.
|
||||||
|
|
||||||
|
@item exchange [--force]
|
||||||
|
The same as export followed by import.
|
||||||
|
|
||||||
|
@item exchange-all [--force]
|
||||||
|
The same as export-all followed by import.
|
||||||
|
|
||||||
@item start [tincd options]
|
@item start [tincd options]
|
||||||
Start @samp{tincd}, optionally with the given extra options.
|
Start @samp{tincd}, optionally with the given extra options.
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,10 @@ export command from standard input.
|
||||||
Already existing host configuration files are not overwritten unless the option
|
Already existing host configuration files are not overwritten unless the option
|
||||||
.Fl -force
|
.Fl -force
|
||||||
is used.
|
is used.
|
||||||
|
.It exchange Op Fl -force
|
||||||
|
The same as export followed by import.
|
||||||
|
.It exchange-all Op Fl -force
|
||||||
|
The same as export-all followed by import.
|
||||||
.It start Op tincd options
|
.It start Op tincd options
|
||||||
Start
|
Start
|
||||||
.Xr tincd 8 ,
|
.Xr tincd 8 ,
|
||||||
|
|
|
@ -153,6 +153,8 @@ static void usage(bool status) {
|
||||||
" export Export host configuration of local node to standard output\n"
|
" export Export host configuration of local node to standard output\n"
|
||||||
" export-all Export all host configuration files to standard output\n"
|
" export-all Export all host configuration files to standard output\n"
|
||||||
" import [--force] Import host configuration file(s) from standard input\n"
|
" import [--force] Import host configuration file(s) from standard input\n"
|
||||||
|
" exchange [--force] Same as export followed by import\n"
|
||||||
|
" exchange-all [--force] Same as export-all followed by import\n"
|
||||||
"\n");
|
"\n");
|
||||||
printf("Report bugs to tinc@tinc-vpn.org.\n");
|
printf("Report bugs to tinc@tinc-vpn.org.\n");
|
||||||
}
|
}
|
||||||
|
@ -1883,7 +1885,10 @@ static int cmd_export(int argc, char *argv[]) {
|
||||||
if(!name)
|
if(!name)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return export(name, stdout);
|
int result = export(name, stdout);
|
||||||
|
if(!tty)
|
||||||
|
fclose(stdout);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmd_export_all(int argc, char *argv[]) {
|
static int cmd_export_all(int argc, char *argv[]) {
|
||||||
|
@ -1915,6 +1920,8 @@ static int cmd_export_all(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
if(!tty)
|
||||||
|
fclose(stdout);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1929,7 +1936,7 @@ static int cmd_import(int argc, char *argv[]) {
|
||||||
|
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
char name[4096];
|
char name[4096];
|
||||||
char *filename;
|
char *filename = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool firstline = true;
|
bool firstline = true;
|
||||||
|
|
||||||
|
@ -1991,6 +1998,14 @@ static int cmd_import(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmd_exchange(int argc, char *argv[]) {
|
||||||
|
return cmd_export(argc, argv) ?: cmd_import(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmd_exchange_all(int argc, char *argv[]) {
|
||||||
|
return cmd_export_all(argc, argv) ?: cmd_import(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *command;
|
const char *command;
|
||||||
int (*function)(int argc, char *argv[]);
|
int (*function)(int argc, char *argv[]);
|
||||||
|
@ -2021,6 +2036,8 @@ static const struct {
|
||||||
{"export", cmd_export},
|
{"export", cmd_export},
|
||||||
{"export-all", cmd_export_all},
|
{"export-all", cmd_export_all},
|
||||||
{"import", cmd_import},
|
{"import", cmd_import},
|
||||||
|
{"exchange", cmd_exchange},
|
||||||
|
{"exchange-all", cmd_exchange_all},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue