}
}
+ if(!tty) {
+ if(!hostname) {
+ fprintf(stderr, "Could not determine the external address or hostname. Please set Address manually.\n");
+ return NULL;
+ }
+ goto save;
+ }
+
again:
- printf("Please enter your host's external address or hostname");
+ fprintf(stderr, "Please enter your host's external address or hostname");
if(hostname)
- printf(" [%s]", hostname);
- printf(": ");
- fflush(stdout);
+ fprintf(stderr, " [%s]", hostname);
+ fprintf(stderr, ": ");
if(!fgets(line, sizeof line, stdin)) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
if(!access(tinc_conf, F_OK)) {
fprintf(stderr, "Configuration file %s already exists!\n", tinc_conf);
- if(!tty || confbasegiven)
+ if(confbasegiven)
return false;
// Generate a random netname, ask for a better one later.
check_port(name);
ask_netname:
- if(ask_netname) {
+ if(ask_netname && tty) {
fprintf(stderr, "Enter a new netname: ");
if(!fgets(line, sizeof line, stdin)) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
make_names();
}
+ fprintf(stderr, "Configuration stored in: %s\n", confbase);
+
return true;
}
if(argc > 1) {
invitation = argv[1];
} else {
- if(tty) {
- printf("Enter invitation URL: ");
- fflush(stdout);
- }
+ if(tty)
+ fprintf(stderr, "Enter invitation URL: ");
errno = EPIPE;
if(!fgets(line, sizeof line, stdin)) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
/* Check stdin and stdout */
if(ask && tty) {
/* Ask for a file and/or directory name. */
- fprintf(stdout, "Please enter a file to save %s to [%s]: ", what, filename);
- fflush(stdout);
+ fprintf(stderr, "Please enter a file to save %s to [%s]: ", what, filename);
if(fgets(buf, sizeof buf, stdin) == NULL) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
} else if(argc < 2) {
if(tty) {
char buf[1024];
- fprintf(stdout, "Enter the Name you want your tinc node to have: ");
- fflush(stdout);
+ fprintf(stderr, "Enter the Name you want your tinc node to have: ");
if(!fgets(buf, sizeof buf, stdin)) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
return 1;