forked from open-learning-exchange/BeLL-Apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·440 lines (422 loc) · 12.9 KB
/
install
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#!/usr/bin/env node
/**
* Module dependencies.
*/
var sys = require('sys')
var fs = require('fs')
var exec = require('child_process').exec;
var program = require('commander');
var databases = []
program
.version('0.0.2')
.parse(process.argv);
if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.')
var couchUrl = program.args[0]
var nano = require('nano')(couchUrl)
function start() {
increaseLimits()
}
// Increase Limits so couchapp push works correctly
function increaseLimits() {
exec('sudo launchctl limit maxfiles 150056 150056', function doneWithLaunchCtl() {
exec('sudo ulimit -n 150056', function doneWithUlimit() {
return getListOfDatabases()
})
})
}
function getListOfDatabases() {
fs.readdir('./databases', function doneReadDir(err, files) {
files.forEach(function addFile(element, index, array) {
databases.push(element.substr(0, element.length - 3))
})
installDatabases()
})
}
var a = 0
function installDatabases() {
var database = databases[a]
if (a !== databases.length) {
console.log("creating database " + database)
nano.db.create(database, function(err, body) {
if (err && err.error !== "file_exists") console.log(err)
a++
return installDatabases()
})
} else {
return installDesignDocs()
}
}
var b = 0
function installDesignDocs() {
var database = databases[b]
if (b !== databases.length) {
if (database != "communities" && database != "languages" && database != "configurations") {
console.log("Inserting design docs for the " + database + " database")
exec('node_modules/.bin/couchapp push ./databases/' + database + '.js ' + couchUrl + '/' + database, function(error, stdout, stderr) {
if (error) console.log(error);
if (stderr) console.log(stderr);
console.log(stdout)
b++
installDesignDocs()
})
} else {
b++
installDesignDocs()
}
} else {
createDefaultAdminMember()
//createLanguages();
}
}
function createDefaultAdminMember() {
nano.db.get('members', function(err, body) {
if (err) console.log(err)
// Cancel if there are already members in the database
if (body.doc_count > 1) return done()
console.log('Creating a default admin member of admin:password')
var members = nano.db.use('members')
var defaultAdminMember = {
"login": "admin",
"kind": "Member",
"roles": ["Manager", "SuperManager"],
"firstName": "Default",
"lastName": "Admin",
"password": "password",
"Gender": "Male",
"status": "active",
"email": "[email protected]",
"visits": 0
}
var configurationsDoc = {
"name": "olesomalia",
"nationName": "olenation",
"code": "so",
"type": "nation",
"nationUrl": "olenation.cloudant.com",
"version": "0.10.0",
"notes": "this is testing .....asdf",
"availableLanguages": ["English", "French", "Arabic", "Urdu"],
"currentLanguage": "English"
};
/* var languagesDoc = {
"Dashboard": "ڈیش بورڈ",
"Library": "لائبریری",
"Courses": "کورسز",
"Meetups": "اجلاس",
"Members": "اراکین",
"Reports": "رپورٹیں",
"Feedback": "آپ کی رائے",
"Logout": "لاگ آؤٹ",
"Badges": "بلے",
"Calender": "کیلنڈر",
"Email": "ای میل",
"Update_Welcome_Video": "اپ ڈیٹ خوش آمدید ویڈیو",
"Community": "کمیونٹی",
"Nation": "قوم",
"Bell": "بیل",
"Manager": "مینیجر",
"Super_Manager": "سپر مینیجر",
"Leader": "لیڈر",
"Learner": "طالب علم",
"Visits": "دورے",
"Days": [
{
"Sunday": "اتوار",
"Monday": "پیر",
"Tuesday": "منگل",
"Wednesday": "بدھ",
"Thursday": "جمعرات",
"Friday": "جمعہ",
"Saturday": "ہفتہ"
}
],
"Months": [
{
"January": "جنوری",
"February": "فروری",
"March": "مارچ",
"April": "اپریل",
"May": "مئی",
"June": "جون",
"July": "جولائی",
"August": "اگست",
"September": "ستمبر",
"October": "اکتوبر",
"November": "نومبر",
"December": "دسمبر"
}
],
"nameOfLanguage": "Urdu",
"e_Readers": "ای قارئین",
"News_Feed": "خبریں",
"My_Library": "میری لائبریری",
"My_Courses_Progress": "میرے کورسز پیش رفت",
"My_Tutors": "میرا ٹیوٹر",
"My_Meetups": "میری میٹنگ",
"Member": "ممبر",
"Login": "لاگ ان",
"Password": " پاس ورڈ",
"Sign_In": "سائن ان کریں",
"Become_a_member": "رکن بنیے",
"My_Home": "صفحہ اول",
"Welcome": " خوش آمدید",
"Functionality_Under_Construction": "یہ فعالیت زیر تعمیر ہے",
"Add_new_Resource": "نئے ریسورس شامل کریے",
"Search": "تلاش کریں",
"Collection": "مجموعہ",
"Resources": "ريسورسس",
"Title": "عنوان",
"action": "کارروائی",
"year": "سال",
"media": "میڈیا",
"language": "زبان",
"subject": "مضمون",
"level": "درجہ",
"publisher_attribution": "پبلیشر / نسبت",
"link_to_license": "لائسنس کے لئے لنک",
"resource_for": "ريسورس کے لئے",
"author": "مصنف",
"Request_Resource": "درخواست براےء ريسورس",
"Back": "پیچھے",
"Next": "اگلا",
"Home": "ہوم",
"resource_type": "ريسورس کی قسم",
"Open": "کھولیں",
"View": "دیکھیں",
"Details": "تفصیلات",
"Add_to_my_library": "میری لائبریری میں شامل کریں",
"Delete": "حذف",
"Hide": "چھپائیں"
};
var englishLangDoc={
"Dashboard": "My Home",
"Library": "Library",
"Courses": "Courses",
"Meetups": "Meetups",
"Members": "Members",
"Reports": "Reports",
"Feedback": "Feedback",
"Logout": "Logout",
"Badges": "Badges",
"Calender": "Calendar",
"Email": "Email",
"Update_Welcome_Video": "Update Welcome Video",
"Nation": "Nation",
"Community": "Community",
"Manager": "Manager",
"Super_Manager": "Super Manager",
"Leader": "Leader",
"Bell": "Bell",
"Learner": "Learner",
"Visits": "Visits",
"Days": [
{
"Sunday": "Sunday",
"Monday": "Monday",
"Tuesday": "Tuesday",
"Wednesday": "Wednesday",
"Thursday": "Thursday",
"Friday": "Friday",
"Saturday": "Saturday"
}
],
"Months": [
{
"January": "January",
"February": "February",
"March": "March",
"April": "April",
"May": "May",
"June": "June",
"July": "July",
"August": "August",
"September": "September",
"October": "October",
"November": "November",
"December": "December"
}
],
"nameOfLanguage": "English",
"e_Readers": "e-Readers",
"My_Courses_Progress": "My Courses Progress",
"My_Library": "My Library",
"My_Meetups": "My Meetups",
"My_Tutors": "My Tutors",
"News_Feed": "News Feed",
"Member": "Member",
"Login": "Login",
"Password": "Password",
"Sign_In": "Sign In",
"Become_a_member": "Become a Member",
"My_Home": "My Home",
"Welcome": "Welcome",
"Functionality_Under_Construction": "This Functionality is under construction.",
"Search": "Search",
"Collection": "Collection",
"Resources": "Resouces",
"Title": "Title",
"action": "Action",
"year": "Year",
"media": "Media",
"language": "Language",
"subject": "Subject(s)",
"level": "Level(s)",
"publisher_attribution": "Publisher/Attribution",
"link_to_license": "Link to License",
"resource_for": "Resource For",
"resource _type": "Resource Type",
"author": "Author",
"Request_Resource": "Request Resource",
"Back": "Back",
"Next": "Next",
"Home": "Home",
"Open": "Open",
"View": "View",
"Details": "Details",
"Delete": "Delete",
"Hide": "Hide",
"Add_to_my_library": "Add to My Library",
"Add_new_Resource": "Add New Resource"
};*/
members.insert(defaultAdminMember, function(err, res) {
if (err)
return console.log(err)
else {
var configurations = nano.db.use('configurations');
configurations.insert(configurationsDoc, function(err, res) {
if (err) {
console.log(err);
} else {
var languages = nano.db.use('languages');
console.log("******************Going to insert document into languages database*******************************");
var langEngDocPath = 'init_docs/languages.txt';
insertLanguagesDoc(langEngDocPath);
langEngDocPath = 'init_docs/languages-Urdu.txt';
insertLanguagesDoc(langEngDocPath);
langEngDocPath = 'init_docs/languages-Arabic.txt';
insertLanguagesDoc(langEngDocPath);
/* var langEngDocPath = 'init_docs/languages.txt';
var langUrduDocPath = 'init_docs/languages-Urdu.txt';
insertLanguagesDoc(langEngDocPath);
insertLanguagesDoc(langUrduDocPath);*/
}
});
}
done()
})
})
}
function insertLanguagesDoc(docPath) {
var languages = nano.db.use('languages');
fs.readFile(docPath, function (err, data) {
languages.insert(data, function (err, res) {
if (err) {
console.log(err);
} else {
console.log("Languages doc inserted successfully.");
}
});
});
}
/*function createLanguages() {
// Cancel if there are already lagug in the database
//if (body.doc_count > 1) return done()
console.log('Creating languages list in the database.')
var languages = nano.db.use('languages');
var english = {
"name":"English",
"type":"languageDoc"
};
var spanish = {
"name":"Spanish",
"type":"languageDoc"
};
var portuguese = {
"name":"Portuguese",
"type":"languageDoc"
};
var french = {
"name":"French",
"type":"languageDoc"
};
var russian = {
"name":"Russian",
"type":"languageDoc"
};
var chinese = {
"name":"Chinese",
"type":"languageDoc"
};
var arabic = {
"name":"Arabic",
"type":"languageDoc"
};
var hindi = {
"name":"Hindi",
"type":"languageDoc"
};
var urdu = {
"name":"Urdu",
"type":"languageDoc"
};
var punjabi = {
"name":"Punjabi",
"type":"languageDoc"
};
var nepali = {
"name":"Nepali",
"type":"languageDoc"
};
var swahili = {
"name":"Swahili",
"type":"languageDoc"
};
var somali = {
"name":"Somali",
"type":"languageDoc"
};
var kyrgyzstani = {
"name":"Kyrgyzstani",
"type":"languageDoc"
};
var asante = {
"name":"Asante",
"type":"languageDoc"
};
var ewe = {
"name":"Ewe",
"type":"languageDoc"
};
var languagesList = [];
languagesList.push(english);
languagesList.push(spanish);
languagesList.push(portuguese);
languagesList.push(french);
languagesList.push(russian);
languagesList.push(chinese);
languagesList.push(arabic);
languagesList.push(hindi);
languagesList.push(urdu);
languagesList.push(punjabi);
languagesList.push(nepali);
languagesList.push(swahili);
languagesList.push(somali);
languagesList.push(kyrgyzstani);
languagesList.push(asante);
languagesList.push(ewe);
for(var i = 0 ; i< languagesList.length ; i++) {
languages.insert(languagesList[i], function(err, res) {
if (err) {
return console.log(err)
}
done()
})
}
}*/
function done() {
console.log('done!')
}
//
// Trigger Start
//
start()