mirror of
https://github.com/YunoHost-Apps/strut_ynh.git
synced 2024-09-03 20:26:33 +02:00
Merge pull request #14 from YunoHost-Apps/package_upgrade
Package upgrade
This commit is contained in:
commit
b7c1e6492b
12 changed files with 339 additions and 138 deletions
69
README.md
69
README.md
|
@ -1,26 +1,67 @@
|
|||
strut_ynh
|
||||
===============
|
||||
# Strut for YunoHost
|
||||
|
||||
Strut package for YunoHost
|
||||
[](https://dash.yunohost.org/appci/app/strut)
|
||||
[](https://install-app.yunohost.org/?app=strut)
|
||||
|
||||
## IMPORTANT NOTE ABOUT THIS PACKAGE
|
||||
This package doesn't contained the exact sources of the upstream https://github.com/tantaman/Strut.
|
||||
> *This package allow you to install Strut quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
Quick description of this app.
|
||||
|
||||
**Shipped version:** 20171224-1
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## Demo
|
||||
|
||||
* [Official demo](http://strut.io/editor/index.html)
|
||||
|
||||
## Configuration
|
||||
|
||||
## Documentation
|
||||
|
||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-users support
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/strut/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/strut/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/strut/)
|
||||
|
||||
## Limitations
|
||||
|
||||
## Additional information
|
||||
|
||||
* This package doesn't contained the exact sources of the upstream https://github.com/tantaman/Strut.
|
||||
|
||||
Initial Strut software includes Google Analytics and is bind to Imgur to upload images. This kind of trackers or external services are not accepted by the package team of YunoHost. So this trackers are removed from sources, a pull request has been done and merged but has finally be removed from the strut upstream with no explanation. In more, Strut developers don't deliver builded versions. To build a version it needs grunt, that can't be removed easily.
|
||||
|
||||
To avoid to take time to build this html/js app, this package setups a builded version of Strut with the patch that remove Google Analytics and Imgur dependencies. It is a build of this version https://github.com/tantaman/Strut/commits/6761b141ee7aa622916e2d23cced84ee95618cce . So it's not the more recent version.
|
||||
|
||||
## Links
|
||||
|
||||
## Official Website: http://strut.io
|
||||
* Report a bug: https://github.com/YunoHost-Apps/strut_ynh/issues
|
||||
* Strut website: http://strut.io
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
## About Strut
|
||||
---
|
||||
|
||||
[](http://strut.io)
|
||||
Developers info
|
||||
----------------
|
||||
|
||||
#### A GUI / Authoring Tool for ImpressJS and Bespoke.js ####
|
||||
|
||||
Don't know what ImpressJS is? Check out the ImpressJS demo presentation: http://bartaz.github.com/impress.js/#/bored
|
||||
|
||||
### Start using Strut! http://strut.io/editor/
|
||||
(works in Firefox, Chrome and Safari with basic support for IE10)
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/strut_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/strut_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade strut -u https://github.com/YunoHost-Apps/strut_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# See here for more informations
|
||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
|
@ -13,7 +11,7 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
# upgrade=1 from_commit=03c3ea18cf117127749a860afe538bc6070a8e0b
|
||||
upgrade=1 from_commit=f6565f66d82fa077d752226f8b8267018f7b91d8
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
|
@ -29,13 +27,13 @@
|
|||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
# Level 8=1
|
||||
# Level 9=1
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=ljf+ynh-strut@grimaud.me
|
||||
Notification=down
|
||||
#;;; Upgrade options
|
||||
# ; commit=03c3ea18cf117127749a860afe538bc6070a8e0b
|
||||
# name=Update package to level 7
|
||||
# manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes&
|
||||
;;; Upgrade options
|
||||
; commit=f6565f66d82fa077d752226f8b8267018f7b91d8
|
||||
name=May 27, 2018
|
||||
manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes&
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
location __PATH__ {
|
||||
alias __FINALPATH__/;
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/ ;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"url": "http://strut.io",
|
||||
"license": "AGPL-3.0",
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.2"
|
||||
"yunohost": ">= 3.2.2"
|
||||
},
|
||||
"description": {
|
||||
"en": "Strut is a slide editor creating impress.js presentations.",
|
||||
|
|
90
scripts/_common.sh
Normal file
90
scripts/_common.sh
Normal file
|
@ -0,0 +1,90 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
# | arg: -k, --key= - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
|
||||
local manifest
|
||||
local manifest_key
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
if [ ! -e "$manifest" ]; then
|
||||
# If the manifest isn't found, try the common place for backup and restore script.
|
||||
manifest="../settings/manifest.json"
|
||||
fi
|
||||
|
||||
jq ".$manifest_key" "$manifest" --raw-output
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version [-m manifest]
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
ynh_app_upstream_version () {
|
||||
declare -Ar args_array=( [m]=manifest= )
|
||||
local manifest
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
manifest="${manifest:-../manifest.json}"
|
||||
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Checks the app version to upgrade with the existing app version and returns:
|
||||
# - UPGRADE_APP if the upstream app version has changed
|
||||
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
#
|
||||
## It stops the current script without error if the package is up-to-date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||
# of it, when it's not needed
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
#
|
||||
# usage: ynh_check_app_version_changed
|
||||
ynh_check_app_version_changed () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
# By default, upstream app version has changed
|
||||
local return_value="UPGRADE_APP"
|
||||
|
||||
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)
|
||||
local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")"
|
||||
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0)
|
||||
local update_upstream_version="$(ynh_app_upstream_version)"
|
||||
|
||||
if [ "$current_version" == "$update_version" ] ; then
|
||||
# Complete versions are the same
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||
# Upstream versions are the same, only YunoHost package versions differ
|
||||
return_value="UPGRADE_PACKAGE"
|
||||
fi
|
||||
echo $return_value
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
log() {
|
||||
echo "${1}"
|
||||
}
|
||||
|
||||
info() {
|
||||
log "[INFO] ${1}"
|
||||
}
|
||||
|
||||
warn() {
|
||||
log "[WARN] ${1}"
|
||||
}
|
||||
|
||||
err() {
|
||||
log "[ERR] ${1}"
|
||||
}
|
||||
to_logs() {
|
||||
|
||||
# When yunohost --verbose or bash -x
|
||||
if $_ISVERBOSE; then
|
||||
cat
|
||||
else
|
||||
cat > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
read_json () {
|
||||
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||
}
|
||||
|
||||
read_manifest () {
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
read_json '../manifest.json' "$1"
|
||||
else
|
||||
read_json '../settings/manifest.json' "$1"
|
||||
fi
|
||||
}
|
||||
abort_if_up_to_date () {
|
||||
version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7')
|
||||
last_version=$(read_manifest 'version')
|
||||
if [ "${version}" = "${last_version}" ]; then
|
||||
info "Up-to-date, nothing to do"
|
||||
ynh_die "" 0
|
||||
fi
|
||||
}
|
|
@ -5,33 +5,45 @@
|
|||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the main app directory..."
|
||||
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _future.sh
|
||||
# source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -21,6 +21,14 @@ new_path=$YNH_APP_NEW_PATH
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
@ -46,50 +54,48 @@ then
|
|||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
||||
#ynh_backup_before_upgrade # Backup the current version of the app
|
||||
#ynh_clean_setup () {
|
||||
# ynh_restore_upgradebackup # restore it if the upgrade fails
|
||||
#}
|
||||
#ynh_abort_if_errors # Exit if an error occurs during the execution of the script
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_print_info "Updating nginx web server configuration..."
|
||||
|
||||
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
|
||||
# Replace locations starting with old_path
|
||||
# Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
|
||||
sed --in-place "s@location\( \(=\|~\|~\*\|\^~\)\)\? $old_path@location\1 $new_path@" "$nginx_conf_path"
|
||||
# Replace path in "return" directives
|
||||
sed --in-place "s@return \([[:digit:]]\{3\}\) $old_path@return \1 $new_path@" "$nginx_conf_path"
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$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 "$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 "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Change of URL completed for $app"
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
#source _common.sh
|
||||
|
||||
# source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# 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
|
||||
|
@ -25,6 +29,8 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
|
@ -34,36 +40,53 @@ ynh_webpath_register $app $domain $path_url
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
# For this app sources are in app subdirectory
|
||||
tmp_dir=$(mktemp -d)
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tmp_dir"
|
||||
}
|
||||
|
||||
ynh_setup_source "$tmp_dir"
|
||||
mv "$tmp_dir/dist" "$final_path"
|
||||
# Imgur is deactivated on the specific upstream selected, but this text is still here
|
||||
# Don't use a patch because it's minified js
|
||||
ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js"
|
||||
ynh_secure_remove "$tmp_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# PATCH SOURCE
|
||||
#=================================================
|
||||
|
||||
# Imgur is deactivated on the specific upstream selected, but this text is still here
|
||||
# Don't use a patch because it's minified js
|
||||
ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
# Set strong right permissions to app files
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R root:www-data "$final_path"
|
||||
chmod -R 640 "$final_path"
|
||||
find "$final_path" -type d -print0 | xargs -0 chmod 750
|
||||
|
@ -71,8 +94,9 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring SSOwat..."
|
||||
|
||||
# Make app public if necessary or protect it
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
|
@ -81,4 +105,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -22,6 +24,7 @@ final_path=$(ynh_app_setting_get $app final_path)
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
|
@ -29,6 +32,13 @@ ynh_secure_remove "$final_path"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
|
|
|
@ -6,18 +6,20 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
#source ../settings/scripts/_common.sh
|
||||
# source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
# Exit on command errors and treat access to unset variables as an error
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -28,22 +30,27 @@ final_path=$(ynh_app_setting_get $app final_path)
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
test ! -f $conf \
|
||||
|| ynh_die "There is already a nginx conf file at this path: $conf "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE BACKUP FILES
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
|
@ -59,5 +66,12 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server and php-fpm..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _future.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -21,23 +22,15 @@ is_public=$(ynh_app_setting_get $app is_public)
|
|||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# Check version
|
||||
#=================================================
|
||||
abort_if_up_to_date
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
ynh_backup_before_upgrade # Backup the current version of the app
|
||||
ynh_clean_setup () {
|
||||
ynh_restore_upgradebackup # restore it if the upgrade fails
|
||||
}
|
||||
ynh_abort_if_errors # Exit if an error occurs during the execution of the script
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info "Ensuring downward compatibility..."
|
||||
|
||||
if [ "${version}" = "20160501-7" ]; then
|
||||
public_site=$(ynh_app_setting_get $app public_site)
|
||||
|
@ -50,14 +43,28 @@ if [ "${version}" = "20160501-7" ]; then
|
|||
is_public=0
|
||||
fi
|
||||
ynh_app_setting_delete $app public_site
|
||||
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z $final_path ]; then
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "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_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
@ -71,31 +78,52 @@ path_url=$(ynh_normalize_url_path $path_url)
|
|||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
# For this app sources are in app subdirectory
|
||||
tmp_dir=$(mktemp -d)
|
||||
ynh_setup_source "$tmp_dir"
|
||||
# Dist is the compiled version. Other directories are source code and tools to build the program
|
||||
cp -R "$tmp_dir/dist/." "$final_path/"
|
||||
# Imgur is deactivated on the specific upstream selected, but this text is still here
|
||||
# Don't use a patch because it's minified js
|
||||
ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js"
|
||||
ynh_secure_remove "$tmp_dir"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_print_info "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
# For this app sources are in app subdirectory
|
||||
tmp_dir=$(mktemp -d)
|
||||
|
||||
ynh_setup_source "$tmp_dir"
|
||||
# Dist is the compiled version. Other directories are source code and tools to build the program
|
||||
cp -a "$tmp_dir/dist/." "$final_path/"
|
||||
ynh_secure_remove "$tmp_dir"
|
||||
|
||||
# Imgur is deactivated on the specific upstream selected, but this text is still here
|
||||
# Don't use a patch because it's minified js
|
||||
ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# PATCH SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# Imgur is deactivated on the specific upstream selected, but this text is still here
|
||||
# Don't use a patch because it's minified js
|
||||
ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set strong right permissions
|
||||
# Set permissions on app files
|
||||
chown -R root:www-data "$final_path"
|
||||
chmod -R 640 "$final_path"
|
||||
find "$final_path" -type d -print0 | xargs -0 chmod 750
|
||||
|
@ -103,16 +131,23 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading SSOwat configuration..."
|
||||
|
||||
# Make app public if necessary or protect it
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
else
|
||||
ynh_app_setting_set $app protected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue