]> git.sur5r.net Git - ngadmin/blob - cli/com_restart.c
8ad5845d04670c18cb5635c94755f1504379bb02
[ngadmin] / cli / com_restart.c
1
2 #include "commands.h"
3
4
5
6 bool do_restart (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga UNUSED) {
7  
8  int i, ret=true;
9  const struct swi_attr *sa;
10  char line[16];
11  
12  
13  if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
14   printf("must be logged\n");
15   ret=false;
16   goto end;
17  }
18  
19  
20  printf("The switch will be restarted. Continue ? [y/N]: ");
21  fflush(stdout);
22  
23  if ( fgets(line, sizeof(line), stdin)!=NULL && strcasecmp(line, "y\n")==0 ) {
24   i=ngadmin_restart(nga);
25   printErrCode(i);
26  }
27  
28  
29  end:
30  
31  return ret;
32  
33 }
34
35