mirror of
https://github.com/YunoHost-Apps/ghost_ynh.git
synced 2024-09-03 19:16:02 +02:00
Finalize packaging v2 and upgrade to v5.44.0
This commit is contained in:
parent
9689e2415b
commit
a5bde0406b
8 changed files with 53 additions and 468 deletions
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -15,17 +15,16 @@ website = "https://ghost.org/"
|
|||
admindoc = "https://ghost.org/help/"
|
||||
code = "https://github.com/TryGhost/Ghost"
|
||||
cpe = "cpe:2.3:a:ghost:ghost"
|
||||
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 4.3.0"
|
||||
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||
yunohost = ">= 11.1.0"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = "false"
|
||||
sso = "false"
|
||||
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
disk = "1G"
|
||||
ram.build = "2G"
|
||||
ram.runtime = "2G"
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
|
|
|
@ -10,56 +10,17 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? 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="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
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
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
#REMOVEME? 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
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? change_domain=0
|
||||
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
#REMOVEME? change_domain=1
|
||||
#REMOVEME? domain=$new_domain
|
||||
else
|
||||
#REMOVEME? domain=$old_domain
|
||||
fi
|
||||
|
||||
#REMOVEME? change_path=0
|
||||
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
#REMOVEME? change_path=1
|
||||
#REMOVEME? path=$new_path
|
||||
else
|
||||
#REMOVEME? path=$old_path
|
||||
fi
|
||||
|
||||
if [[ $path =~ "\/ghost\/?" ]]
|
||||
then
|
||||
ynh_die --message="Sorry, Ghost does not support being installed on a path ending by /ghost"
|
||||
|
@ -95,30 +30,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#REMOVEME? 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
|
||||
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for NGINX helper
|
||||
#REMOVEME? domain="$old_domain"
|
||||
#REMOVEME? path="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
#REMOVEME? 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
|
||||
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
|
@ -139,13 +50,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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
|
||||
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -9,14 +9,11 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
read -p "debug me"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing NodeJS dependencies..."
|
||||
|
||||
# Install Nodejs
|
||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
||||
|
@ -34,6 +31,7 @@ chmod -R o-rwx "$install_dir"
|
|||
chown -R $app:$app "$install_dir"
|
||||
|
||||
pushd $install_dir
|
||||
ynh_script_progression --message="Installing and configuring Ghost..."
|
||||
ynh_exec_as $app $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 \
|
||||
|
|
|
@ -10,99 +10,27 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing the MySQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
#REMOVEME? ynh_remove_app_dependencies
|
||||
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
#REMOVEME? ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,55 +10,8 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
#REMOVEME? test ! -d $install_dir \
|
||||
|| ynh_die --message="There is already a directory: $install_dir "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -71,28 +24,25 @@ chmod -R o-rwx "$install_dir"
|
|||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
#REMOVEME? 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
|
||||
#REMOVEME? 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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..."
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
#REMOVEME? 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
|
||||
|
||||
#=================================================
|
||||
|
|
167
scripts/upgrade
167
scripts/upgrade
|
@ -9,42 +9,10 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? 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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_clean_check_starting
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -53,18 +21,9 @@ ynh_script_progression --message="Ensuring downward compatibility..."
|
|||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
@ -73,38 +32,35 @@ ynh_script_progression --message="Stopping a systemd service..."
|
|||
ynh_systemd_action --service_name=$app --action=stop
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? 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)
|
||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@latest
|
||||
|
||||
# Install Yarn
|
||||
ynh_npm install --global yarn
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
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 "$install_dir/config.production.json" ]
|
||||
then
|
||||
# Old versions of Ghost store it here
|
||||
cp -ar "$install_dir/config.production.json" "$tmpdir/config.production.json"
|
||||
else
|
||||
# New versions of Ghost store it here
|
||||
cp -ar "$install_dir/ghost/core/config.production.json" "$tmpdir/config.production.json"
|
||||
fi
|
||||
|
||||
# Backup the content folder to the temp dir
|
||||
if [ -f "$install_dir/config.production.json" ]
|
||||
then
|
||||
# Old versions of Ghost store it here
|
||||
# Old versions of Ghost stored it here
|
||||
cp -ar "$install_dir/content" "$tmpdir/content"
|
||||
else
|
||||
# New versions of Ghost store it here
|
||||
|
@ -112,17 +68,24 @@ then
|
|||
fi
|
||||
|
||||
# Remove the app directory securely
|
||||
#REMOVEME? ynh_secure_remove --file=$install_dir
|
||||
ynh_secure_remove --file=$install_dir
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir=$install_dir
|
||||
# Recreate it
|
||||
mkdir -p $install_dir
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from casper.src
|
||||
mkdir -p $install_dir/content/themes/casper
|
||||
ynh_setup_source --dest_dir="$install_dir/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" "$install_dir/ghost/core/config.production.json"
|
||||
pushd $install_dir
|
||||
ynh_exec_as $app $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 install_dir
|
||||
cp -ar "$tmpdir/content" "${install_dir}/ghost/core"
|
||||
|
@ -130,14 +93,8 @@ then
|
|||
# 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="$install_dir/ghost/core/core/server/models/post.js"
|
||||
fi
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -146,66 +103,15 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
# Install Nodejs
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||
|
||||
# Install Yarn
|
||||
#REMOVEME? 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="$install_dir/ghost/core/config.production.json"
|
||||
chmod 400 "$install_dir/ghost/core/config.production.json"
|
||||
chown $app:$app "$install_dir/ghost/core/config.production.json"
|
||||
|
||||
touch "$install_dir/.yarnrc.yml"
|
||||
chmod 400 "$install_dir/.yarnrc.yml"
|
||||
chown $app:$app "$install_dir/.yarnrc.yml"
|
||||
|
||||
#==============================================
|
||||
# BUILD GHOST
|
||||
#==============================================
|
||||
|
||||
# Make the install_dir a git repo if needed
|
||||
if [ ! -d "$install_dir/.git" ]; then
|
||||
ynh_exec_as $app git init "$install_dir" -q
|
||||
fi
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Building Ghost... (this will take some time and resources!)"
|
||||
|
||||
pushd "$install_dir"
|
||||
# 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="$install_dir" yarn config set network-timeout 600000
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$install_dir" yarn install --non-interactive
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$install_dir" 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="$install_dir" yarn setup
|
||||
pushd "ghost/admin"
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$install_dir" 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,7 +121,7 @@ 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
|
||||
|
@ -231,13 +137,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
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue