-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
96 lines (68 loc) · 2.36 KB
/
install.php
File metadata and controls
96 lines (68 loc) · 2.36 KB
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
<?php
/* Fast&dirty installation */
require_once "config/codebasehq.php";
require_once "config/telegram.php";
require_once "config/database.php";
require_once "install/sql_import.php";
function checkConfig() {
function codebasehq() {
if(empty(CODEBASE_API_KEY)
|| empty(CODEBASE_ACCOUNT_NAME)
|| empty(CODEBASE_USER_NAME)
)
throw new Exception("Please configure CodebaseHQ account in config/codebasehq.php");
echo "CodebaseHQ account configured<br/>";
}
function telegram() {
if(empty(TELEGRAM_API_KEY)
|| empty(TELEGRAM_BOT_NAME)
|| empty(TELEGRAM_HOOK_URL) || TELEGRAM_HOOK_URL == "https://{BOT_URL}/hook_telegram.php"
|| empty(TELEGRAM_ADMIN_USERNAME) || TELEGRAM_ADMIN_USERNAME == "@username"
)
throw new Exception("Please configure your Telegram bot in config/telegram.php");
echo "Telegram bot configured<br/>";
}
function database() {
if(empty(DB_HOST)
|| empty(DB_USER)
|| empty(DB_PASSWORD)
|| empty(DB_NAME)
|| empty(DB_PORT)
)
throw new Exception("Please configure database in config/database.php");
echo "Database configured<br/>";
}
codebasehq();
telegram();
database();
}
function deployDatabase() {
$sql_file_name = "2017-02-28.sql";
try {
$dbh = new PDO('mysql:host='.DB_HOST.';port='.DB_PORT.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);
PDODbImporter::importSQL('install/'.$sql_file_name, $dbh);
} catch (PDOException $e) {
print "Error copying database: " . $e->getMessage() . "<br/>";
die();
}
echo "Database (probably) copied<br>";
}
function setupTelegramHook() {
// require "telegram_hook_unset.php";
require "telegram_hook_set.php";
echo "<br>";
}
function fetchCodebaseHQstuff() {
echo "CodebaseHQ stuff loaded: ";
require "codebasehq_update_projects.php";
echo "<br>";
}
echo "<style>pre { display:inline; }</style>";
checkConfig();
deployDatabase();
setupTelegramHook();
fetchCodebaseHQstuff();
echo "<br>You're all set<br>";
echo "Try <pre>/start</pre> your bot!";
echo "<br><br>Also, REMOVE <pre>install.php</pre>, <pre>install/</pre>, optionally <pre>telegram_hook_set.php</pre> & <pre>telegram_hook_unset.php</pre>";
echo "<br>You can add <pre>codebasehq_update_projects.php</pre> to a CRON job to refresh your users subscriptions once in a while";