From 9d01f8de5f65d0bd2ccbe6c68d90b86b47fb19fb Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Fri, 21 Mar 2014 18:15:13 +0100 Subject: [PATCH] first implem mysql --- TODO.org | 10 ++++++++-- conf/config.js | 20 +++++++++++++++----- scripts/install | 10 ++++++++++ scripts/remove | 6 ++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/TODO.org b/TODO.org index 3025fb7..b386127 100644 --- a/TODO.org +++ b/TODO.org @@ -3,7 +3,8 @@ * DONE logs * DONE logrotate config * DONE is_public -* TODO auto set up admin section +* BLOCKED auto set up admin section +** curl call seems ok but I get a 403 (XSRF ?) * DONE mail in config.js : what's this ? ** mails are working ** http://docs.ghost.org/usage/configuration/ @@ -35,5 +36,10 @@ admin@yunohost:/home/yunohost.app/ghostblog$ du -sh ghost/* * DONE change pid file path ** let's stay with /var/run/yunohost/ghostblog for the moment * DONE cleanup pid file -* TODO change theme police to avoid google requests +* TODO download theme police, install locally to avoid google requests +** download theme police +//fonts.googleapis.com/css?family=Noto+Serif:400,700,400italic|Open+Sans:700,400" +** install locally in themes/casper/assets/fonts ? +** modify assets/css ? +** modify default.hbs * TODO check password length (>=8) diff --git a/conf/config.js b/conf/config.js index 11bad1c..f7ca6cf 100644 --- a/conf/config.js +++ b/conf/config.js @@ -8,12 +8,22 @@ config = { production: { url: 'http://YNH_DOMAINYNH_LOCATION', mail: {YNH_MAIL}, +// database: { +// client: 'sqlite3', +// connection: { +// filename: path.join(__dirname, '/content/data/ghost.db') +// }, +// debug: false +// }, database: { - client: 'sqlite3', - connection: { - filename: path.join(__dirname, '/content/data/ghost.db') - }, - debug: false + client: 'mysql', + connection: { + host : 'localhost', + user : 'YNH_DBUSER', + password : 'YNH_DBPWD', + database : 'YNH_DBNAME', + charset : 'utf8' + } }, server: { // Host to be passed to node's `net.Server#listen()` diff --git a/scripts/install b/scripts/install index 7c981f6..0dee75a 100644 --- a/scripts/install +++ b/scripts/install @@ -37,10 +37,20 @@ find $final_path -type d | grep "tests$" | xargs sudo rm -rf sudo rm -rf $final_path/ghost/node_modules/sqlite3/build sudo rm -rf $final_path/tmp +echo "Setting up database..." +db_name=ghostblog +db_user=ghostblog +db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') +sudo yunohost app initdb $db_user -d $db_name -p $db_pwd +sudo yunohost app setting ghostblog mysqlpwd -v $db_pwd + echo "Deploying configuration..." sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.js sed -i "s@YNH_LOCATION@$path@g" ../conf/config.js sed -i "s@YNH_MAIL@@g" ../conf/config.js +sed -i "s@YNH_DBNAME@$db_name@g" ../conf/config.js +sed -i "s@YNH_DBUSER@$db_user@g" ../conf/config.js +sed -i "s@YNH_DBPWD@$db_pwd@g" ../conf/config.js sudo cp ../conf/config.js $final_path/ghost sudo chown ghostblog: $final_path/ghost/config.js sudo chmod 644 $final_path/ghost/config.js diff --git a/scripts/remove b/scripts/remove index f8e53ae..46d2910 100644 --- a/scripts/remove +++ b/scripts/remove @@ -11,5 +11,11 @@ sudo rm -f /var/log/ghostblog.log sudo rm -rf /var/run/yunohost/ghostblog sudo rm -f /etc/logrotate.d/ynh-ghostblog +db_user=ghostblog +db_name=ghostblog +root_pwd=$(sudo cat /etc/yunohost/mysql) + +mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" + # remove user so that it does not hold resource sudo userdel --remove ghostblog