aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/install
diff options
context:
space:
mode:
Diffstat (limited to 'bin/install')
-rwxr-xr-xbin/install72
1 files changed, 0 insertions, 72 deletions
diff --git a/bin/install b/bin/install
deleted file mode 100755
index ed2c2d91..00000000
--- a/bin/install
+++ /dev/null
@@ -1,72 +0,0 @@
1#!/usr/bin/php
2<?php
3require_once __DIR__. '/../vendor/autoload.php';
4
5use Symfony\Component\Yaml\Yaml;
6
7$parameters = Yaml::parse(file_get_contents('app/config/parameters.yml'));
8
9echo 'Okay, you want to install wallabag, let\'s go!';
10echo "\r\n";
11
12function executeQuery($handle, $sql, $params) {
13 try
14 {
15 $query = $handle->prepare($sql);
16 $query->execute($params);
17 return $query->fetchAll();
18 }
19 catch (Exception $e)
20 {
21 return false;
22 }
23}
24
25$configFile = 'app/config/config.inc.php';
26$dbFile = 'data/db/poche.sqlite';
27$username = 'wallabag';
28$password = 'wallabag';
29$salt = $parameters['parameters']['secret'];
30$defaultLanguage = 'en_EN.UTF8';
31
32if (!copy('app/config/config.inc.default.php', $configFile)) {
33 die('Installation aborted, impossible to create ' . $configFile . ' file. Maybe you don\'t have write access to create it.');
34}
35
36$content = file_get_contents($configFile);
37$content = str_replace("define ('SALT', '');", "define ('SALT', '".$salt."');", $content);
38file_put_contents($configFile, $content);
39
40if (!copy('bin/poche.sqlite', $dbFile)) {
41 die('Impossible to create ' . $dbFile . ' file.');
42}
43
44chmod($dbFile, 0777);
45
46$dbPath = 'sqlite:' . realpath('') . '/' . $dbFile;
47
48$handle = new PDO($dbPath);
49
50$handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
51
52$saltedPassword = sha1($password . $username . $salt);
53
54$sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')";
55$params = array($username, $saltedPassword, $username);
56$query = executeQuery($handle, $sql, $params);
57
58$idUser = (int)$handle->lastInsertId('users_id_seq');
59
60$sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
61$params = array($idUser, 'pager', '10');
62$query = executeQuery($handle, $sql, $params);
63
64$sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
65$params = array($idUser, 'language', $defaultLanguage);
66$query = executeQuery($handle, $sql, $params);
67
68echo 'wallabag is now installed';
69echo "\r\n";
70echo 'Just execute `php app/console server:run` for using wallabag:';
71echo "\r\n";
72echo 'http://localhost:8000'; \ No newline at end of file