mirror of
https://github.com/YunoHost-Apps/ghost_ynh.git
synced 2024-09-03 19:16:02 +02:00
Packaging v2 and stop the install from source madness
This commit is contained in:
parent
d9cf63005b
commit
9689e2415b
14 changed files with 238 additions and 411 deletions
|
@ -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]
|
[Unit]
|
||||||
Description=__APP__ systemd service
|
Description=__APP__ systemd service
|
||||||
Documentation=https://docs.ghost.org
|
Documentation=https://ghost.org/docs/
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__
|
WorkingDirectory=__INSTALL_DIR__/ghost
|
||||||
Environment="__YNH_NODE_LOAD_PATH__"
|
Environment="__YNH_NODE_LOAD_PATH__"
|
||||||
Environment="NODE_ENV=production"
|
Environment="NODE_ENV=production"
|
||||||
#ExecStart=__YNH_NODE__ core/index.js run
|
ExecStart=__YNH_NODE__ __INSTALL_DIR__/node_modules/ghost-cli/bin/ghost run
|
||||||
ExecStart=yarn start
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
# Sandboxing options to harden security
|
# Sandboxing options to harden security
|
||||||
|
|
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!
|
59
manifest.toml
Normal file
59
manifest.toml
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
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"
|
||||||
|
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"]
|
||||||
|
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, ...
|
||||||
|
|
||||||
|
[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"
|
||||||
|
|
||||||
|
[resources.database]
|
||||||
|
type = "mysql"
|
|
@ -4,10 +4,7 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
NODEJS_VERSION=16
|
||||||
pkg_dependencies="mailutils"
|
|
||||||
|
|
||||||
NODEJS_VERSION=14
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
@ -20,60 +17,3 @@ NODEJS_VERSION=14
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# 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"
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Loading installation settings..."
|
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -13,65 +13,65 @@ source /usr/share/yunohost/helpers
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
new_path=$YNH_APP_NEW_PATH
|
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
|
|
||||||
# Add settings here as needed by your application
|
# Add settings here as needed by your application
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
# 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
|
#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
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#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.
|
# 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"
|
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
change_domain=0
|
#REMOVEME? change_domain=0
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||||
then
|
then
|
||||||
change_domain=1
|
#REMOVEME? change_domain=1
|
||||||
domain=$new_domain
|
#REMOVEME? domain=$new_domain
|
||||||
else
|
else
|
||||||
domain=$old_domain
|
#REMOVEME? domain=$old_domain
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_path=0
|
#REMOVEME? change_path=0
|
||||||
if [ "$old_path" != "$new_path" ]
|
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||||
then
|
then
|
||||||
change_path=1
|
#REMOVEME? change_path=1
|
||||||
path=$new_path
|
#REMOVEME? path=$new_path
|
||||||
else
|
else
|
||||||
path=$old_path
|
#REMOVEME? path=$old_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $path =~ "\/ghost\/?" ]]
|
if [[ $path =~ "\/ghost\/?" ]]
|
||||||
|
@ -93,28 +93,30 @@ 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
|
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
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
|
# Change the path in the NGINX config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original NGINX config file if modified
|
# Make a backup of the original NGINX config file if modified
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for NGINX helper
|
# Set global variables for NGINX helper
|
||||||
domain="$old_domain"
|
#REMOVEME? domain="$old_domain"
|
||||||
path_url="$new_path"
|
#REMOVEME? path="$new_path"
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
#REMOVEME? ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for NGINX
|
# Change the domain for NGINX
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -124,9 +126,9 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modifying 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"
|
ynh_add_config --template="../conf/config.production.json" --destination="$install_dir/ghost/core/config.production.json"
|
||||||
chmod 400 "$final_path/ghost/core/config.production.json"
|
chmod 400 "$install_dir/ghost/core/config.production.json"
|
||||||
chown $app:$app "$final_path/ghost/core/config.production.json"
|
chown $app:$app "$install_dir/ghost/core/config.production.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
@ -140,9 +142,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
180
scripts/install
180
scripts/install
|
@ -9,107 +9,39 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
read -p "debug me"
|
||||||
}
|
}
|
||||||
# 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
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
# Install Nodejs
|
# Install Nodejs
|
||||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
|
# Upgrade NPM
|
||||||
|
ynh_npm install --global npm@latest
|
||||||
|
|
||||||
# Install Yarn
|
# 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
|
||||||
|
|
||||||
#=================================================
|
# Install Ghost-CLI
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..."
|
|
||||||
|
|
||||||
# Create a system user
|
mkdir -p $install_dir/ghost
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
chmod 750 "$install_dir"
|
||||||
|
chmod -R o-rwx "$install_dir"
|
||||||
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
pushd $install_dir
|
||||||
# CREATE A MYSQL DATABASE
|
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) \
|
||||||
ynh_script_progression --message="Creating a MySQL database..."
|
--no-prompt --no-setup-systemd --no-start \
|
||||||
|
--dir ghost --no-setup-linux-user \
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
--no-setup-nginx --no-setup-ssl --url http://$domain$path --port $port \
|
||||||
db_user=$db_name
|
--db mysql --dbhost localhost --dbuser $db_user --dbpass $db_pwd --dbname $db_name \
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
--mail SMTP --mailhost localhost --mailport 465
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
popd
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -119,37 +51,6 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_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
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -164,14 +65,14 @@ ynh_add_systemd_config
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
ynh_script_progression --message="Configuring log rotation..."
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate --logfile="$install_dir/ghost/content/logs"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating 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
|
# START SYSTEMD SERVICE
|
||||||
|
@ -181,44 +82,9 @@ ynh_script_progression --message="Starting a systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Ghost booted" --timeout=60
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed"
|
ynh_script_progression --message="Installation of $app completed"
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -54,28 +54,28 @@ ynh_remove_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MYSQL DATABASE
|
# REMOVE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the MySQL database..."
|
#REMOVEME? ynh_script_progression --message="Removing the MySQL database..."
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
#REMOVEME? ynh_script_progression --message="Removing dependencies..."
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
#REMOVEME? ynh_remove_app_dependencies
|
||||||
|
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..."
|
#REMOVEME? ynh_script_progression --message="Removing app main directory..."
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
@ -98,10 +98,10 @@ ynh_secure_remove --file="/var/log/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
#REMOVEME? ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -14,33 +14,33 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading settings..."
|
ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
|
||||||
|
|
||||||
test ! -d $final_path \
|
#REMOVEME? test ! -d $install_dir \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $install_dir "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
|
@ -54,45 +54,45 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Install Nodejs
|
# Install Nodejs
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
# Install Yarn
|
# 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"
|
#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
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..."
|
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..."
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
#REMOVEME? 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
|
#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
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
112
scripts/upgrade
112
scripts/upgrade
|
@ -12,17 +12,17 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -33,17 +33,17 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -53,12 +53,12 @@ ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
# If db_name doesn't exist, create it
|
# If db_name doesn't exist, create it
|
||||||
if [ -z "$db_name" ]; then
|
if [ -z "$db_name" ]; then
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
# Cleaning legacy permissions
|
||||||
if ynh_legacy_permissions_exists; then
|
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||||
ynh_legacy_permissions_delete_all
|
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
fi
|
fi
|
||||||
|
@ -75,10 +75,10 @@ ynh_systemd_action --service_name=$app --action=stop
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -92,51 +92,51 @@ then
|
||||||
tmpdir="$(mktemp -d)"
|
tmpdir="$(mktemp -d)"
|
||||||
|
|
||||||
# Copy the admin saved settings from final path to tmp directory
|
# Copy the admin saved settings from final path to tmp directory
|
||||||
if [ -f "$final_path/config.production.json" ]
|
if [ -f "$install_dir/config.production.json" ]
|
||||||
then
|
then
|
||||||
# Old versions of Ghost store it here
|
# Old versions of Ghost store it here
|
||||||
cp -ar "$final_path/config.production.json" "$tmpdir/config.production.json"
|
cp -ar "$install_dir/config.production.json" "$tmpdir/config.production.json"
|
||||||
else
|
else
|
||||||
# New versions of Ghost store it here
|
# New versions of Ghost store it here
|
||||||
cp -ar "$final_path/ghost/core/config.production.json" "$tmpdir/config.production.json"
|
cp -ar "$install_dir/ghost/core/config.production.json" "$tmpdir/config.production.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Backup the content folder to the temp dir
|
# Backup the content folder to the temp dir
|
||||||
if [ -f "$final_path/config.production.json" ]
|
if [ -f "$install_dir/config.production.json" ]
|
||||||
then
|
then
|
||||||
# Old versions of Ghost store it here
|
# Old versions of Ghost store it here
|
||||||
cp -ar "$final_path/content" "$tmpdir/content"
|
cp -ar "$install_dir/content" "$tmpdir/content"
|
||||||
else
|
else
|
||||||
# New versions of Ghost store it here
|
# 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
|
fi
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file=$final_path
|
#REMOVEME? ynh_secure_remove --file=$install_dir
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir=$final_path
|
ynh_setup_source --dest_dir=$install_dir
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from casper.src
|
# Download, check integrity, uncompress and patch the source from casper.src
|
||||||
mkdir -p $final_path/content/themes/casper
|
mkdir -p $install_dir/content/themes/casper
|
||||||
ynh_setup_source --dest_dir="$final_path/ghost/core/content/themes/casper" --source_id="casper"
|
ynh_setup_source --dest_dir="$install_dir/ghost/core/content/themes/casper" --source_id="casper"
|
||||||
|
|
||||||
# Copy the admin saved settings from tmp directory to final path
|
# Copy the admin saved settings from tmp directory to final path
|
||||||
cp -ar "$tmpdir/config.production.json" "$final_path/ghost/core/config.production.json"
|
cp -ar "$tmpdir/config.production.json" "$install_dir/ghost/core/config.production.json"
|
||||||
|
|
||||||
# Copy content folder back to the final_path
|
# Copy content folder back to the install_dir
|
||||||
cp -ar "$tmpdir/content" "${final_path}/ghost/core"
|
cp -ar "$tmpdir/content" "${install_dir}/ghost/core"
|
||||||
|
|
||||||
# Remove the tmp directory securely
|
# Remove the tmp directory securely
|
||||||
ynh_secure_remove --file="$tmpdir"
|
ynh_secure_remove --file="$tmpdir"
|
||||||
|
|
||||||
# Patch https://github.com/YunoHost-Apps/ghost_ynh/issues/199
|
# 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"
|
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
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -149,15 +149,15 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Install Nodejs
|
# Install Nodejs
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
# Install Yarn
|
# 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"
|
#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
|
# SPECIFIC UPGRADE
|
||||||
|
@ -166,35 +166,35 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modifying 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"
|
ynh_add_config --template="../conf/config.production.json" --destination="$install_dir/ghost/core/config.production.json"
|
||||||
chmod 400 "$final_path/ghost/core/config.production.json"
|
chmod 400 "$install_dir/ghost/core/config.production.json"
|
||||||
chown $app:$app "$final_path/ghost/core/config.production.json"
|
chown $app:$app "$install_dir/ghost/core/config.production.json"
|
||||||
|
|
||||||
touch "$final_path/.yarnrc.yml"
|
touch "$install_dir/.yarnrc.yml"
|
||||||
chmod 400 "$final_path/.yarnrc.yml"
|
chmod 400 "$install_dir/.yarnrc.yml"
|
||||||
chown $app:$app "$final_path/.yarnrc.yml"
|
chown $app:$app "$install_dir/.yarnrc.yml"
|
||||||
|
|
||||||
#==============================================
|
#==============================================
|
||||||
# BUILD GHOST
|
# BUILD GHOST
|
||||||
#==============================================
|
#==============================================
|
||||||
|
|
||||||
# Make the final_path a git repo if needed
|
# Make the install_dir a git repo if needed
|
||||||
if [ ! -d "$final_path/.git" ]; then
|
if [ ! -d "$install_dir/.git" ]; then
|
||||||
ynh_exec_as $app git init "$final_path" -q
|
ynh_exec_as $app git init "$install_dir" -q
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Building Ghost... (this will take some time and resources!)"
|
ynh_script_progression --message="Building Ghost... (this will take some time and resources!)"
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$install_dir"
|
||||||
# Longer network timeouts for slow systems; see https://github.com/yarnpkg/yarn/issues/8242
|
# 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="$install_dir" 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="$install_dir" 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="$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="$final_path" yarn setup
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$install_dir" yarn setup
|
||||||
pushd "ghost/admin"
|
pushd "ghost/admin"
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn build --environment/production
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$install_dir" yarn build --environment/production
|
||||||
popd
|
popd
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
@ -234,9 +234,9 @@ ynh_systemd_action --service_name=$app --action=start --line_match="Ghost booted
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Add table
Reference in a new issue