summaryrefslogtreecommitdiffstats
path: root/wizzard.c
blob: 80851c9849d5c79eb462aa3133365790ce86628c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*****************************************************************************\
**                                                                           **
** PBX4Linux                                                                 **
**                                                                           **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg                                              **
**                                                                           **
** installation wizzard                                                      **
**                                                                           **
\*****************************************************************************/ 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *check_mISDN(void)
{
}

char *install_mISDN(void)
{
}

char *check_kernel(void)
{
}

char *install_kernel(void)
{
}

char *check_includes(void)
{
}

char *install_includes(void)
{
}

char *check_device(void)
{
}

char *install_device(void)
{
}

char *check_lib(void)
{
}

char *install_lib(void)
{
}

char *check_isdnnet(void)
{
}

char *install_isdnnet(void)
{
}

char *check_pbx(void)
{
}

char *install_pbx(void)
{
}

char *check_mISDNrc(void)
{
}

char *install_mISDNrc(void)
{
}


struct jobs {
	char *name;
	(char *(check))(void);
	(char *(install))(void);
} jobs[] = {
	{ "Install mISDN to kernel Source.", check_mISDN, install_mISDN },
	{ "Compile and install Kernel.", check_kernel, install_kernel },
	{ "Copy user space includes.", check_includes, install_includes },
	{ "Create \"/dev/mISDN\" device", check_device, install_device },
	{ "Compile mISDN device library.", check_lib, install_lib },
	{ "Compile mISDN NT-mode library.", check_isdnnet, install_isdnnet },
	{ "Compile and install PBX4Linux.", check_pbx, install_pbx },
	{ "Create mISDNrc to load mISDN.", check_mISDNrc, install_mISDNrc },
	{ NULL, NULL, NULL},
};


int main(int argc, char *argv[])
{
	int allok = 1;
	int i;
	char *ret;
	char input[256];

	printf("\nWelcome to PBX4Linux installation wizzard.\n\n");

	again:

	/* check what to do */
	i = 0;
	while(jobs[i].name)
	{
		printf("Checking: %s - ", jobs[i].name);
		fflush(stdout);
		ret = jobs[i].check();
		if (ret == NULL)
			printf("OK\n");
		else {
			printf("%s\n", ret);
			allok = 0;
		}
		i++;
	}

	/* if all ok */
	if (allok)
	{
		printf("\nEverything seems to be correctly installed. Do you like to continue? (y/n)");
		fflush(stdout);
		do {
			scanf("%s", input);
		} while(input[0] != 'y' && input[0] != 'n');
		if (input[0] == 'n')
			return(0);
		
	}

	/* select installation step(s) */
	printf("\nPlease select one of the following install options:\n");
	printf("a - Complete installation with all of the following steps\n");
	i = 0;
	while(jobs[i].name)
	{
		printf("%d - Step %d: %s\n", i+1, i+1, jobs[i].name);
		i++;
	}
	printf("x - Exit wizzard.\n");
	printf("\n(a/1-%d/x)", i);
	fflush(stdout);
	do {
		scanf("%s", input);
	} while(input[0]!='a' && (input[0]<'1' || input[0]>('0'+i)) && input[0]!='x');
	if (input[0] == 'x')
		return(0);
	i = 0;
	while(jobs[i].name)
	{
		if (input[0]=='a' || (input[0]-'1')==i)
		{
			printf("\nDoing Step %d: %s\n", i+1, jobs[i].name);
			ret = jobs[i].check();
			if (ret)
				printf("It is required to continue with this step. Dou you want to continue? (y/n)");
			else
				printf("It is not required to continue with this step. Still want to continue? (y/n)");
			fflush(stdout);
			do {
				scanf("%s", input);
			} while(input[0] != 'y' && input[0] != 'n');
			if (input[0] == 'n')
				i++;
				continue;
			}
			ret = jobs[i].install();
			if (ret)
			{
				printf("Failed to install step: %s\n", jobs[i].name);
				printf("%s\n", ret);
				printf("Do you like to retry? (y/n)");
				fflush(stdout);
				do {
					scanf("%s", input);
				} while(input[0] != 'y' && input[0] != 'n');
				if (input[0] == 'y')
					continue;
				}
				break;
			}
		i++;
	}
	goto again;
}