-
Notifications
You must be signed in to change notification settings - Fork 0
/
runInstallModule.php
53 lines (45 loc) · 1.71 KB
/
runInstallModule.php
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
<?php
/**
* Install script for the module
* @author Alexandre Moittié <contact@alexandre-moittie.com>
* @package bfw-mailer
* @version 1.0
*/
// Get the module path and set the database initscript name
$modulePath = realpath(__DIR__).'/';
$db_initscript = 'bfwmailer_init_db.php';
$process_q_script = 'bfwmailer_process_q.php';
echo "\n".' > Copy script '."\033[0;36m".$process_q_script."\033[0m into /src/cli/";
// We check that our destination file does not exist
if(!file_exists(CLI_DIR.$process_q_script)) {
// We copy our script into our destination path
if(copy($modulePath.$process_q_script, CLI_DIR.$process_q_script)) {
echo "...\033[1;32m Done";
} else {
// Display error in case of symlink fail
echo "...\033[1;31m Fail !";
}
} else {
// Dispay warning if the destination file (link) already exists
echo "...\033[1;33m Already exist.";
}
echo "\033[0m\n";
echo ' > Create symbolic link to '."\033[0;36m".$db_initscript."\033[0m into /src/cli/";
// We check that our destination file does not exist
if(!file_exists(CLI_DIR.$db_initscript)) {
// We create our symbolic link between our destinatation and our source file
if(symlink($modulePath.$db_initscript, CLI_DIR.$db_initscript)) {
echo "...\033[1;32m Done";
} else {
// Display error in case of symlink fail
echo "...\033[1;31m Fail !";
}
} else {
// Dispay warning if the destination file (link) already exists
echo "...\033[1;33m Already exist.";
}
echo "\033[0m\n";
// Execute the cli.php script with our own initscript into parameters
echo ' > Execute script '."\033[0;36m".$db_initscript."\033[0m".' ...'."\n";
echo "\033[0m\n";
require_once($db_initscript);