]> git.ipfire.org Git - ipfire-2.x.git/blob - src/install+setup/install/net.c
PXE Boot integriert.
[ipfire-2.x.git] / src / install+setup / install / net.c
1 /* SmoothWall install program.
2 *
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 *
6 * (c) Lawrence Manning, 2001
7 * Stuff for downloading the smoothwall tarball using wget.
8 *
9 */
10
11 #include "install.h"
12
13 extern FILE *flog;
14 extern char *mylog;
15
16 extern char **ctr;
17
18 static int got_url = 0;
19
20 char url[STRING_SIZE] = "http://";;
21
22 static int gettarballurl(char *url, char *message);
23
24 int checktarball(char *file, char *message)
25 {
26 int done;
27 int tries = 0;
28 char commandstring[STRING_SIZE];
29
30 done = 0;
31 while (!done)
32 {
33 if (!got_url && gettarballurl(url, message) != 1)
34 return 0;
35
36 /* remove any successive /'s */
37 while (url[strlen(url)-1] == '/') { url[strlen(url)-1] = '\0'; }
38
39 snprintf(commandstring, STRING_SIZE, "/bin/wget -s -O /dev/null %s/%s", url, file);
40 if (!(runcommandwithstatus(commandstring, ctr[TR_CHECKING])))
41 {
42 done = 1;
43 got_url = 1;
44 }
45 else
46 {
47 errorbox(ctr[TR_FAILED_TO_FIND]);
48 got_url = 0;
49 if (tries == 3)
50 return 1; /* failure */
51 }
52 tries++;
53 }
54
55 return 0;
56 }
57
58 static int gettarballurl(char *url, char *message)
59 {
60 char *values[] = { url, NULL }; /* pointers for the values. */
61 struct newtWinEntry entries[] =
62 { { "", &values[0], 0,}, { NULL, NULL, 0 } };
63 char title[STRING_SIZE];
64 int rc;
65
66 sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
67 rc = newtWinEntries(title, message,
68 60, 5, 5, 50, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
69
70 strncpy(url, values[0], STRING_SIZE);
71
72 return rc;
73 }