1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ghost_ynh.git synced 2024-09-03 19:16:02 +02:00

Update to v5.8.3 and use new install format

Ghost has significantly changed their file structure, which means
the scripts had to be changed around quite a bit as well. We are
also using the readymade `yarn setup` tool to set up the Ghost
installation instead of manually running each command. Significant
changes are:

  - Config and content now lives under ./ghost/core instead of
    being directly in the project root. While updating, for
    backward compatibility, we're checking for the existence
    of the old folder as well
  - The admin interface is bundled along with the main Ghost
    package, so there is no need to download it separately
    (Casper is still being downloaded separately though)
  - We are using `yarn start` instead of knex, grunt, etc.
    (`yarn start` automatically calls those commands for us
    behind the scenes)
  - Similarly, we are now running `yarn start` to execute the
    Ghost process in the systemd config, instead of manually
    running `index.js` as we were doing earlier.

Fresh installs work well on this commit, though upgrades are yet
to be tested!
This commit is contained in:
Badri 2022-08-11 10:03:06 +05:30
parent 5018d5c13c
commit 61616f907d
6 changed files with 40 additions and 38 deletions

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://api.github.com/repos/TryGhost/Ghost/zipball/v5.2.4
SOURCE_SUM=04ba64fd6f7ecb0ba0970eb63189b5b5780095260bce5d4edd2b50e25d0a316b
SOURCE_URL=https://api.github.com/repos/TryGhost/Ghost/zipball/v5.8.3
SOURCE_SUM=557c39864483fff00beeb60e27d84915e184845c69db3be83dcd7a65f327d497
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/TryGhost/Casper/archive/refs/tags/v5.1.5.zip
SOURCE_SUM=ad883bf9e3ded051b21e4f2473cbcf32bdacdd8258f29bc45c4fdc0e3fc3e57f
SOURCE_URL=https://github.com/TryGhost/Casper/archive/refs/tags/v5.2.3.zip
SOURCE_SUM=49d57ce078a2775f39d019ed74fa4ae9476e95fa35b02593c726c0ea25fe49df
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -9,7 +9,8 @@ Group=__APP__
WorkingDirectory=__FINALPATH__
Environment="__YNH_NODE_LOAD_PATH__"
Environment="NODE_ENV=production"
ExecStart=__YNH_NODE__ index.js run
#ExecStart=__YNH_NODE__ core/index.js run
ExecStart=yarn start
Restart=always
# Sandboxing options to harden security

View file

@ -124,9 +124,9 @@ fi
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json"
chmod 400 "$final_path/config.production.json"
chown $app:$app "$final_path/config.production.json"
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/ghost/core/config.production.json"
chmod 400 "$final_path/ghost/core/config.production.json"
chown $app:$app "$final_path/ghost/core/config.production.json"
#=================================================
# GENERIC FINALISATION

View file

@ -99,13 +99,9 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
# Download, check integrity, uncompress and patch the source from admin.src
mkdir -p $final_path/core/client/Admin
ynh_setup_source --dest_dir="$final_path/core/admin" --source_id="admin"
# Download, check integrity, uncompress and patch the source from casper.src
mkdir -p $final_path/content/themes/casper
ynh_setup_source --dest_dir="$final_path/content/themes/casper" --source_id="casper"
mkdir -p $final_path/ghost/core/content/themes/casper
ynh_setup_source --dest_dir="$final_path/ghost/core/content/themes/casper" --source_id="casper"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
@ -126,9 +122,9 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json"
chmod 400 "$final_path/config.production.json"
chown $app:$app "$final_path/config.production.json"
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/ghost/core/config.production.json"
chmod 400 "$final_path/ghost/core/config.production.json"
chown $app:$app "$final_path/ghost/core/config.production.json"
#==============================================
# BUILD GHOST
@ -137,11 +133,8 @@ ynh_script_progression --message="Building Ghost... (this will take some time an
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --non-interactive
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn add knex-migrator
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/knex-migrator init
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt symlink
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt init --force
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn add knex-migrator ember-cli --dev --ignore-workspace-root-check --non-interactive
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn setup # catch-all command provided by Ghost that handles all the setup
popd
#=================================================

View file

@ -92,10 +92,24 @@ then
tmpdir="$(mktemp -d)"
# Copy the admin saved settings from final path to tmp directory
cp -ar "$final_path/config.production.json" "$tmpdir/config.production.json"
if [ -d "$final_path/config.production.json" ]
then
# Old versions of Ghost store it here
cp -ar "$final_path/config.production.json" "$tmpdir/config.production.json"
else
# New versions of Ghost store it here
cp -ar "$final_path/ghost/core/config.production.json" "$tmpdir/config.production.json"
fi
# Backup the content folder to the temp dir
cp -ar "$final_path/content" "$tmpdir/content"
if [ -d "$final_path/config.production.json" ]
then
# Old versions of Ghost store it here
cp -ar "$final_path/content" "$tmpdir/content"
else
# New versions of Ghost store it here
cp -ar "$final_path/ghost/core/content" "$tmpdir/content"
fi
# Remove the app directory securely
ynh_secure_remove --file=$final_path
@ -103,19 +117,15 @@ then
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path
# Download, check integrity, uncompress and patch the source from admin.src
mkdir -p $final_path/core/client/Admin
ynh_setup_source --dest_dir="$final_path/core/admin" --source_id="admin"
# Download, check integrity, uncompress and patch the source from casper.src
mkdir -p $final_path/content/themes/casper
ynh_setup_source --dest_dir="$final_path/content/themes/casper" --source_id="casper"
ynh_setup_source --dest_dir="$final_path/ghost/core/content/themes/casper" --source_id="casper"
# Copy the admin saved settings from tmp directory to final path
cp -ar "$tmpdir/config.production.json" "$final_path/config.production.json"
cp -ar "$tmpdir/config.production.json" "$final_path/ghost/core/config.production.json"
# Copy content folder back to the final_path
cp -ar "$tmpdir/content" "${final_path}"
cp -ar "$tmpdir/content" "${final_path}/ghost/core"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
@ -153,9 +163,9 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json"
chmod 400 "$final_path/config.production.json"
chown $app:$app "$final_path/config.production.json"
ynh_add_config --template="../conf/config.production.json" --destination="$final_path/ghost/core/config.production.json"
chmod 400 "$final_path/ghost/core/config.production.json"
chown $app:$app "$final_path/ghost/core/config.production.json"
#==============================================
# BUILD GHOST
@ -167,10 +177,8 @@ then
pushd "$final_path"
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --non-interactive
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn add knex-migrator
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/knex-migrator init
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt symlink
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt init --force
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn add knex-migrator ember-cli --dev --ignore-workspace-root-check --non-interactive
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn setup
popd
fi