Uberspace / lab

The Uberlab provides various tutorials - written by you! - on how to run software and tools on Uberspace 7.
https://lab.uberspace.de
Other
315 stars 416 forks source link

[ghost] Update Script is not working without `browser_download_url` #1243

Closed remarcable closed 2 years ago

remarcable commented 2 years ago

The following line in the update script is not working anymore:

CURRENT_GHOST_DOWNLOAD=$(curl -s https://api.github.com/repos/TryGhost/Ghost/releases/latest | grep browser_download_url | cut -d '"' -f 4)

browser_download_url doesn't exist in the API response of https://api.github.com/repos/TryGhost/Ghost/releases/latest. It looks like GitHub changed their API response, and zipball_url might be a suitable replacement. Downloading this file reveals, though, that the repository is now nested inside another folder with a dynamically generated name.

I didn't have the time yet to fix the update script, but wanted to make you aware of the problem. Thank you!

EV21 commented 2 years ago

It looks like GitHub changed their API response

It looks like the developers have not yet added any pre-build assets to the latest release, so of cause the API can not retrieve something from an empty asset[] like the browser_download_url.

and zipball_url might be a suitable replacement.

The lab guide says at some point:

Make sure not to use the source code zip.

Maybe there will be an asset next week or you may change some steps. - I don't use ghost, I was just interested in that API, so someone else have to fix that.

Never release on fridays!

remarcable commented 2 years ago

Thank you very much!

EV21 commented 2 years ago

Hey, it looks like they did this on purpose. https://github.com/TryGhost/action-ghost-release/commit/b76068939e38c399b24bbd1b50c55d30ddce9807

You may re-open this issue until it is clear how to proceed.

Have you tried updating the officially documented way? https://ghost.org/docs/update/

cd ~/ghost
npm install -g ghost-cli@latest
ghost update

Maybe we don't need that update script.

EV21 commented 2 years ago

@MaluNoPeleke As the original author you may have a look at this? Your script is also not working with this issue https://github.com/MaluNoPeleke/Ghost4Uberspace/blob/master/ghostupgrade.sh

MaluNoPeleke commented 2 years ago

Sorry, but as I don't use Ghost anymore (I switched to Kirby) I also don't update the script. The last version should be this one: https://www.peleke.de/de/blog/ghost-4-uberspace-aktualisieren

noave commented 2 years ago

unfortunately the cli command ghost update uses sudo, just to stop/start the systemd service it expects, so it cannot be used here without further patching

MaluNoPeleke commented 2 years ago

Is the local option of any use? "Service options" https://ghost.org/docs/ghost-cli/#:~:text=transport)%0A%2D%2Dmailport%20465-,Service%20options,-%23%20Process%20manager%20to

SalocinHB commented 2 years ago

Is the local option of any use? "Service options" https://ghost.org/docs/ghost-cli/#:~:text=transport)%0A%2D%2Dmailport%20465-,Service%20options,-%23%20Process%20manager%20to

No, unfortunately not, it still expects to be able to talk to systemd using sudo. These options appear to be ignored by ghost update, which is consistent with the documentation:

All of these options can also be passed to ghost install and ghost setup, as these commands call ghost config.

[testnico@fairydust ghost]$ ghost update --process local
┌──────────────────────────────────────────────────────────────────────────────────┐
│Warning: MySQL 8 will be the required database in the next major release of Ghost.│
│     Make sure your database is up to date to ensure forwards compatibility.      │
└──────────────────────────────────────────────────────────────────────────────────┘

Love open source? We’re hiring Node.js Engineers to work on Ghost full-time.
https://careers.ghost.org/product-engineer-node-js

+ sudo systemctl is-active ghost_testnico-uber-space
? Sudo Password [input is hidden]

I have modified the update script to download and extract the source tarball instead, but then it breaks because the source tarball doesn't include the default theme (the folder is empty). Maybe someone else would like to play with this?

#!/bin/bash
#set -v
#created by peleke.de
GHOSTDIR=~/ghost
PACKAGE_VERSION_OLD=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' $GHOSTDIR/current/package.json)
CURRENT_GHOST=$(curl -s https://api.github.com/repos/TryGhost/Ghost/releases | grep tag_name | head -n 1 | cut -d '"' -f 4)
CURRENT_GHOST_DOWNLOAD=$(curl -s https://api.github.com/repos/TryGhost/Ghost/releases/latest | grep tarball_url | cut -d '"' -f 4)
CURRENT_GHOST_FILE="$(echo $CURRENT_GHOST_DOWNLOAD | sed 's:.*/::').tar.gz"
echo "installed version: $PACKAGE_VERSION_OLD"
echo "available version: $CURRENT_GHOST"
cd $GHOSTDIR
if [[ $CURRENT_GHOST != $PACKAGE_VERSION_OLD ]]
then
  read -r -p "Do you want to update Ghost $PACKAGE_VERSION_OLD to version $CURRENT_GHOST? [Y/n] " response
  if [[ $response =~ ^([yY]|"")$ ]]
  then
    echo "downloading and unpacking ghost $CURRENT_GHOST ..."
    cd $GHOSTDIR/versions/
    curl -Lk $CURRENT_GHOST_DOWNLOAD -o $CURRENT_GHOST_FILE
    mkdir -p $GHOSTDIR/versions/$CURRENT_GHOST
    tar xf $GHOSTDIR/versions/$CURRENT_GHOST_FILE -C $GHOSTDIR/versions/$CURRENT_GHOST --strip-components=1
    rm $GHOSTDIR/versions/$CURRENT_GHOST_FILE
    echo "Updating ghost ..."
    cd $GHOSTDIR/versions/$CURRENT_GHOST
    yarn install --production
    echo "Migrating ghost database ..."
    cd $GHOSTDIR
    NODE_ENV=production knex-migrator migrate --mgpath $GHOSTDIR/versions/$CURRENT_GHOST
    ln -sfn $GHOSTDIR/versions/$CURRENT_GHOST $GHOSTDIR/current
    PACKAGE_VERSION=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' $GHOSTDIR/current/package.json)
    echo "Ghost $PACKAGE_VERSION_OLD has been updated to version $PACKAGE_VERSION"
    echo "Restarting Ghost. This may take a few seconds ..."
    supervisorctl restart ghost
    supervisorctl status
    echo "If something seems wrong, please check the logs: 'supervisorctl tail ghost'"
    echo "To revert to version $PACKAGE_VERSION_OLD run the following command: 'ln -sfn $GHOSTDIR/versions/$PACKAGE_VERSION_OLD $GHOSTDIR/current' and restart ghost using 'supervisorctl restart ghost'."
  fi
else
  echo "-> Ghost is already up-to-date, no update needed."
fi
SalocinHB commented 2 years ago

Oh, I just realised my mistake. ghost config --process local ; ghost update ; supervisorctl restart ghost seems to work.

remarcable commented 2 years ago

Hello, I tried to update my ghost instance and ran into an error. To me, this also happens when freshly installing ghost:

(following the guide):

uberspace tools version use node 16
npm i -g ghost-cli knex-migrator yarn # uninstalled them before
ghost install --no-stack --no-setup-linux-user --no-setup-systemd --no-setup-nginx --no-setup-mysql --no-start --no-enable

node ./current/index.js

produces this error:

[2022-05-01 09:54:20] INFO Ghost is running in development...
[2022-05-01 09:54:20] INFO Listening on: 127.0.0.1:2368
[2022-05-01 09:54:20] INFO Url configured as: http://localhost:2368/
[2022-05-01 09:54:20] INFO Ctrl+C to shut down
[2022-05-01 09:54:20] INFO Ghost server started in 0.731s
Knex: run
$ npm install sqlite3 --save
/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/mrc/ghost/versions/4.46.0/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node)
Error: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/mrc/ghost/versions/4.46.0/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1187:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    ...
[2022-05-01 09:54:21] ERROR Knex: run
$ npm install sqlite3 --save
/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/mrc/ghost/versions/4.46.0/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node)

Knex: run
$ npm install sqlite3 --save
/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/mrc/ghost/versions/4.46.0/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node)

Error ID:
    ac72a680-c934-11ec-a4b3-45bd60abff71

[2022-05-01 09:54:21] WARN Ghost is shutting down
[2022-05-01 09:54:21] WARN Ghost has shut down
[2022-05-01 09:54:21] WARN Ghost was running for a few seconds

I found an old issue (https://github.com/TryGhost/Ghost-CLI/issues/281) that described a similar error and tried to use their fix (uninstalling ghost-cli and then reinstalling it) but it didn't work.

This exact behavior also happened for updating ghost using the new steps in the guide. Running node current/index.js produced the same error.

Currently, ghost doesn't work for me at all. Did someone else encounter this error as well and fixed it?

remarcable commented 2 years ago

I was able to find a solution to the problem described above:

- node ./current/index.js
+ NODE_ENV=production /bin/node current/index.js

It seemed like sqlite3 was loaded by default when NODE_ENV is not production, which failed with the error above.

The upgrade still isn't working for me, but relief is in sight. Because of a bug in knex and MariaDB, the database migrations are currently not working. Everything will hopefully work again from Ghost 5.1.0 :)