+ char filename2[PATH_MAX];
+ snprintf(filename, sizeof(filename), "%s" SLASH "tinc-up.invitation", confbase);
+ snprintf(filename2, sizeof(filename2), "%s" SLASH "tinc-up", confbase);
+
+ if(valid_tinc_up) {
+ if(tty) {
+ FILE *fup = fopen(filename, "r");
+
+ if(fup) {
+ fprintf(stderr, "\nPlease review the following tinc-up script:\n\n");
+
+ char buf[MAXSIZE];
+
+ while(fgets(buf, sizeof(buf), fup)) {
+ fputs(buf, stderr);
+ }
+
+ fclose(fup);
+
+ int response = 0;
+
+ do {
+ fprintf(stderr, "\nDo you want to use this script [y]es/[n]o/[e]dit? ");
+ response = tolower(getchar());
+ } while(!strchr("yne", response));
+
+ fprintf(stderr, "\n");
+
+ if(response == 'e') {
+ char *command;
+#ifndef HAVE_MINGW
+ xasprintf(&command, "\"%s\" \"%s\"", getenv("VISUAL") ? : getenv("EDITOR") ? : "vi", filename);
+#else
+ xasprintf(&command, "edit \"%s\"", filename);
+#endif
+
+ if(system(command)) {
+ response = 'n';
+ } else {
+ response = 'y';
+ }
+
+ free(command);
+ }
+
+ if(response == 'y') {
+ rename(filename, filename2);
+ chmod(filename2, 0755);
+ fprintf(stderr, "tinc-up enabled.\n");
+ } else {
+ fprintf(stderr, "tinc-up has been left disabled.\n");
+ }
+ }
+ } else {
+ fprintf(stderr, "A tinc-up script was generated, but has been left disabled.\n");
+ }
+ } else {
+ // A placeholder was generated.
+ rename(filename, filename2);
+ chmod(filename2, 0755);
+ }
+
+ fprintf(stderr, "Configuration stored in: %s\n", confbase);
+