diff --git a/check_process b/check_process index 3390dad..8de351d 100644 --- a/check_process +++ b/check_process @@ -1,24 +1,40 @@ +# See here for more informations +# https://github.com/YunoHost/package_check#syntax-check_process-file + +# Move this file from check_process.default to check_process when you have filled it. + ;; Test complet - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) - admin="john" (USER) - password="password" (PASSWORD) + is_public=1 (PUBLIC|public=1|private=0) + ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=0 - upgrade=1 - backup_restore=1 - multi_instance=0 - wrong_user=1 - wrong_path=1 - incorrect_path=1 - corrupt_source=0 - fail_download_source=0 - port_already_use=0 - final_path_already_use=0 + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=1 + incorrect_path=1 + port_already_use=1 + change_url=0 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto +# Level 4: + Level 4=0 +# Level 5: + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 +;;; Options +Email= +Notification=none diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..6e02c59 --- /dev/null +++ b/conf/app.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/TryGhost/Ghost/archive/1.24.9.zip +SOURCE_SUM=9560f0f54cbbfd412e6d37245ac82178f704df2707f156012373c60381235a49 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/conf/config.js b/conf/config.js deleted file mode 100644 index 383f5cf..0000000 --- a/conf/config.js +++ /dev/null @@ -1,40 +0,0 @@ -// # Ghost Configuration -// Setup your Ghost install for various environments - -var path = require('path'), - config; - -config = { - production: { - url: 'http://YNH_DOMAINYNH_LOCATION', - - mail: { - transport: 'SMTP', - options : { - host : 'localhost', - port : '25' - } - }, - - database: { - 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()` - host: '0.0.0.0', - // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` - port: '2368' - } - } -}; - -// Export config -module.exports = config; diff --git a/conf/config.production.json b/conf/config.production.json new file mode 100644 index 0000000..1a2d073 --- /dev/null +++ b/conf/config.production.json @@ -0,0 +1,29 @@ +{ + "url": "https://__DOMAIN__/__PATH__", + "server": { + "host": "127.0.0.1", + "port": __PORT__ + }, + "database": { + "client": "mysql", + "connection": { + "host" : "127.0.0.1", + "user" : "__DBNAME__", + "password" : "__DBPWD__", + "database" : "__DBNAME__" + } + }, + "auth": { + "type": "password" + }, + "paths": { + "contentPath": "content/" + }, + "logging": { + "level": "info", + "rotation": { + "enabled": true + }, + "transports": ["file", "stdout"] + } +} diff --git a/conf/init-script b/conf/init-script deleted file mode 100644 index 10fef40..0000000 --- a/conf/init-script +++ /dev/null @@ -1,193 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: ghost -# Required-Start: $network $syslog -# Required-Stop: $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Ghost Blogging Platform -# Description: Ghost: Just a blogging platform -### END INIT INFO - -# Kindly stolen from http://docs.ghost.org/pl/installation/deploy/ - -# Do NOT "set -e" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="Ghost" -NAME=ynh-ghostblog -GHOST_ROOT=YNH_FINALPATH/ghost -GHOST_GROUP=ghostblog -GHOST_USER=ghostblog -DAEMON=/usr/bin/node -DAEMON_ARGS="$GHOST_ROOT/index.js" -PIDFILEDIR=/var/run/yunohost/ghostblog -PIDFILE=$PIDFILEDIR/$NAME.pid -SCRIPTNAME=/etc/init.d/$NAME -LOGFILE="YNH_LOGFILE" -export NODE_ENV=production - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -# Read configuration variable file if it is present -[ -r /etc/default/$NAME ] && . /etc/default/$NAME - -# Load the VERBOSE setting and other rcS variables -. /lib/init/vars.sh -# I like to know what is going on -VERBOSE=yes - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.2-14) to ensure that this file is present -# and status_of_proc is working. -. /lib/lsb/init-functions - -# -# Function that starts the daemon/service -# -do_start() -{ - # Set up folder structure - mkdir -p $PIDFILEDIR - chown -R $GHOST_USER:$GHOST_GROUP $PIDFILEDIR - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - start-stop-daemon --start --quiet \ - --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --background \ - --pidfile $PIDFILE --make-pidfile --exec $DAEMON --test > /dev/null \ - || return 1 - - start-stop-daemon --start --quiet \ - --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --background \ - --pidfile $PIDFILE --make-pidfile --exec /bin/bash -- -c "exec $DAEMON $DAEMON_ARGS >> $LOGFILE 2>&1" \ - || return 2 - # Add code here, if necessary, that waits for the process to be ready - # to handle requests from services started subsequently which depend - # on this one. As a last resort, sleep for some dime. - - ghost_http_request_result=1 - ghost_path=$(yunohost app setting ghostblog path) - count=0 - max_count=60 - while [ "$ghost_http_request_result" != "0" ] - do - [ "$VERBOSE" != no ] && log_action_cont_msg "." - - if [ "$count" -ge $max_count ]; then - [ "$VERBOSE" != no ] && log_action_cont_msg "Timeout" - return 3 - fi - - curl -kL -X GET http://localhost:2368${ghost_path} > /dev/null 2>&1 - ghost_http_request_result=$? - sleep 1 - count=$(expr $count + 1) - done -} - -# -# Function that stops the daemon/service -# -do_stop() -{ - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ - --pidfile $PIDFILE --name $NAME - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/3/KILL/5 \ - --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -# # -# # Function that sends a SIGHUP to the daemon/service -# # -# do_reload() { -# # -# # If the daemon can reload its configuration without -# # restarting (for example, when it is sent a SIGHUP), -# # then implement that here. -# # -# start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE \ -# --name $NAME -# return 0 -# } - -case "$1" in -start) - [ "$VERBOSE" != no ] && log_action_begin_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_action_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_action_end_msg 1 ;; - esac - ;; -stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; -status) - status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? - ;; -#reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; -restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; -*) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -exit 0 - diff --git a/conf/logrotate b/conf/logrotate deleted file mode 100644 index 9dfc1dc..0000000 --- a/conf/logrotate +++ /dev/null @@ -1,10 +0,0 @@ -YNH_LOGFILE -{ - weekly - missingok - rotate 12 - notifempty - compress - delaycompress - copytruncate -} \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 80ec37d..1fc5d84 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,10 @@ -location YNH_LOCATION { +location __PATH__/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; - proxy_pass http://127.0.0.1:2368; + proxy_pass http://127.0.0.1:__PORT__; proxy_redirect off; client_max_body_size 100M; diff --git a/conf/npm-shrinkwrap.json b/conf/npm-shrinkwrap.json deleted file mode 100644 index be59f7d..0000000 --- a/conf/npm-shrinkwrap.json +++ /dev/null @@ -1,1036 +0,0 @@ -{ - "name": "ghost", - "version": "0.4.2", - "dependencies": { - "bcryptjs": { - "version": "0.7.10", - "from": "bcryptjs@0.7.10", - "resolved": "http://registry.npmjs.org/bcryptjs/-/bcryptjs-0.7.10.tgz" - }, - "bookshelf": { - "version": "0.6.1", - "from": "bookshelf@0.6.1", - "resolved": "http://registry.npmjs.org/bookshelf/-/bookshelf-0.6.1.tgz", - "dependencies": { - "backbone": { - "version": "1.1.2", - "from": "backbone@~1.1.0", - "resolved": "http://registry.npmjs.org/backbone/-/backbone-1.1.2.tgz", - "dependencies": { - "underscore": { - "version": "1.6.0", - "from": "underscore@>=1.5.0", - "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" - } - } - }, - "inflection": { - "version": "1.2.7", - "from": "inflection@~1.2.x", - "resolved": "http://registry.npmjs.org/inflection/-/inflection-1.2.7.tgz" - }, - "trigger-then": { - "version": "0.1.1", - "from": "trigger-then@~0.1.1", - "resolved": "http://registry.npmjs.org/trigger-then/-/trigger-then-0.1.1.tgz" - }, - "bluebird": { - "version": "0.10.14-0", - "from": "bluebird@~0.10.5-0", - "resolved": "http://registry.npmjs.org/bluebird/-/bluebird-0.10.14-0.tgz" - }, - "lodash": { - "version": "2.3.0", - "from": "lodash@~2.3.0", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.3.0.tgz" - } - } - }, - "busboy": { - "version": "0.0.12", - "from": "busboy@0.0.12", - "resolved": "http://registry.npmjs.org/busboy/-/busboy-0.0.12.tgz", - "dependencies": { - "dicer": { - "version": "0.1.5", - "from": "dicer@0.1.5", - "resolved": "http://registry.npmjs.org/dicer/-/dicer-0.1.5.tgz", - "dependencies": { - "streamsearch": { - "version": "0.1.2", - "from": "streamsearch@0.1.2", - "resolved": "http://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz" - } - } - }, - "readable-stream": { - "version": "1.1.13-1", - "from": "readable-stream@1.1.x", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13-1.tgz", - "dependencies": { - "core-util-is": { - "version": "1.0.1", - "from": "core-util-is@~1.0.0", - "resolved": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "string_decoder": { - "version": "0.10.25-1", - "from": "string_decoder@~0.10.x", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25-1.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@~2.0.1", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - } - } - }, - "colors": { - "version": "0.6.2", - "from": "colors@0.6.2", - "resolved": "http://registry.npmjs.org/colors/-/colors-0.6.2.tgz" - }, - "connect-slashes": { - "version": "1.2.0", - "from": "connect-slashes@1.2.0", - "resolved": "http://registry.npmjs.org/connect-slashes/-/connect-slashes-1.2.0.tgz" - }, - "downsize": { - "version": "0.0.5", - "from": "downsize@0.0.5", - "resolved": "http://registry.npmjs.org/downsize/-/downsize-0.0.5.tgz", - "dependencies": { - "xregexp": { - "version": "2.0.0", - "from": "xregexp@2.0.0", - "resolved": "http://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz" - } - } - }, - "express": { - "version": "3.4.6", - "from": "express@3.4.6", - "resolved": "http://registry.npmjs.org/express/-/express-3.4.6.tgz", - "dependencies": { - "connect": { - "version": "2.11.2", - "from": "connect@2.11.2", - "resolved": "http://registry.npmjs.org/connect/-/connect-2.11.2.tgz", - "dependencies": { - "qs": { - "version": "0.6.5", - "from": "qs@0.6.5", - "resolved": "http://registry.npmjs.org/qs/-/qs-0.6.5.tgz" - }, - "bytes": { - "version": "0.2.1", - "from": "bytes@0.2.1", - "resolved": "http://registry.npmjs.org/bytes/-/bytes-0.2.1.tgz" - }, - "pause": { - "version": "0.0.1", - "from": "pause@0.0.1", - "resolved": "http://registry.npmjs.org/pause/-/pause-0.0.1.tgz" - }, - "uid2": { - "version": "0.0.3", - "from": "uid2@0.0.3", - "resolved": "http://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz" - }, - "raw-body": { - "version": "1.1.2", - "from": "raw-body@1.1.2", - "resolved": "http://registry.npmjs.org/raw-body/-/raw-body-1.1.2.tgz" - }, - "negotiator": { - "version": "0.3.0", - "from": "negotiator@0.3.0", - "resolved": "http://registry.npmjs.org/negotiator/-/negotiator-0.3.0.tgz" - }, - "multiparty": { - "version": "2.2.0", - "from": "multiparty@2.2.0", - "resolved": "http://registry.npmjs.org/multiparty/-/multiparty-2.2.0.tgz", - "dependencies": { - "readable-stream": { - "version": "1.1.13-1", - "from": "readable-stream@~1.1.9", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13-1.tgz", - "dependencies": { - "core-util-is": { - "version": "1.0.1", - "from": "core-util-is@~1.0.0", - "resolved": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "string_decoder": { - "version": "0.10.25-1", - "from": "string_decoder@~0.10.x", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25-1.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@~2.0.1", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - }, - "stream-counter": { - "version": "0.2.0", - "from": "stream-counter@~0.2.0", - "resolved": "http://registry.npmjs.org/stream-counter/-/stream-counter-0.2.0.tgz" - } - } - } - } - }, - "commander": { - "version": "1.3.2", - "from": "commander@1.3.2", - "resolved": "http://registry.npmjs.org/commander/-/commander-1.3.2.tgz", - "dependencies": { - "keypress": { - "version": "0.1.0", - "from": "keypress@0.1.x", - "resolved": "http://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz" - } - } - }, - "range-parser": { - "version": "0.0.4", - "from": "range-parser@0.0.4", - "resolved": "http://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz" - }, - "mkdirp": { - "version": "0.3.5", - "from": "mkdirp@~0.3.5", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" - }, - "cookie": { - "version": "0.1.0", - "from": "cookie@0.1.0", - "resolved": "http://registry.npmjs.org/cookie/-/cookie-0.1.0.tgz" - }, - "buffer-crc32": { - "version": "0.2.1", - "from": "buffer-crc32@0.2.1", - "resolved": "http://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz" - }, - "fresh": { - "version": "0.2.0", - "from": "fresh@0.2.0", - "resolved": "http://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz" - }, - "methods": { - "version": "0.1.0", - "from": "methods@0.1.0", - "resolved": "http://registry.npmjs.org/methods/-/methods-0.1.0.tgz" - }, - "send": { - "version": "0.1.4", - "from": "send@0.1.4", - "resolved": "http://registry.npmjs.org/send/-/send-0.1.4.tgz", - "dependencies": { - "mime": { - "version": "1.2.11", - "from": "mime@~1.2.9", - "resolved": "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz" - } - } - }, - "cookie-signature": { - "version": "1.0.1", - "from": "cookie-signature@1.0.1", - "resolved": "http://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.1.tgz" - }, - "debug": { - "version": "0.8.1", - "from": "debug@>= 0.7.3 < 1", - "resolved": "http://registry.npmjs.org/debug/-/debug-0.8.1.tgz" - } - } - }, - "express-hbs": { - "version": "0.7.9", - "from": "express-hbs@0.7.9", - "resolved": "http://registry.npmjs.org/express-hbs/-/express-hbs-0.7.9.tgz", - "dependencies": { - "handlebars": { - "version": "1.3.0", - "from": "handlebars@~1.3", - "resolved": "http://registry.npmjs.org/handlebars/-/handlebars-1.3.0.tgz", - "dependencies": { - "optimist": { - "version": "0.3.7", - "from": "optimist@~0.3", - "resolved": "http://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz", - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "from": "wordwrap@~0.0.2", - "resolved": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" - } - } - }, - "uglify-js": { - "version": "2.3.6", - "from": "uglify-js@~2.3", - "resolved": "http://registry.npmjs.org/uglify-js/-/uglify-js-2.3.6.tgz", - "dependencies": { - "async": { - "version": "0.2.10", - "from": "async@~0.2.6", - "resolved": "http://registry.npmjs.org/async/-/async-0.2.10.tgz" - }, - "source-map": { - "version": "0.1.34", - "from": "source-map@~0.1.7", - "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.1.34.tgz", - "dependencies": { - "amdefine": { - "version": "0.1.0", - "from": "amdefine@>=0.0.4", - "resolved": "http://registry.npmjs.org/amdefine/-/amdefine-0.1.0.tgz" - } - } - } - } - } - } - }, - "readdirp": { - "version": "0.3.3", - "from": "readdirp@~0.3.1", - "resolved": "http://registry.npmjs.org/readdirp/-/readdirp-0.3.3.tgz", - "dependencies": { - "graceful-fs": { - "version": "2.0.3", - "from": "graceful-fs@~2.0.0", - "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz" - }, - "minimatch": { - "version": "0.2.14", - "from": "minimatch@~0.2.12", - "resolved": "http://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "dependencies": { - "lru-cache": { - "version": "2.5.0", - "from": "lru-cache@2", - "resolved": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz" - }, - "sigmund": { - "version": "1.0.0", - "from": "sigmund@~1.0.0", - "resolved": "http://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz" - } - } - } - } - }, - "js-beautify": { - "version": "1.4.2", - "from": "js-beautify@~1.4.2", - "resolved": "http://registry.npmjs.org/js-beautify/-/js-beautify-1.4.2.tgz", - "dependencies": { - "config-chain": { - "version": "1.1.8", - "from": "config-chain@~1.1.5", - "resolved": "http://registry.npmjs.org/config-chain/-/config-chain-1.1.8.tgz", - "dependencies": { - "proto-list": { - "version": "1.2.3", - "from": "proto-list@~1.2.1", - "resolved": "http://registry.npmjs.org/proto-list/-/proto-list-1.2.3.tgz" - }, - "ini": { - "version": "1.2.1", - "from": "ini@1", - "resolved": "http://registry.npmjs.org/ini/-/ini-1.2.1.tgz" - } - } - }, - "mkdirp": { - "version": "0.3.5", - "from": "mkdirp@0.3.5", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" - }, - "nopt": { - "version": "2.1.2", - "from": "nopt@~2.1.1", - "resolved": "http://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", - "dependencies": { - "abbrev": { - "version": "1.0.5", - "from": "abbrev@1", - "resolved": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz" - } - } - } - } - } - } - }, - "fs-extra": { - "version": "0.8.1", - "from": "fs-extra@0.8.1", - "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.8.1.tgz", - "dependencies": { - "ncp": { - "version": "0.4.2", - "from": "ncp@~0.4.2", - "resolved": "http://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz" - }, - "mkdirp": { - "version": "0.3.5", - "from": "mkdirp@0.3.x", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" - }, - "jsonfile": { - "version": "1.1.1", - "from": "jsonfile@~1.1.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-1.1.1.tgz" - }, - "rimraf": { - "version": "2.2.8", - "from": "rimraf@~2.2.0", - "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz" - } - } - }, - "knex": { - "version": "0.5.8", - "from": "knex@0.5.8", - "resolved": "http://registry.npmjs.org/knex/-/knex-0.5.8.tgz", - "dependencies": { - "generic-pool-redux": { - "version": "0.1.0", - "from": "generic-pool-redux@~0.1.0", - "resolved": "http://registry.npmjs.org/generic-pool-redux/-/generic-pool-redux-0.1.0.tgz" - }, - "optimist": { - "version": "0.6.1", - "from": "optimist@~0.6.0", - "resolved": "http://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "from": "wordwrap@~0.0.2", - "resolved": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" - }, - "minimist": { - "version": "0.0.10", - "from": "minimist@~0.0.1", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" - } - } - }, - "mkdirp": { - "version": "0.3.5", - "from": "mkdirp@~0.3.5", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" - }, - "bluebird": { - "version": "1.0.8", - "from": "bluebird@~1.0.0", - "resolved": "http://registry.npmjs.org/bluebird/-/bluebird-1.0.8.tgz" - } - } - }, - "lodash": { - "version": "2.4.1", - "from": "lodash@2.4.1", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.1.tgz" - }, - "moment": { - "version": "2.4.0", - "from": "moment@2.4.0", - "resolved": "http://registry.npmjs.org/moment/-/moment-2.4.0.tgz" - }, - "node-polyglot": { - "version": "0.3.0", - "from": "node-polyglot@0.3.0", - "resolved": "http://registry.npmjs.org/node-polyglot/-/node-polyglot-0.3.0.tgz" - }, - "node-uuid": { - "version": "1.4.1", - "from": "node-uuid@1.4.1", - "resolved": "http://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz" - }, - "nodemailer": { - "version": "0.5.13", - "from": "nodemailer@0.5.13", - "resolved": "http://registry.npmjs.org/nodemailer/-/nodemailer-0.5.13.tgz", - "dependencies": { - "mailcomposer": { - "version": "0.2.11", - "from": "mailcomposer@~0.2.5", - "resolved": "http://registry.npmjs.org/mailcomposer/-/mailcomposer-0.2.11.tgz", - "dependencies": { - "mimelib": { - "version": "0.2.16", - "from": "mimelib@~0.2.15", - "resolved": "http://registry.npmjs.org/mimelib/-/mimelib-0.2.16.tgz", - "dependencies": { - "encoding": { - "version": "0.1.8", - "from": "encoding@~0.1.7", - "resolved": "http://registry.npmjs.org/encoding/-/encoding-0.1.8.tgz", - "dependencies": { - "iconv-lite": { - "version": "0.4.3", - "from": "iconv-lite@~0.4.3", - "resolved": "http://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.3.tgz" - } - } - }, - "addressparser": { - "version": "0.2.1", - "from": "addressparser@~0.2.1", - "resolved": "http://registry.npmjs.org/addressparser/-/addressparser-0.2.1.tgz" - } - } - }, - "mime": { - "version": "1.2.11", - "from": "mime@~1.2.11", - "resolved": "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz" - }, - "punycode": { - "version": "1.2.4", - "from": "punycode@~1.2.4", - "resolved": "http://registry.npmjs.org/punycode/-/punycode-1.2.4.tgz" - }, - "follow-redirects": { - "version": "0.0.3", - "from": "follow-redirects@0.0.3", - "resolved": "http://registry.npmjs.org/follow-redirects/-/follow-redirects-0.0.3.tgz", - "dependencies": { - "underscore": { - "version": "1.6.0", - "from": "underscore@", - "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" - } - } - }, - "dkim-signer": { - "version": "0.1.2", - "from": "dkim-signer@~0.1.1", - "resolved": "http://registry.npmjs.org/dkim-signer/-/dkim-signer-0.1.2.tgz" - } - } - }, - "simplesmtp": { - "version": "0.3.32", - "from": "simplesmtp@~0.2 || ~0.3", - "resolved": "http://registry.npmjs.org/simplesmtp/-/simplesmtp-0.3.32.tgz", - "dependencies": { - "rai": { - "version": "0.1.11", - "from": "rai@~0.1.11", - "resolved": "http://registry.npmjs.org/rai/-/rai-0.1.11.tgz" - }, - "xoauth2": { - "version": "0.1.8", - "from": "xoauth2@~0.1.8", - "resolved": "http://registry.npmjs.org/xoauth2/-/xoauth2-0.1.8.tgz" - } - } - }, - "directmail": { - "version": "0.1.8", - "from": "directmail@~0.1.1", - "resolved": "http://registry.npmjs.org/directmail/-/directmail-0.1.8.tgz" - }, - "he": { - "version": "0.3.6", - "from": "he@~0.3.6", - "resolved": "http://registry.npmjs.org/he/-/he-0.3.6.tgz" - }, - "readable-stream": { - "version": "1.0.27-1", - "from": "readable-stream@*", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.27-1.tgz", - "dependencies": { - "core-util-is": { - "version": "1.0.1", - "from": "core-util-is@~1.0.0", - "resolved": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "string_decoder": { - "version": "0.10.25-1", - "from": "string_decoder@~0.10.x", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25-1.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@~2.0.1", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - } - } - }, - "rss": { - "version": "0.2.1", - "from": "rss@0.2.1", - "resolved": "http://registry.npmjs.org/rss/-/rss-0.2.1.tgz", - "dependencies": { - "mime": { - "version": "1.2.11", - "from": "mime@~1.2.11", - "resolved": "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz" - } - } - }, - "semver": { - "version": "2.2.1", - "from": "semver@2.2.1", - "resolved": "http://registry.npmjs.org/semver/-/semver-2.2.1.tgz" - }, - "showdown": { - "version": "0.3.2-ghost", - "from": "https://github.com/ErisDS/showdown/archive/v0.3.2-ghost.tar.gz", - "resolved": "https://github.com/ErisDS/showdown/archive/v0.3.2-ghost.tar.gz" - }, - "sqlite3": { - "version": "2.2.0", - "from": "sqlite3@2.2.0", - "resolved": "http://registry.npmjs.org/sqlite3/-/sqlite3-2.2.0.tgz", - "dependencies": { - "node-pre-gyp": { - "version": "0.2.6", - "from": "node-pre-gyp@~0.2.5", - "resolved": "http://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.2.6.tgz", - "dependencies": { - "nopt": { - "version": "2.1.2", - "from": "nopt@~2.1.2", - "resolved": "http://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", - "dependencies": { - "abbrev": { - "version": "1.0.5", - "from": "abbrev@1", - "resolved": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz" - } - } - }, - "npmlog": { - "version": "0.0.6", - "from": "npmlog@~0.0.6", - "resolved": "http://registry.npmjs.org/npmlog/-/npmlog-0.0.6.tgz", - "dependencies": { - "ansi": { - "version": "0.2.1", - "from": "ansi@~0.2.1", - "resolved": "http://registry.npmjs.org/ansi/-/ansi-0.2.1.tgz" - } - } - }, - "request": { - "version": "2.36.0", - "from": "request@2", - "resolved": "http://registry.npmjs.org/request/-/request-2.36.0.tgz", - "dependencies": { - "qs": { - "version": "0.6.6", - "from": "qs@~0.6.0", - "resolved": "http://registry.npmjs.org/qs/-/qs-0.6.6.tgz" - }, - "json-stringify-safe": { - "version": "5.0.0", - "from": "json-stringify-safe@~5.0.0", - "resolved": "http://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.0.tgz" - }, - "mime": { - "version": "1.2.11", - "from": "mime@~1.2.9", - "resolved": "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz" - }, - "forever-agent": { - "version": "0.5.2", - "from": "forever-agent@~0.5.0", - "resolved": "http://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz" - }, - "tough-cookie": { - "version": "0.12.1", - "from": "tough-cookie@>=0.12.0", - "resolved": "http://registry.npmjs.org/tough-cookie/-/tough-cookie-0.12.1.tgz", - "dependencies": { - "punycode": { - "version": "1.2.4", - "from": "punycode@>=0.2.0", - "resolved": "http://registry.npmjs.org/punycode/-/punycode-1.2.4.tgz" - } - } - }, - "form-data": { - "version": "0.1.4", - "from": "form-data@~0.1.0", - "resolved": "http://registry.npmjs.org/form-data/-/form-data-0.1.4.tgz", - "dependencies": { - "combined-stream": { - "version": "0.0.5", - "from": "combined-stream@~0.0.4", - "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-0.0.5.tgz", - "dependencies": { - "delayed-stream": { - "version": "0.0.5", - "from": "delayed-stream@0.0.5", - "resolved": "http://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" - } - } - }, - "async": { - "version": "0.9.0", - "from": "async@~0.9.0", - "resolved": "http://registry.npmjs.org/async/-/async-0.9.0.tgz" - } - } - }, - "tunnel-agent": { - "version": "0.4.0", - "from": "tunnel-agent@~0.4.0", - "resolved": "http://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.0.tgz" - }, - "http-signature": { - "version": "0.10.0", - "from": "http-signature@~0.10.0", - "resolved": "http://registry.npmjs.org/http-signature/-/http-signature-0.10.0.tgz", - "dependencies": { - "assert-plus": { - "version": "0.1.2", - "from": "assert-plus@0.1.2", - "resolved": "http://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz" - }, - "asn1": { - "version": "0.1.11", - "from": "asn1@0.1.11", - "resolved": "http://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz" - }, - "ctype": { - "version": "0.5.2", - "from": "ctype@0.5.2", - "resolved": "http://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz" - } - } - }, - "oauth-sign": { - "version": "0.3.0", - "from": "oauth-sign@~0.3.0", - "resolved": "http://registry.npmjs.org/oauth-sign/-/oauth-sign-0.3.0.tgz" - }, - "hawk": { - "version": "1.0.0", - "from": "hawk@~1.0.0", - "resolved": "http://registry.npmjs.org/hawk/-/hawk-1.0.0.tgz", - "dependencies": { - "hoek": { - "version": "0.9.1", - "from": "hoek@0.9.x", - "resolved": "http://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz" - }, - "boom": { - "version": "0.4.2", - "from": "boom@0.4.x", - "resolved": "http://registry.npmjs.org/boom/-/boom-0.4.2.tgz" - }, - "cryptiles": { - "version": "0.2.2", - "from": "cryptiles@0.2.x", - "resolved": "http://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz" - }, - "sntp": { - "version": "0.2.4", - "from": "sntp@0.2.x", - "resolved": "http://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz" - } - } - }, - "aws-sign2": { - "version": "0.5.0", - "from": "aws-sign2@~0.5.0", - "resolved": "http://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz" - } - } - }, - "semver": { - "version": "2.1.0", - "from": "semver@~2.1.0", - "resolved": "http://registry.npmjs.org/semver/-/semver-2.1.0.tgz" - }, - "tar": { - "version": "0.1.20", - "from": "tar@~0.1.19", - "resolved": "http://registry.npmjs.org/tar/-/tar-0.1.20.tgz", - "dependencies": { - "block-stream": { - "version": "0.0.7", - "from": "block-stream@*", - "resolved": "http://registry.npmjs.org/block-stream/-/block-stream-0.0.7.tgz" - }, - "fstream": { - "version": "0.1.28", - "from": "fstream@~0.1.28", - "resolved": "http://registry.npmjs.org/fstream/-/fstream-0.1.28.tgz", - "dependencies": { - "graceful-fs": { - "version": "3.0.2", - "from": "graceful-fs@~3.0.2", - "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.2.tgz" - } - } - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@2", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - }, - "tar-pack": { - "version": "2.0.0", - "from": "tar-pack@~2.0.0", - "resolved": "http://registry.npmjs.org/tar-pack/-/tar-pack-2.0.0.tgz", - "dependencies": { - "uid-number": { - "version": "0.0.3", - "from": "uid-number@0.0.3", - "resolved": "http://registry.npmjs.org/uid-number/-/uid-number-0.0.3.tgz" - }, - "once": { - "version": "1.1.1", - "from": "once@~1.1.1", - "resolved": "http://registry.npmjs.org/once/-/once-1.1.1.tgz" - }, - "debug": { - "version": "0.7.4", - "from": "debug@~0.7.2", - "resolved": "http://registry.npmjs.org/debug/-/debug-0.7.4.tgz" - }, - "fstream": { - "version": "0.1.28", - "from": "fstream@~0.1.28", - "resolved": "http://registry.npmjs.org/fstream/-/fstream-0.1.28.tgz", - "dependencies": { - "graceful-fs": { - "version": "3.0.2", - "from": "graceful-fs@~3.0.2", - "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.2.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@~2.0.0", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - }, - "fstream-ignore": { - "version": "0.0.7", - "from": "fstream-ignore@0.0.7", - "resolved": "http://registry.npmjs.org/fstream-ignore/-/fstream-ignore-0.0.7.tgz", - "dependencies": { - "minimatch": { - "version": "0.2.14", - "from": "minimatch@~0.2.0", - "resolved": "http://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "dependencies": { - "lru-cache": { - "version": "2.5.0", - "from": "lru-cache@2", - "resolved": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz" - }, - "sigmund": { - "version": "1.0.0", - "from": "sigmund@~1.0.0", - "resolved": "http://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz" - } - } - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@2", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - }, - "readable-stream": { - "version": "1.0.27-1", - "from": "readable-stream@~1.0.2", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.27-1.tgz", - "dependencies": { - "core-util-is": { - "version": "1.0.1", - "from": "core-util-is@~1.0.0", - "resolved": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "string_decoder": { - "version": "0.10.25-1", - "from": "string_decoder@~0.10.x", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25-1.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@~2.0.1", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - }, - "graceful-fs": { - "version": "1.2.3", - "from": "graceful-fs@1.2", - "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz" - } - } - }, - "mkdirp": { - "version": "0.3.5", - "from": "mkdirp@~0.3.5", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" - }, - "aws-sdk": { - "version": "2.0.4", - "from": "aws-sdk@~2.0.0-rc6", - "resolved": "http://registry.npmjs.org/aws-sdk/-/aws-sdk-2.0.4.tgz", - "dependencies": { - "aws-sdk-apis": { - "version": "3.0.6", - "from": "aws-sdk-apis@3.x", - "resolved": "http://registry.npmjs.org/aws-sdk-apis/-/aws-sdk-apis-3.0.6.tgz" - }, - "xml2js": { - "version": "0.2.6", - "from": "xml2js@0.2.6", - "resolved": "http://registry.npmjs.org/xml2js/-/xml2js-0.2.6.tgz", - "dependencies": { - "sax": { - "version": "0.4.2", - "from": "sax@0.4.2", - "resolved": "http://registry.npmjs.org/sax/-/sax-0.4.2.tgz" - } - } - }, - "xmlbuilder": { - "version": "0.4.2", - "from": "xmlbuilder@0.4.2", - "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.2.tgz" - } - } - }, - "rc": { - "version": "0.3.5", - "from": "rc@~0.3.2", - "resolved": "http://registry.npmjs.org/rc/-/rc-0.3.5.tgz", - "dependencies": { - "minimist": { - "version": "0.0.10", - "from": "minimist@~0.0.7", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" - }, - "deep-extend": { - "version": "0.2.10", - "from": "deep-extend@~0.2.5", - "resolved": "http://registry.npmjs.org/deep-extend/-/deep-extend-0.2.10.tgz" - }, - "ini": { - "version": "1.1.0", - "from": "ini@~1.1.0", - "resolved": "http://registry.npmjs.org/ini/-/ini-1.1.0.tgz" - } - } - }, - "rimraf": { - "version": "2.2.8", - "from": "rimraf@~2.2.5", - "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz" - } - } - } - } - }, - "unidecode": { - "version": "0.1.3", - "from": "unidecode@0.1.3", - "resolved": "http://registry.npmjs.org/unidecode/-/unidecode-0.1.3.tgz" - }, - "validator": { - "version": "3.4.0", - "from": "validator@3.4.0", - "resolved": "http://registry.npmjs.org/validator/-/validator-3.4.0.tgz" - }, - "when": { - "version": "2.7.0", - "from": "when@2.7.0", - "resolved": "http://registry.npmjs.org/when/-/when-2.7.0.tgz" - }, - "xml": { - "version": "0.0.12", - "from": "xml@0.0.12", - "resolved": "http://registry.npmjs.org/xml/-/xml-0.0.12.tgz" - }, - "mysql": { - "version": "2.1.1", - "from": "mysql@2.1.1", - "resolved": "http://registry.npmjs.org/mysql/-/mysql-2.1.1.tgz", - "dependencies": { - "require-all": { - "version": "0.0.3", - "from": "require-all@0.0.3", - "resolved": "http://registry.npmjs.org/require-all/-/require-all-0.0.3.tgz" - }, - "bignumber.js": { - "version": "1.0.1", - "from": "bignumber.js@1.0.1", - "resolved": "http://registry.npmjs.org/bignumber.js/-/bignumber.js-1.0.1.tgz" - }, - "readable-stream": { - "version": "1.1.13-1", - "from": "readable-stream@~1.1.9", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13-1.tgz", - "dependencies": { - "core-util-is": { - "version": "1.0.1", - "from": "core-util-is@~1.0.0", - "resolved": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "string_decoder": { - "version": "0.10.25-1", - "from": "string_decoder@~0.10.x", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25-1.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@~2.0.1", - "resolved": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - } - } - } - } -} diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..5f61256 --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,15 @@ +[Unit] +Description=__APP__ systemd service +Documentation=https://docs.ghost.org + +[Service] +Type=simple +WorkingDirectory=__FINALPATH__ +User=__APP__ +Group=__APP__ +Environment="NODE_ENV=production" +ExecStart=/usr/bin/node index.js run +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/conf/user_getmail.py b/conf/user_getmail.py deleted file mode 100644 index fb7d13b..0000000 --- a/conf/user_getmail.py +++ /dev/null @@ -1,4 +0,0 @@ -import sys, json -for i in json.loads(sys.stdin.readlines()[0])["users"]: - if i["username"] == sys.argv[1]: - print i["mail"] diff --git a/conf/user_getname.py b/conf/user_getname.py deleted file mode 100644 index 2f59f76..0000000 --- a/conf/user_getname.py +++ /dev/null @@ -1,4 +0,0 @@ -import sys, json -for i in json.loads(sys.stdin.readlines()[0])["users"]: - if i["username"] == sys.argv[1]: - print i["fullname"] diff --git a/conf/user_list.py b/conf/user_list.py deleted file mode 100644 index 52994aa..0000000 --- a/conf/user_list.py +++ /dev/null @@ -1,3 +0,0 @@ -import sys, json -userlist=json.loads(sys.stdin.readlines()[0])["Users"] -print "{0}".format("\n".join(i["Username"] for i in userlist)) diff --git a/manifest.json b/manifest.json index bdde6f7..9a8c2b7 100644 --- a/manifest.json +++ b/manifest.json @@ -1,16 +1,27 @@ { "name": "Ghost", - "id": "ghostblog", + "id": "ghost", + "packaging_format": 1, "description": { "en": "Just a blogging platform", "fr": "Plateforme de blogging" }, + "version": "1.0", + "url": "https://ghost.org/", + "license": "free", "developer": { "name": "Julien Malik", - "email": "julien.malik@paraiso.me", - "url": "https://ghost.org/" + "email": "julien.malik@paraiso.me" }, - "multi_instance": "false", + "requirements": { + "yunohost": ">= 2.7.2" + }, + "multi_instance": true, + "services": [ + "nginx", + "nodjs", + "mysql" + ], "arguments": { "install" : [ { @@ -31,19 +42,13 @@ "default": "/blog" }, { - "name": "admin", + "name": "is_public", + "type": "boolean", "ask": { - "en": "Admin user (must be an existing Yunohost user login)", - "fr": "Administrateur du site (doit être un utilisateur Yunohost existant)" + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" }, - "default": "homer" - }, - { - "name": "password", - "ask": { - "en": "Admin user password (8 characters minimum)", - "fr": "Mot de passe de l'administrateur (8 caractères minimum)" - } + "default": true } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..bb04a03 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# ============= FUTURE YUNOHOST HELPER ============= +# Delete a file checksum from the app settings +# +# $app should be defined when calling this helper +# +# usage: ynh_remove_file_checksum file +# | arg: file - The file for which the checksum will be deleted +ynh_delete_file_checksum () { + local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' + ynh_app_setting_delete $app $checksum_setting_name +} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup new file mode 100755 index 0000000..b245aba --- /dev/null +++ b/scripts/backup @@ -0,0 +1,58 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup "$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + + +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= + +ynh_mysql_dump_db "$db_name" > db.sql + +#================================================= +# SPECIFIC BACKUP +#================================================= + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup "/etc/systemd/system/$app.service" diff --git a/scripts/install b/scripts/install index ed76872..4dbafd7 100644 --- a/scripts/install +++ b/scripts/install @@ -1,136 +1,201 @@ #!/bin/bash -# Retrieve arguments -domain=$1 -path=$2 -admin=$3 -password=$4 +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# '/ghost' is refused by the application itself. This is used as the route to the admin section -if [[ "$path" = "/ghost" ]]; then - echo "Error : the path cannot be '/ghost', please choose another location" - exit 1 +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC + +# This is a multi-instance app, meaning it can be installed several times independently +# The id of the app as stated in the manifest is available as $YNH_APP_ID +# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) +# The app instance name is available as $YNH_APP_INSTANCE_NAME +# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample +# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 +# - ynhexample__{N} for the subsequent installations, with N=3,4, ... +# The app instance name is probably what you are interested the most, since this is +# guaranteed to be unique. This is a good unique identifier to define installation path, +# db names, ... +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= + +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" + +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register $app $domain $path_url + +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= + +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path_url +ynh_app_setting_set $app is_public $is_public + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= + +# Find a free port +port=$(ynh_find_port 4010) +# Open this port +yunohost firewall allow --no-upnp TCP $port 2>&1 +ynh_app_setting_set $app port $port + +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +# install nodejs +ynh_install_nodejs 8 + +# add yarn repo for Debian +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +ynh_package_update + +ynh_install_app_dependencies mailutils yarn + + +#================================================= +# CREATE A MYSQL DATABASE +#================================================= +# If your app uses a MySQL database, you can use these lines to bootstrap +# a database, an associated user and save the password in app settings + +db_name=$(ynh_sanitize_dbid $app) +ynh_app_setting_set $app db_name $db_name +ynh_mysql_setup_db $db_name $db_name + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Create a dedicated nginx config +ynh_add_nginx_config +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" +fi +ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# CREATE DEDICATED USER +#================================================= + +# Create a system user +ynh_system_user_create $app + +#================================================= +# SPECIFIC SETUP +#================================================= + +# Copy configuration file +cp ../conf/config.production.json "$final_path/config.production.json" + +# Install the dependencies with yarn +( + cd "$final_path" + yarn install + yarn global add knex-migrator + + +) + +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/config.production.json" +ynh_replace_string "__PATH__" "path_url" "$final_path/config.production.json" +ynh_replace_string "__DBNAME__" "$db_name" "$final_path/config.production.json" +ynh_replace_string "__DBPWD__" "$db_pwd" "$final_path/config.production.json" +ynh_replace_string "__PORT__" "$port" "$final_path/config.production.json" + +# Create tables in database +( + cd "$final_path" +NODE_ENV=production knex-migrator init + +) + +#================================================= +# STORE THE CHECKSUM OF THE CONFIG FILE +#================================================= + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/config.production.json" + +#================================================= +# SET WRITE PERMISSION +#================================================= + +# Set right permissions for curl install +chown -R $app: $final_path + +#================================================= +# SETUP SYSTEMD +#================================================= + +# Create a dedicated systemd config +ynh_add_systemd_config +systemctl start "$app" + +#================================================= +# SETUP SSOWAT +#================================================= + +if [ $is_public -eq 0 ] +then # Remove the public access + ynh_app_setting_delete $app skipped_uris +fi +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" fi -# Check that admin user is an existing account -sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" -if [[ ! $? -eq 0 ]]; then - echo "Error : the chosen admin user does not exist" - exit 1 -fi +#================================================= +# RELOAD NGINX +#================================================= -# 'password' must be >= 8 characters -if [[ $(expr length $password) -lt "8" ]]; then - echo "Error : the password must be >= 8 characters" - exit 1 -fi +systemctl reload nginx -# Check domain/path availability -sudo yunohost app checkurl $domain$path -a ghostblog -if [[ ! $? -eq 0 ]]; then - exit 1 -fi -echo "Install dependencies..." -sudo apt-get update -sudo apt-get install nodejs-legacy npm -y - -version=0.5.1 -echo "Downloading Ghost $version..." -mkdir ../tmp -sudo wget -O ../tmp/ghost-$version.zip "https://en.ghost.org/zip/ghost-$version.zip" - -echo "Deploying source files..." -unzip ../tmp/ghost-$version.zip -d ../tmp/ghost -final_path=/var/www/ghostblog -sudo mkdir -p $final_path -sudo useradd -d $final_path ghostblog -sudo cp -r ../tmp/ghost $final_path -#sudo cp ../conf/npm-shrinkwrap.json $final_path/ghost -sudo chown -R ghostblog: $final_path - -echo "Installing Ghost with NPM..." -#sudo su --shell /bin/bash --command "cd $final_path/ghost && npm install --production --registry http://registry.npmjs.eu" ghostblog -sudo su --shell /bin/bash --command "cd $final_path/ghost && npm install --production --registry http://registry.npmjs.org" ghostblog - -echo "Cleaning up install tree..." -sudo rm -rf $final_path/.npm -find $final_path -type d | grep "test$" | xargs sudo rm -rf -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 "Patching sources to remove calls to googleapis..." -# patches to core -sudo cp $final_path/ghost/core/server/views/user-error.hbs $final_path/ghost/core/server/views/user-error.hbs.orig -sudo cp $final_path/ghost/core/server/views/default.hbs $final_path/ghost/core/server/views/default.hbs.orig -sudo cp $final_path/ghost/core/client/assets/css/fonts.css $final_path/ghost/core/client/assets/css/fonts.css.orig -sudo sed -i '/googleapis/c\ ' $final_path/ghost/core/server/views/user-error.hbs -sudo sed -i '/googleapis/c\ ' $final_path/ghost/core/server/views/default.hbs -sudo cp ../patches/core/fonts.css $final_path/ghost/core/client/assets/css -sudo cp ../patches/core/*.woff $final_path/ghost/core/client/assets/fonts -# patches to casper theme -sudo cp $final_path/ghost/content/themes/casper/default.hbs $final_path/ghost/content/themes/casper/default.hbs.orig -sudo cp $final_path/ghost/content/themes/casper/assets/css/fonts.css $final_path/ghost/content/themes/casper/assets/css/fonts.css.orig -sudo sed -i '/googleapis/c\ ' $final_path/ghost/content/themes/casper/default.hbs -sudo cp ../patches/theme/fonts.css $final_path/ghost/content/themes/casper/assets/css -sudo cp ../patches/theme/*.woff $final_path/ghost/content/themes/casper/assets/fonts - -echo "Setting up permissions" -sudo chown -R ghostblog: $final_path/ghost - -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_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 - -echo "Setting up init script..." -logfile=/var/log/ynh-ghostblog.log -sudo touch $logfile -sudo chown ghostblog: $logfile -sed -i "s@YNH_FINALPATH@$final_path@g" ../conf/init-script -sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/init-script -sudo cp ../conf/init-script /etc/init.d/ynh-ghostblog -sudo chmod +x /etc/init.d/ynh-ghostblog -sudo update-rc.d ynh-ghostblog defaults -sudo service ynh-ghostblog start -sudo yunohost service add ynh-ghostblog -l $logfile - -echo "Setting up logrotate configuration..." -sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate -sudo cp ../conf/logrotate /etc/logrotate.d/ynh-ghostblog - -echo "Nginx configuration (sso disabled)..." -sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ghostblog.conf -sudo yunohost app setting ghostblog skipped_uris -v "/" - -echo "Reloading Nginx (sso disabled)..." -sudo service nginx reload -sudo yunohost app ssowatconf - -echo "Registering admin..." -admin_name=$(sudo yunohost user list --json | python ../conf/user_getname.py $admin) -admin_mail=$(sudo yunohost user list --json | python ../conf/user_getmail.py $admin) -curl -kL -X POST http://localhost:2368${path%/}/ghost/api/v0.1/authentication/setup/ \ - --data-urlencode "setup[0][name]=$admin_name" \ - --data-urlencode "setup[0][email]=$admin_mail" \ - --data-urlencode "setup[0][password]=$password" \ - --data-urlencode "setup[0][blogTitle]=My Yunohost blog" - -sudo yunohost app setting ghostblog admin -v $admin -sudo yunohost app setting ghostblog password -v $password - -echo "Success ! You can go to https://$domain$path/ghost to write your posts" diff --git a/scripts/remove b/scripts/remove index c2faa4f..21a5b29 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,21 +1,89 @@ #!/bin/bash -domain=$(sudo yunohost app setting ghostblog domain) +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -sudo service ynh-ghostblog stop -sudo update-rc.d ynh-ghostblog remove -sudo rm /etc/init.d/ynh-ghostblog -sudo yunohost service remove ynh-ghostblog -sudo rm -f /etc/nginx/conf.d/$domain.d/ghostblog.conf -sudo rm -f /var/log/ynh-ghostblog.log* -sudo rm -rf /var/run/yunohost/ghostblog -sudo rm -f /etc/logrotate.d/ynh-ghostblog +source _common.sh +source /usr/share/yunohost/helpers -db_user=ghostblog -db_name=ghostblog -root_pwd=$(sudo cat /etc/yunohost/mysql) +#================================================= +# LOAD SETTINGS +#================================================= -mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) +port=$(ynh_app_setting_get $app port) +db_name=$(ynh_app_setting_get $app db_name) +db_user=$db_name +final_path=$(ynh_app_setting_get $app final_path) + +#================================================= +# STANDARD REMOVE +#================================================= +# STOP AND REMOVE SERVICE +#================================================= + +# Remove the dedicated systemd config +ynh_remove_systemd_config + +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +if yunohost service status | grep -q $app +then + echo "Remove $app service" + yunohost service remove $app +fi + +#================================================= +# REMOVE DEPENDENCIES +#================================================= + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# REMOVE THE MYSQL DATABASE +#================================================= + +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db $db_user $db_name + +#================================================= +# REMOVE APP MAIN DIR +#================================================= + +# Remove the app directory securely +ynh_secure_remove "$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + echo "Close port $port" + yunohost firewall disallow TCP $port 2>&1 +fi + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= + +# Delete a system user +ynh_system_user_delete $app -# remove user so that it does not hold resource -sudo userdel --remove ghostblog diff --git a/scripts/restore b/scripts/restore new file mode 100755 index 0000000..99a778a --- /dev/null +++ b/scripts/restore @@ -0,0 +1,111 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) +port=$(ynh_app_setting_get "$app" port) + + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= + +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" + +# Open this port +yunohost firewall allow Both "$port" 2>&1 + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= + +db_pwd=$(ynh_app_setting_get $app mysqlpwd) +ynh_mysql_setup_db $db_name $db_name $db_pwd +ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= + +# Create the dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app: $final_path + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= + +# install nodejs +ynh_install_nodejs 8 + +# add yarn repo for Debian +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +ynh_package_update + +ynh_install_app_dependencies mailutils yarn + + +#================================================= +# RESTORE SYSTEMD +#================================================= + +ynh_restore_file "/etc/systemd/system/$app.service" +systemctl enable $app.service +systemctl start "$app" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= + +systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index 01c11ca..114fb37 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,95 +1,178 @@ #!/bin/bash -# Retrieve arguments -domain=$(sudo yunohost app setting ghostblog domain) -path=$(sudo yunohost app setting ghostblog path) -path=${path%/} -admin=$(sudo yunohost app setting ghostblog admin) -password=$(sudo yunohost app setting ghostblog password) +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -sudo service ynh-ghostblog stop +source _common.sh +source /usr/share/yunohost/helpers -final_path=/var/www/ghostblog +#================================================= +# LOAD SETTINGS +#================================================= -version=0.5.1 -echo "Downloading Ghost $version..." -mkdir ../tmp -sudo wget -O ../tmp/ghost-$version.zip "https://en.ghost.org/zip/ghost-$version.zip" -unzip ../tmp/ghost-$version.zip -d ../tmp/ghost +app=$YNH_APP_INSTANCE_NAME -echo "Saving content folder..." -sudo cp -ar $final_path/ghost/content ../tmp +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) +final_path=$(ynh_app_setting_get $app final_path) +port=$(ynh_app_setting_get $app port) +db_name=$(ynh_app_setting_get $app db_name) -echo "Deploying source files..." -sudo rm -rf $final_path/ghost -sudo cp -r ../tmp/ghost $final_path -sudo cp -ar ../tmp/content $final_path/ghost -#sudo cp ../conf/npm-shrinkwrap.json $final_path/ghost -sudo chown -R ghostblog: $final_path +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= -echo "Installing Ghost with NPM..." -#sudo su --shell /bin/bash --command "cd $final_path/ghost && npm install --production --registry http://registry.npmjs.eu" ghostblog -sudo su --shell /bin/bash --command "cd $final_path/ghost && npm install --production --registry http://registry.npmjs.org" ghostblog +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set $app is_public 1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set $app is_public 0 + is_public=0 +fi -echo "Cleaning up install tree..." -sudo rm -rf $final_path/.npm -find $final_path -type d | grep "test$" | xargs sudo rm -rf -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 +# If db_name doesn't exist, create it +if [ -z $db_name ]; then + db_name=$(ynh_sanitize_dbid $app) + ynh_app_setting_set $app db_name $db_name +fi -echo "Patching sources to remove calls to googleapis..." -# patches to core -sudo cp $final_path/ghost/core/server/views/user-error.hbs $final_path/ghost/core/server/views/user-error.hbs.orig -sudo cp $final_path/ghost/core/server/views/default.hbs $final_path/ghost/core/server/views/default.hbs.orig -sudo cp $final_path/ghost/core/client/assets/css/fonts.css $final_path/ghost/core/client/assets/css/fonts.css.orig -sudo sed -i '/googleapis/c\ ' $final_path/ghost/core/server/views/user-error.hbs -sudo sed -i '/googleapis/c\ ' $final_path/ghost/core/server/views/default.hbs -sudo cp ../patches/core/fonts.css $final_path/ghost/core/client/assets/css -sudo cp ../patches/core/*.woff $final_path/ghost/core/client/assets/fonts +# If final_path doesn't exist, create it +if [ -z $final_path ]; then + final_path=/var/www/$app + ynh_app_setting_set $app final_path $final_path +fi -echo "Setting up permissions" -sudo chown -R ghostblog: $final_path/ghost +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= -echo "Setting up database..." -db_name=ghostblog -db_user=ghostblog -db_pwd=$(sudo yunohost app setting ghostblog mysqlpwd) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -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_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 +#================================================= +# CHECK THE PATH +#================================================= -echo "Setting up init script..." -logfile=/var/log/ynh-ghostblog.log -sudo touch $logfile -sudo chown ghostblog: $logfile +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path $path_url) -sed -i "s@YNH_FINALPATH@$final_path@g" ../conf/init-script -sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/init-script -sudo cp ../conf/init-script /etc/init.d/ynh-ghostblog -sudo chmod +x /etc/init.d/ynh-ghostblog -sudo update-rc.d ynh-ghostblog defaults -sudo service ynh-ghostblog start -sudo yunohost service add ynh-ghostblog -l $logfile +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= -echo "Setting up logrotate configuration..." -sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate -sudo cp ../conf/logrotate /etc/logrotate.d/ynh-ghostblog +# Create a temporary directory +tmpdir="$(mktemp -d)" +# Backup the content folder to the temp dir +cp -ar "$final_path/ghost/content" "$tmpdir" -echo "Nginx configuration (sso disabled)..." -sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ghostblog.conf -sudo yunohost app setting ghostblog skipped_uris -v "/" +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" -echo "Reloading Nginx (sso disabled)..." -sudo service nginx reload -sudo yunohost app ssowatconf +# copy content folder back to the final_path +sudo cp -ar "$tmpdir/content" "${final_path}" -echo "Success ! You can go to https://$domain$path/ghost to write your posts" +#================================================= +# SPECIFIC SETUP +#================================================= + +# Copy configuration file +cp ../conf/config.production.json "$final_path/config.production.json" + +# Install the dependencies with yarn +( + cd "$final_path" + yarn install + yarn global add knex-migrator + + +) + +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/config.production.json" +ynh_replace_string "__PATH__" "path_url" "$final_path/config.production.json" +ynh_replace_string "__DBNAME__" "$db_name" "$final_path/config.production.json" +ynh_replace_string "__DBPWD__" "$db_pwd" "$final_path/config.production.json" +ynh_replace_string "__PORT__" "$port" "$final_path/config.production.json" + + +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Create a dedicated nginx config +ynh_add_nginx_config +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" +fi +ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# CREATE DEDICATED USER +#================================================= + +# Create a system user +ynh_system_user_create $app + +#================================================= +# SPECIFIC UPGRADE +#================================================= + +# Verify the checksum and backup the file if it's different +ynh_backup_if_checksum_is_different "$final_path/config.production.json" +# Recalculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/config.production.json" + +#================================================= +# SETUP SYSTEMD +#================================================= + +# Create a dedicated systemd config +ynh_add_systemd_config +systemctl start "$app" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set right permissions for curl installation +chown -R $app: $final_path + +#================================================= +# SETUP SSOWAT +#================================================= + +if [ $is_public -eq 0 ] +then # Remove the public access + ynh_app_setting_delete $app skipped_uris +fi +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set $app unprotected_uris "/" +fi + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx