mirror of
https://github.com/YunoHost-Apps/ghost_ynh.git
synced 2024-09-03 19:16:02 +02:00
Merge pull request #228 from YunoHost-Apps/fix
Packaging v2 and stop the install from source madness
This commit is contained in:
commit
01d5ebd928
23 changed files with 185 additions and 950 deletions
95
.github/workflows/updater.sh
vendored
95
.github/workflows/updater.sh
vendored
|
@ -16,22 +16,11 @@
|
|||
# Fetching information
|
||||
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
||||
|
||||
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
|
||||
current_version=$(tomlq -t -s --indent 4 -r '.version|split("~")[0]' manifest.toml)
|
||||
|
||||
# CORE
|
||||
# repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
|
||||
repo="TryGhost/Ghost"
|
||||
repo=$(tomlq -r '.upstream.code|split("https://github.com/")[1]' manifest.toml)
|
||||
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
||||
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").zipball_url ] | join(" ") | @sh' | tr -d "'"))
|
||||
|
||||
# ADMIN
|
||||
admin_repo="TryGhost/Admin"
|
||||
assets+=("https://github.com/$admin_repo/archive/refs/tags/${version}.zip")
|
||||
|
||||
# THEME
|
||||
theme_repo="TryGhost/Casper"
|
||||
theme_version=$(curl --silent "https://api.github.com/repos/$theme_repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
||||
assets+=("https://github.com/$theme_repo/archive/refs/tags/${theme_version}.zip")
|
||||
|
||||
# Later down the script, we assume the version has only digits and dots
|
||||
# Sometimes the release name starts with a "v", so let's filter it out.
|
||||
|
@ -57,90 +46,12 @@ elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
|
||||
echo "${#assets[@]} available asset(s)"
|
||||
|
||||
#=================================================
|
||||
# UPDATE SOURCE FILES
|
||||
#=================================================
|
||||
|
||||
# Here we use the $assets variable to get the resources published in the upstream release.
|
||||
|
||||
count=0
|
||||
|
||||
# Let's loop over the array of assets URLs
|
||||
for asset_url in ${assets[@]}; do
|
||||
|
||||
echo "Handling asset at $asset_url"
|
||||
|
||||
# Assign the asset to a source file in conf/ directory
|
||||
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
|
||||
# Leave $src empty to ignore the asset
|
||||
case $asset_url in
|
||||
*"/Ghost/"*)
|
||||
src="app"
|
||||
;;
|
||||
*"/Admin/"*)
|
||||
src="admin"
|
||||
;;
|
||||
*"/Casper/"*)
|
||||
src="casper"
|
||||
;;
|
||||
*)
|
||||
src=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# If $src is not empty, let's process the asset
|
||||
if [ ! -z "$src" ]; then
|
||||
|
||||
# Create the temporary directory
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
# Download sources and calculate checksum
|
||||
filename=${asset_url##*/}
|
||||
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
|
||||
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
|
||||
|
||||
# Delete temporary directory
|
||||
rm -rf $tempdir
|
||||
|
||||
# Rewrite source file
|
||||
cat <<EOT > conf/$src.src
|
||||
SOURCE_URL=$asset_url
|
||||
SOURCE_SUM=$checksum
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
||||
EOT
|
||||
echo "... conf/$src.src updated"
|
||||
|
||||
count=$((count+1))
|
||||
|
||||
else
|
||||
echo "... asset ignored"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [ $count -lt 2 ]; then
|
||||
echo "::warning ::Some assets were not processed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPDATE STEPS
|
||||
#=================================================
|
||||
|
||||
# Any action on the app's source code can be done.
|
||||
# The GitHub Action workflow takes care of committing all changes after this script ends.
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Replace new version in manifest
|
||||
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
|
||||
echo "$(tomlq -t -r ".version = \"${version}~ynh1\"" manifest.toml)" > manifest.toml
|
||||
|
||||
# No need to update the README, yunohost-bot takes care of it
|
||||
|
||||
|
|
29
README.md
29
README.md
|
@ -16,7 +16,10 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
|||
|
||||
## Overview
|
||||
|
||||
Publishing, memberships, subscriptions and newsletters platform
|
||||
Ghost is a powerful app for new-media creators to publish, share, and grow a business around their content.
|
||||
|
||||
It comes with modern tools to build a website, publish content, send newsletters & offer paid subscriptions to members.
|
||||
|
||||
|
||||
**Shipped version:** 5.44.0~ynh1
|
||||
|
||||
|
@ -24,30 +27,6 @@ Publishing, memberships, subscriptions and newsletters platform
|
|||
|
||||

|
||||
|
||||
## Disclaimers / important information
|
||||
|
||||
## Installation
|
||||
|
||||
1. No LDAP support.
|
||||
1. You need more than **1GB** of ram. If you don't have it, please create a **swap memory**.
|
||||
|
||||
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
1. This app is multi-instance (you can have more than one Ghost blogging websites on a single YunoHost server)
|
||||
|
||||
### Installing the Ghost app
|
||||
|
||||
0. Note - When making the install public, your Ghost domain link must be accessed WHILE NOT signed into your YunoHost session. It is recommended to use a incognito mode to sign into your Ghost admin account. If you make your install public, and try to login your Ghost admin account while signed into your YunoHost session, you will get a an authorized header error. The reason for this is because Ghost has a feature that allows for a subscription based access for content. This means Ghost allows for the admin user to setup other users (either other staff or paid/unpaid subscribers) to have the abilility to login outside of YunoHost.
|
||||
|
||||
1. **App can be installed by YunoHost admin interface or by the following command:**
|
||||
|
||||
`sudo yunohost app install https://github.com/YunoHost-Apps/ghost_ynh`
|
||||
|
||||
2. After installation create an **admin account** by visiting `https://domain.tld/ghost/ghost`. If you choose to name your Ghost instance "blog" during YunoHost setup process, then it would be `https://domain.tld/blog/ghost`. This will allow you to continue to setup your admin account and configure your settings.
|
||||
|
||||
## :red_circle: Antifeatures
|
||||
|
||||
- **Arbitrary limitations**: Features arbitrary limitations. Please refer to the README.
|
||||
|
|
28
README_fr.md
28
README_fr.md
|
@ -16,7 +16,10 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
|
|||
|
||||
## Vue d’ensemble
|
||||
|
||||
Plateforme d'édition, d'adhésions, d'abonnements et de newsletters
|
||||
Ghost is a powerful app for new-media creators to publish, share, and grow a business around their content.
|
||||
|
||||
It comes with modern tools to build a website, publish content, send newsletters & offer paid subscriptions to members.
|
||||
|
||||
|
||||
**Version incluse :** 5.44.0~ynh1
|
||||
|
||||
|
@ -24,29 +27,6 @@ Plateforme d'édition, d'adhésions, d'abonnements et de newsletters
|
|||
|
||||

|
||||
|
||||
## Avertissements / informations importantes
|
||||
|
||||
## Installation
|
||||
|
||||
1. Pas de prise en charge LDAP.
|
||||
1. Vous avez besoin de plus de **1 Go** de RAM. Si vous ne l'avez pas, veuillez créer une **mémoire d'échange**.
|
||||
|
||||
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
|
||||
mkswap /fichier d'échange
|
||||
swapon / fichier d'échange
|
||||
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
1. Cette application est multi-instance (vous pouvez avoir plusieurs sites Web de blogs Ghost sur un seul serveur YunoHost)
|
||||
|
||||
### Installation de l'application Ghost
|
||||
|
||||
0. Remarque - Lorsque vous rendez l'installation publique, vous devez accéder à votre lien de domaine Ghost SANS vous connecter à votre session YunoHost. Il est recommandé d'utiliser un mode incognito pour vous connecter à votre compte administrateur Ghost. Si vous rendez votre installation publique et essayez de vous connecter à votre compte administrateur Ghost tout en étant connecté à votre session YunoHost, vous obtiendrez une erreur d'en-tête autorisée. La raison en est que Ghost a une fonctionnalité qui permet un accès au contenu basé sur un abonnement. Cela signifie que Ghost permet à l'utilisateur administrateur de configurer d'autres utilisateurs (soit d'autres membres du personnel, soit des abonnés payés/non payés) pour avoir la possibilité de se connecter en dehors de YunoHost.
|
||||
|
||||
1. ** L'application peut être installée par l'interface d'administration YunoHost ou par la commande suivante : **
|
||||
|
||||
`sudo yunohost installer l'application https://github.com/YunoHost-Apps/ghost_ynh`
|
||||
|
||||
2. Après l'installation, créez un **compte administrateur** en visitant `https://domain.tld/ghost/ghost`. Si vous choisissez de nommer votre instance Ghost "blog" pendant le processus d'installation de YunoHost, alors ce sera "https://domain.tld/blog/ghost". Cela vous permettra de continuer à configurer votre compte administrateur et à configurer vos paramètres.
|
||||
## :red_circle: Fonctions indésirables
|
||||
|
||||
- **Arbitrary limitations**: Features arbitrary limitations. Please refer to the README.
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
is_public=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
# 4.9.4
|
||||
upgrade=1 from_commit=7a150ab29ee969f72dd7846539ae12ac1975165b
|
||||
# 4.17.1, disabled due to failing in v4.3
|
||||
# upgrade=1 from_commit=09f260c04435df35edca042486b6a8eb3160333b
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
change_url=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=7a150ab29ee969f72dd7846539ae12ac1975165b
|
||||
name=4.9.4
|
||||
; commit=09f260c04435df35edca042486b6a8eb3160333b
|
||||
name=4.17.1
|
|
@ -1,5 +0,0 @@
|
|||
SOURCE_URL=https://github.com/TryGhost/Admin/archive/refs/tags/v5.44.0.zip
|
||||
SOURCE_SUM=d5558cd419c8d46bdc958064cb97f963d1ea793866414c025906ec15033512ed
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,5 +0,0 @@
|
|||
SOURCE_URL=https://api.github.com/repos/TryGhost/Ghost/zipball/v5.44.0
|
||||
SOURCE_SUM=496639db3ca7c19a8baa78e282e1753a97eac0d0045b852375178b31895c6b86
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,5 +0,0 @@
|
|||
SOURCE_URL=https://github.com/TryGhost/Casper/archive/refs/tags/v5.4.9.zip
|
||||
SOURCE_SUM=0ff2112375d84a1c80e1cbb80f2b55d91cc1f521cfc07dbcef1f4bec7ac3e2b5
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"url": "https://__DOMAIN____PATH__",
|
||||
"server": {
|
||||
"host": "127.0.0.1",
|
||||
"port": __PORT__
|
||||
},
|
||||
"database": {
|
||||
"client": "mysql",
|
||||
"connection": {
|
||||
"socketPath" : "/run/mysqld/mysqld.sock",
|
||||
"user" : "__DB_USER__",
|
||||
"password" : "__DB_PWD__",
|
||||
"database" : "__DB_NAME__"
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
"type": "password"
|
||||
},
|
||||
"paths": {
|
||||
"contentPath": "content/"
|
||||
},
|
||||
"logging": {
|
||||
"level": "info",
|
||||
"rotation": {
|
||||
"enabled": true
|
||||
},
|
||||
"transports": ["file", "stdout"]
|
||||
}
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
[Unit]
|
||||
Description=__APP__ systemd service
|
||||
Documentation=https://docs.ghost.org
|
||||
Description=__APP__ systemd service
|
||||
Documentation=https://ghost.org/docs/
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__FINALPATH__
|
||||
WorkingDirectory=__INSTALL_DIR__/ghost
|
||||
Environment="__YNH_NODE_LOAD_PATH__"
|
||||
Environment="NODE_ENV=production"
|
||||
#ExecStart=__YNH_NODE__ core/index.js run
|
||||
ExecStart=yarn start
|
||||
ExecStart=__YNH_NODE__ __INSTALL_DIR__/node_modules/ghost-cli/bin/ghost run
|
||||
Restart=always
|
||||
|
||||
# Sandboxing options to harden security
|
||||
|
|
3
doc/DESCRIPTION.md
Normal file
3
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Ghost is a powerful app for new-media creators to publish, share, and grow a business around their content.
|
||||
|
||||
It comes with modern tools to build a website, publish content, send newsletters & offer paid subscriptions to members.
|
|
@ -1,21 +0,0 @@
|
|||
## Installation
|
||||
|
||||
1. No LDAP support.
|
||||
1. You need more than **1GB** of ram. If you don't have it, please create a **swap memory**.
|
||||
|
||||
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
1. This app is multi-instance (you can have more than one Ghost blogging websites on a single YunoHost server)
|
||||
|
||||
### Installing the Ghost app
|
||||
|
||||
0. Note - When making the install public, your Ghost domain link must be accessed WHILE NOT signed into your YunoHost session. It is recommended to use a incognito mode to sign into your Ghost admin account. If you make your install public, and try to login your Ghost admin account while signed into your YunoHost session, you will get a an authorized header error. The reason for this is because Ghost has a feature that allows for a subscription based access for content. This means Ghost allows for the admin user to setup other users (either other staff or paid/unpaid subscribers) to have the abilility to login outside of YunoHost.
|
||||
|
||||
1. **App can be installed by YunoHost admin interface or by the following command:**
|
||||
|
||||
`sudo yunohost app install https://github.com/YunoHost-Apps/ghost_ynh`
|
||||
|
||||
2. After installation create an **admin account** by visiting `https://domain.tld/ghost/ghost`. If you choose to name your Ghost instance "blog" during YunoHost setup process, then it would be `https://domain.tld/blog/ghost`. This will allow you to continue to setup your admin account and configure your settings.
|
|
@ -1,21 +0,0 @@
|
|||
## Installation
|
||||
|
||||
1. Pas de prise en charge LDAP.
|
||||
1. Vous avez besoin de plus de **1 Go** de RAM. Si vous ne l'avez pas, veuillez créer une **mémoire d'échange**.
|
||||
|
||||
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
|
||||
mkswap /fichier d'échange
|
||||
swapon / fichier d'échange
|
||||
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
1. Cette application est multi-instance (vous pouvez avoir plusieurs sites Web de blogs Ghost sur un seul serveur YunoHost)
|
||||
|
||||
### Installation de l'application Ghost
|
||||
|
||||
0. Remarque - Lorsque vous rendez l'installation publique, vous devez accéder à votre lien de domaine Ghost SANS vous connecter à votre session YunoHost. Il est recommandé d'utiliser un mode incognito pour vous connecter à votre compte administrateur Ghost. Si vous rendez votre installation publique et essayez de vous connecter à votre compte administrateur Ghost tout en étant connecté à votre session YunoHost, vous obtiendrez une erreur d'en-tête autorisée. La raison en est que Ghost a une fonctionnalité qui permet un accès au contenu basé sur un abonnement. Cela signifie que Ghost permet à l'utilisateur administrateur de configurer d'autres utilisateurs (soit d'autres membres du personnel, soit des abonnés payés/non payés) pour avoir la possibilité de se connecter en dehors de YunoHost.
|
||||
|
||||
1. ** L'application peut être installée par l'interface d'administration YunoHost ou par la commande suivante : **
|
||||
|
||||
`sudo yunohost installer l'application https://github.com/YunoHost-Apps/ghost_ynh`
|
||||
|
||||
2. Après l'installation, créez un **compte administrateur** en visitant `https://domain.tld/ghost/ghost`. Si vous choisissez de nommer votre instance Ghost "blog" pendant le processus d'installation de YunoHost, alors ce sera "https://domain.tld/blog/ghost". Cela vous permettra de continuer à configurer votre compte administrateur et à configurer vos paramètres.
|
5
doc/POST_INSTALL.md
Normal file
5
doc/POST_INSTALL.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
Ghost was successfully installed!
|
||||
|
||||
Now create an admin account at https://__DOMAIN____PATH__/ghost
|
||||
|
||||
Happy Blogging!
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"name": "Ghost",
|
||||
"id": "ghost",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Publishing, memberships, subscriptions and newsletters platform",
|
||||
"fr": "Plateforme d'édition, d'adhésions, d'abonnements et de newsletters"
|
||||
},
|
||||
"version": "5.44.0~ynh1",
|
||||
"url": "https://ghost.org/",
|
||||
"upstream": {
|
||||
"license": "MIT",
|
||||
"website": "https://ghost.org/",
|
||||
"admindoc": "https://ghost.org/help/",
|
||||
"code": "https://github.com/TryGhost/Ghost",
|
||||
"cpe": "cpe:2.3:a:ghost:ghost"
|
||||
},
|
||||
"license": "MIT",
|
||||
"maintainer": {
|
||||
"name": "Julien Malik",
|
||||
"email": "julien.malik@paraiso.me"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"example": "/blog",
|
||||
"default": "/blog"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"help": {
|
||||
"en": "If enabled, Ghost will be accessible by people who do not have an account. This can be changed later via the webadmin.",
|
||||
"fr": "Si cette case est cochée, Ghost sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
58
manifest.toml
Normal file
58
manifest.toml
Normal file
|
@ -0,0 +1,58 @@
|
|||
packaging_format = 2
|
||||
|
||||
id = "ghost"
|
||||
name = "Ghost"
|
||||
description.en = "Publishing, memberships, subscriptions and newsletters platform"
|
||||
description.fr = "Plateforme d'édition, d'adhésions, d'abonnements et de newsletters"
|
||||
|
||||
version = "5.44.0~ynh1"
|
||||
|
||||
maintainers = ["Julien Malik"]
|
||||
|
||||
[upstream]
|
||||
license = "MIT"
|
||||
website = "https://ghost.org/"
|
||||
admindoc = "https://ghost.org/help/"
|
||||
code = "https://github.com/TryGhost/Ghost"
|
||||
cpe = "cpe:2.3:a:ghost:ghost"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.1.0"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
sso = false
|
||||
disk = "1G"
|
||||
ram.build = "2G"
|
||||
ram.runtime = "2G"
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
type = "path"
|
||||
default = "/blog"
|
||||
|
||||
[install.init_main_permission]
|
||||
help.en = "If enabled, Ghost will be accessible by people who do not have an account. This can be changed later via the webadmin."
|
||||
help.fr = "Si cette case est cochée, Ghost sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
|
||||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[resources]
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
main.auth_header = false
|
||||
|
||||
[resources.ports]
|
||||
|
||||
[resources.apt]
|
||||
packages = "mailutils mariadb-server"
|
||||
|
||||
[resources.database]
|
||||
type = "mysql"
|
|
@ -4,10 +4,7 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="mailutils"
|
||||
|
||||
NODEJS_VERSION=14
|
||||
NODEJS_VERSION=16
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
@ -20,60 +17,3 @@ NODEJS_VERSION=14
|
|||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Send an email to inform the administrator
|
||||
#
|
||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||
# | arg: app_message - The message to send to the administrator.
|
||||
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||
# example: "root admin@domain"
|
||||
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||
# example: "root admin@domain user1 user2"
|
||||
ynh_send_readme_to_admin() {
|
||||
local app_message="${1:-...No specific information...}"
|
||||
local recipients="${2:-root}"
|
||||
|
||||
# Retrieve the email of users
|
||||
find_mails () {
|
||||
local list_mails="$1"
|
||||
local mail
|
||||
local recipients=" "
|
||||
# Read each mail in argument
|
||||
for mail in $list_mails
|
||||
do
|
||||
# Keep root or a real email address as it is
|
||||
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
|
||||
then
|
||||
recipients="$recipients $mail"
|
||||
else
|
||||
# But replace an user name without a domain after by its email
|
||||
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
|
||||
then
|
||||
recipients="$recipients $mail"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$recipients"
|
||||
}
|
||||
recipients=$(find_mails "$recipients")
|
||||
|
||||
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` has important message for you"
|
||||
|
||||
local mail_message="This is an automated message from your beloved YunoHost server.
|
||||
Specific information for the application $app.
|
||||
$app_message
|
||||
---
|
||||
Automatic diagnosis data from YunoHost
|
||||
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||
|
||||
# Define binary to use for mail command
|
||||
if [ -e /usr/bin/bsd-mailx ]
|
||||
then
|
||||
local mail_bin=/usr/bin/bsd-mailx
|
||||
else
|
||||
local mail_bin=/usr/bin/mail.mailutils
|
||||
fi
|
||||
|
||||
# Send the email to the recipients
|
||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||
}
|
||||
|
|
|
@ -10,56 +10,17 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -9,71 +9,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
domain=$new_domain
|
||||
else
|
||||
domain=$old_domain
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
path=$new_path
|
||||
else
|
||||
path=$old_path
|
||||
fi
|
||||
|
||||
if [[ $path =~ "\/ghost\/?" ]]
|
||||
then
|
||||
ynh_die --message="Sorry, Ghost does not support being installed on a path ending by /ghost"
|
||||
|
@ -93,29 +28,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the NGINX config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original NGINX config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
|
@ -124,9 +37,7 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..."
|
||||
|
||||
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"
|
||||
echo "$(jq -r --arg YNH_APP_NEW_DOMAIN $YNH_APP_NEW_DOMAIN --arg YNH_APP_NEW_PATH $YNH_APP_NEW_PATH ".url = \"http://$YNH_APP_NEW_DOMAIN$YNH_APP_NEW_PATH\"" $install_dir/ghost/config.production.json)" > $install_dir/ghost/config.production.json
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
@ -137,13 +48,6 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
182
scripts/install
182
scripts/install
|
@ -9,107 +9,40 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# 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
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=4010)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_script_progression --message="Installing NodeJS dependencies..."
|
||||
|
||||
# Install Nodejs
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@latest
|
||||
|
||||
# Install Yarn
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
ynh_npm install --global yarn
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
# Install Ghost-CLI
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
mkdir -p $install_dir/ghost
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..."
|
||||
pushd $install_dir
|
||||
ynh_script_progression --message="Installing and configuring Ghost..."
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ghost-cli@latest
|
||||
ynh_exec_as $app $ynh_node_load_PATH ./node_modules/ghost-cli/bin/ghost install $(ynh_app_upstream_version) \
|
||||
--no-prompt --no-setup-systemd --no-start \
|
||||
--dir ghost --no-setup-linux-user \
|
||||
--no-setup-nginx --no-setup-ssl --url http://$domain$path --port $port \
|
||||
--db mysql --dbhost localhost --dbuser $db_user --dbpass $db_pwd --dbname $db_name \
|
||||
--mail SMTP --mailhost localhost --mailport 465
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
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 casper.src
|
||||
mkdir -p $final_path/ghost/core/content/themes/casper
|
||||
ynh_setup_source --dest_dir="$final_path/ghost/core/content/themes/casper" --source_id="casper"
|
||||
|
||||
git init "$final_path" -q
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
# Patch https://github.com/YunoHost-Apps/ghost_ynh/issues/199
|
||||
ynh_replace_string --match_string=".whereRaw('posts.id" --replace_string=".whereRaw('\`posts\`.id" --target_file="$final_path/ghost/core/core/server/models/post.js"
|
||||
# Cleanup cache
|
||||
ynh_secure_remove --file=".cache/yarn"
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -119,37 +52,6 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..."
|
||||
|
||||
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"
|
||||
|
||||
touch "$final_path/.yarnrc.yml"
|
||||
chmod 400 "$final_path/.yarnrc.yml"
|
||||
chown $app:$app "$final_path/.yarnrc.yml"
|
||||
|
||||
#==============================================
|
||||
# BUILD GHOST
|
||||
#==============================================
|
||||
ynh_script_progression --message="Building Ghost... (this will take some time and resources!)"
|
||||
|
||||
pushd "$final_path"
|
||||
ynh_use_nodejs
|
||||
# Longer network timeouts for slow systems; see https://github.com/yarnpkg/yarn/issues/8242
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn config set network-timeout 600000
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_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 HOME="$final_path" yarn setup # catch-all command provided by Ghost that handles all the setup
|
||||
pushd "ghost/admin"
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn build --environment/production # well, except for the admin
|
||||
popd
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
@ -164,14 +66,14 @@ ynh_add_systemd_config
|
|||
ynh_script_progression --message="Configuring log rotation..."
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_use_logrotate --logfile="$install_dir/ghost/content/logs"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="$app daemon for Ghost" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -181,42 +83,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
|||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Ghost booted" --timeout=60
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
ynh_permission_create --permission="admin" --url="/ghost" --allowed="visitors" --auth_header="false" --protected="true"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Sending a readme for the admin..." --weight=1
|
||||
|
||||
message="Ghost was successfully installed :)
|
||||
|
||||
Next step:
|
||||
|
||||
Create an admin account at https://$domain$path_url/ghost
|
||||
|
||||
Happy Blogging!
|
||||
|
||||
If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/ghost_ynh/issues"
|
||||
|
||||
ynh_send_readme_to_admin "$message"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,99 +10,27 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the MySQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing log files..."
|
||||
ynh_remove_logrotate
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,40 +10,19 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -51,48 +30,19 @@ ynh_script_progression --message="Restoring the NGINX configuration..."
|
|||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_script_progression --message="Reinstalling NodeJS..."
|
||||
|
||||
# Install Nodejs
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
||||
# Install Yarn
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..."
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
|
@ -115,7 +65,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="$app daemon for Ghost" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
|
190
scripts/upgrade
190
scripts/upgrade
|
@ -9,42 +9,10 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_clean_check_starting
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -56,15 +24,6 @@ if [ -z "$db_name" ]; then
|
|||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
@ -73,70 +32,81 @@ ynh_script_progression --message="Stopping a systemd service..."
|
|||
ynh_systemd_action --service_name=$app --action=stop
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
# Install Nodejs
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@latest
|
||||
|
||||
# Install Yarn
|
||||
ynh_npm install --global yarn
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
# UPGRADE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
# Up to v5.26.4~ynh1, we were downloading the source code and building the app by ourselves
|
||||
# that was a mess to maintain, let's move away from that
|
||||
if ynh_compare_current_package_version --comparison le --version 5.26.4~ynh1
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
ynh_script_progression --message="Upgrading from older packaging of Ghost..."
|
||||
|
||||
# Create a temporary directory
|
||||
tmpdir="$(mktemp -d)"
|
||||
|
||||
# Copy the admin saved settings from final path to tmp directory
|
||||
if [ -f "$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
|
||||
if [ -f "$final_path/config.production.json" ]
|
||||
if [ -f "$install_dir/config.production.json" ]
|
||||
then
|
||||
# Old versions of Ghost store it here
|
||||
cp -ar "$final_path/content" "$tmpdir/content"
|
||||
# Old versions of Ghost stored it here
|
||||
cp -ar "$install_dir/content" "$tmpdir/content"
|
||||
else
|
||||
# New versions of Ghost store it here
|
||||
cp -ar "$final_path/ghost/core/content" "$tmpdir/content"
|
||||
cp -ar "$install_dir/ghost/core/content" "$tmpdir/content"
|
||||
fi
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file=$final_path
|
||||
ynh_secure_remove --file=$install_dir
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir=$final_path
|
||||
# Recreate it
|
||||
mkdir -p $install_dir
|
||||
|
||||
# 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/ghost/core/content/themes/casper" --source_id="casper"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
# Copy the admin saved settings from tmp directory to final path
|
||||
cp -ar "$tmpdir/config.production.json" "$final_path/ghost/core/config.production.json"
|
||||
pushd $install_dir
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ghost-cli@latest
|
||||
ynh_exec_as $app $ynh_node_load_PATH ./node_modules/ghost-cli/bin/ghost install $(ynh_app_upstream_version) \
|
||||
--no-prompt --no-setup-systemd --no-start \
|
||||
--dir ghost --no-setup-linux-user \
|
||||
--no-setup-nginx --no-setup-ssl --url http://$domain$path --port $port \
|
||||
--db mysql --dbhost localhost --dbuser $db_user --dbpass $db_pwd --dbname $db_name \
|
||||
--mail SMTP --mailhost localhost --mailport 465
|
||||
popd
|
||||
|
||||
# Copy content folder back to the final_path
|
||||
cp -ar "$tmpdir/content" "${final_path}/ghost/core"
|
||||
# Copy content folder back to the install_dir
|
||||
cp -ar "$tmpdir/content" "${install_dir}/ghost/core"
|
||||
|
||||
# Remove the tmp directory securely
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
|
||||
# Patch https://github.com/YunoHost-Apps/ghost_ynh/issues/199
|
||||
ynh_replace_string --match_string=".whereRaw('posts.id" --replace_string=".whereRaw('\`posts\`.id" --target_file="$final_path/ghost/core/core/server/models/post.js"
|
||||
else
|
||||
|
||||
# Upgrade Ghost CLI and Ghost itself
|
||||
pushd $install_dir
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ghost-cli@latest
|
||||
ynh_exec_as $app $ynh_node_load_PATH ./node_modules/ghost-cli/bin/ghost update $(ynh_app_upstream_version) \
|
||||
--no-prompt --no-auto-rollback --no-restart
|
||||
popd
|
||||
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
# Cleanup cache
|
||||
ynh_secure_remove --file="$install_dir/.cache/yarn"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -146,66 +116,15 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
# Install Nodejs
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
||||
# Install Yarn
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..."
|
||||
|
||||
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"
|
||||
|
||||
touch "$final_path/.yarnrc.yml"
|
||||
chmod 400 "$final_path/.yarnrc.yml"
|
||||
chown $app:$app "$final_path/.yarnrc.yml"
|
||||
|
||||
#==============================================
|
||||
# BUILD GHOST
|
||||
#==============================================
|
||||
|
||||
# Make the final_path a git repo if needed
|
||||
if [ ! -d "$final_path/.git" ]; then
|
||||
ynh_exec_as $app git init "$final_path" -q
|
||||
fi
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Building Ghost... (this will take some time and resources!)"
|
||||
|
||||
pushd "$final_path"
|
||||
# Longer network timeouts for slow systems; see https://github.com/yarnpkg/yarn/issues/8242
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn config set network-timeout 600000
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn install --non-interactive
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_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 HOME="$final_path" yarn setup
|
||||
pushd "ghost/admin"
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn build --environment/production
|
||||
popd
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -215,14 +134,14 @@ ynh_script_progression --message="Upgrading systemd configuration..."
|
|||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_use_logrotate --logfile="$install_dir/ghost/content/logs" --non-append
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="$app daemon for Ghost" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="$app daemon for Ghost" --log="$install_dir/ghost/contents/logs"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -231,13 +150,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
|||
|
||||
ynh_systemd_action --service_name=$app --action=start --line_match="Ghost booted" --timeout=60
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
7
tests.toml
Normal file
7
tests.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
test_format = 1.0
|
||||
|
||||
[default]
|
||||
|
||||
exclude = ["install.nourl"]
|
||||
|
||||
test_upgrade_from.7a150ab29ee969f72dd7846539ae12ac1975165b.name = "Upgrade from 4.9.4"
|
Loading…
Add table
Reference in a new issue