-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·65 lines (58 loc) · 2 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
#!/usr/bin/env php
<?php
$configfile = 'config.inc.php';
if (!file_exists(__DIR__ . '/' . $configfile)) {
echo 'Please configure the application. Copy the sample file and modify it:' . "\n";
echo 'cp ' . $configfile . '.sample ' . $configfile . "\n";
exit(1);
}
define('ROOT', dirname(__FILE__));
define('LIBS', ROOT . '/libs');
require_once LIBS . '/Db.php';
$db=new StdClass();
require_once __DIR__ . '/config.inc.php';
/*
try {
$db = new Db($db);
} catch(Exception $e) {
echo _('Cannot connect to the database:') . ' ' . $e->getMessage() . "\n";
$msg = $e->getMessage();
if ($msg == "could not find driver" && $db->type == 'sqlite') {
echo _("Please install PHP sqlite module:") . "\n";
echo 'apt-get install php5-sqlite' . "\n";
}
exit(2);
}
echo "Installing a new database.";
$sql_file = file_get_contents(ROOT.'/db/dump.sql');
$sql_queries = explode(';', $sql_file);
foreach ($sql_queries as $sql) {
$sql = trim($sql);
$db->q($sql);
}
echo ".. done\n";
*/
if (!file_exists(__DIR__ . '/tmp')) {
mkdir(__DIR__ . '/tmp');
chmod(__DIR__ . '/tmp',755);
}
if (!is_dir(STORAGE_PATH."/original")) mkdir(STORAGE_PATH."/original");
if (!is_dir(STORAGE_PATH."/transcoded")) mkdir(STORAGE_PATH."/transcoded");
if (!is_file("/etc/debian_version")) {
echo "Now copy the init/* files into /etc/init.d/ and do the appropriate sysV or other daemon boot launcher. (warning, they are from Debian, they may not work on your system)";
} else {
$services=array("omk-api","omk-cron","omk-downloader","omk-metadata","omk-transcoder");
foreach($services as $service) {
echo "Installing $service daemon.";
$src=file_get_contents("init/$service");
$src=str_replace("OMKROOT=/var/www/omk","OMKROOT=".ROOT,$src);
file_put_contents("/etc/init.d/$service",$src);
chmod("/etc/init.d/$service",0755);
exec("update-rc.d $service defaults");
exec("invoke-rc.d $service restart");
echo ".. done\n"; flush();
}
}
if (is_dir("/etc/cron.d")) {
copy("crontab","/etc/cron.d/omk-server");
}