diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-21 14:45:39 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-21 14:45:39 +0100 |
commit | 19875ef0dad9999f91e6f8d780756e402b5e6722 (patch) | |
tree | 169b887df1bf71f7ceb0be54447b11be8765e431 /bin | |
parent | 00fcfd299b7a1aa5177c97d2b13c0d9d587678e5 (diff) | |
download | wallabag-19875ef0dad9999f91e6f8d780756e402b5e6722.tar.gz wallabag-19875ef0dad9999f91e6f8d780756e402b5e6722.tar.zst wallabag-19875ef0dad9999f91e6f8d780756e402b5e6722.zip |
add install script after composer install
Diffstat (limited to 'bin')
-rwxr-xr-x[-rw-r--r--] | bin/install | 68 | ||||
-rwxr-xr-x | bin/update | 4 |
2 files changed, 72 insertions, 0 deletions
diff --git a/bin/install b/bin/install index e69de29b..ad991409 100644..100755 --- a/bin/install +++ b/bin/install | |||
@@ -0,0 +1,68 @@ | |||
1 | #!/usr/bin/php | ||
2 | <?php | ||
3 | |||
4 | echo 'Okay, you want to install wallabag, let\'s go!'; | ||
5 | echo "\r\n"; | ||
6 | |||
7 | function generateSalt() { | ||
8 | mt_srand(microtime(true)*100000 + memory_get_usage(true)); | ||
9 | return md5(uniqid(mt_rand(), true)); | ||
10 | } | ||
11 | |||
12 | function 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 = 'app/db/poche.sqlite'; | ||
27 | $username = 'wallabag'; | ||
28 | $password = 'wallabag'; | ||
29 | $salt = generateSalt(); | ||
30 | $defaultLanguage = 'en_EN.UTF8'; | ||
31 | |||
32 | if (!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); | ||
38 | file_put_contents($configFile, $content); | ||
39 | |||
40 | if (!copy('bin/poche.sqlite', $dbFile)) { | ||
41 | die('Impossible to create ' . $dbFile . ' file.'); | ||
42 | } | ||
43 | |||
44 | chmod($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 | |||
68 | echo 'wallabag is now installed'; | ||
diff --git a/bin/update b/bin/update new file mode 100755 index 00000000..fa579762 --- /dev/null +++ b/bin/update | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | set -e | ||
3 | |||
4 | # What can we do when we update vendor? \ No newline at end of file | ||