From 19875ef0dad9999f91e6f8d780756e402b5e6722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 21 Jan 2015 14:45:39 +0100 Subject: add install script after composer install --- bin/install | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/update | 4 ++++ 2 files changed, 72 insertions(+) mode change 100644 => 100755 bin/install create mode 100755 bin/update (limited to 'bin') diff --git a/bin/install b/bin/install old mode 100644 new mode 100755 index e69de29b..ad991409 --- a/bin/install +++ b/bin/install @@ -0,0 +1,68 @@ +#!/usr/bin/php +prepare($sql); + $query->execute($params); + return $query->fetchAll(); + } + catch (Exception $e) + { + return false; + } +} + +$configFile = 'app/config/config.inc.php'; +$dbFile = 'app/db/poche.sqlite'; +$username = 'wallabag'; +$password = 'wallabag'; +$salt = generateSalt(); +$defaultLanguage = 'en_EN.UTF8'; + +if (!copy('app/config/config.inc.default.php', $configFile)) { + die('Installation aborted, impossible to create ' . $configFile . ' file. Maybe you don\'t have write access to create it.'); +} + +$content = file_get_contents($configFile); +$content = str_replace("define ('SALT', '');", "define ('SALT', '".$salt."');", $content); +file_put_contents($configFile, $content); + +if (!copy('bin/poche.sqlite', $dbFile)) { + die('Impossible to create ' . $dbFile . ' file.'); +} + +chmod($dbFile, 0777); + +$dbPath = 'sqlite:' . realpath('') . '/' . $dbFile; + +$handle = new PDO($dbPath); + +$handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$saltedPassword = sha1($password . $username . $salt); + +$sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')"; +$params = array($username, $saltedPassword, $username); +$query = executeQuery($handle, $sql, $params); + +$idUser = (int)$handle->lastInsertId('users_id_seq'); + +$sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; +$params = array($idUser, 'pager', '10'); +$query = executeQuery($handle, $sql, $params); + +$sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; +$params = array($idUser, 'language', $defaultLanguage); +$query = executeQuery($handle, $sql, $params); + +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 @@ +#!/bin/sh +set -e + +# What can we do when we update vendor? \ No newline at end of file -- cgit v1.2.3