1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/distbin_ynh.git synced 2024-09-03 18:26:10 +02:00

Merge pull request #42 from YunoHost-Apps/testing

Upgrade to 1.20 + sub_path
This commit is contained in:
yalh76 2019-03-20 13:18:09 +01:00 committed by GitHub
commit e3456669fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 59 additions and 29 deletions

View file

@ -11,7 +11,7 @@ A distributed pastebin. i.e. it is a service where anyone can post things on the
A networked place to store posted web documents. This is meant to allow for distributed social commentary and reaction around these documents using best practices recommended or noted by the W3C Social Web Working Group.
**Shipped version:** 1.0
**Shipped version:** 1.2.0
## Screenshots

View file

@ -6,21 +6,21 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0)
; Checks
pkg_linter=1
setup_sub_dir=0
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=d39e8118603e1cc7e00d1c414ad9b55da68bfc7a
backup_restore=1
multi_instance=1
incorrect_path=1
port_already_use=0
change_url=0
change_url=1
;;; Levels
Level 1=auto
Level 2=auto

View file

@ -8,7 +8,10 @@ PORT=__PORT__
DB_DIR=__FINALPATH__/distbin-db
# The external URL
EXTERNAL_URL=https://__DOMAIN_URI__
EXTERNAL_URL=https://__DOMAIN_URI__/
# The internal URL
INTERNAL_URL=http://localhost:__PORT__/
# The Node Environnement
NODE_ENV=production

View file

@ -1,5 +1,5 @@
SOURCE_URL=url of app's source
SOURCE_SUM=sha256 checksum
SOURCE_URL=https://github.com/gobengo/distbin/archive/v1.2.0.tar.gz
SOURCE_SUM=ae72d386e9c68afa4d6b08f0a9c9b441a04176001beb226b903f924076e5cfcb
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -7,8 +7,12 @@ location __PATH__/ {
}
proxy_pass http://127.0.0.1:__PORT__/;
proxy_set_header Host $host;
# proxy_buffering off;
proxy_pass_request_headers on;
proxy_redirect ~^/(.*) $scheme://$http_host__PATH__/$1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;

View file

@ -6,7 +6,7 @@
"en": "Distributed pastebin with ActivityPub.",
"fr": "Pastebin distribué utilisant le protocole ActivityPub."
},
"version": "1.0~ynh6",
"version": "1.2.0~ynh1",
"url": "https://example.com",
"license": "Apache-2.0",
"maintainer": {
@ -30,6 +30,16 @@
},
"example": "distbin.example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for distbin",
"fr": "Choisissez un chemin pour distbin"
},
"example": "/distbin",
"default": "/distbin"
},
{
"name": "is_public",
"type": "boolean",

View file

@ -5,7 +5,7 @@
#=================================================
# dependencies used by the app
pkg_dependencies="ca-certificates"
pkg_dependencies="ca-certificates curl sudo"
#=================================================
# PERSONAL HELPERS

View file

@ -7,6 +7,7 @@
#=================================================
source _common.sh
source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
@ -17,7 +18,7 @@ old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
@ -32,6 +33,7 @@ final_path=$(ynh_app_setting_get $app final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get "$app" db_name)
#db_pwd=$(ynh_app_setting_get $app db_pwd)
port=$(ynh_app_setting_get $app port)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
@ -95,14 +97,22 @@ fi
# STOP SERVICE
#=================================================
ynh_systemd_action --action=stop --service_name=$app
ynh_systemd_action --action=stop --service_name=$app --log_path=systemd --line_match="Stopped Distbin Service"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
# Change the URL in the configuration file
ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain$new_path" "$final_path/.env"
if [ "$new_path" == "/" ]
then
new_domain_uri="$new_domain"
else
new_domain_uri="$new_domain$new_path"
fi
ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain_uri/" "$final_path/.env"
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
@ -114,8 +124,7 @@ ynh_store_file_checksum "$final_path/.env"
# START SERVICE
#=================================================
ynh_systemd_action --action=start --service_name=$app
ynh_systemd_action --action=start --service_name=$app --line_match="http"
#=================================================
# GENERIC FINALISATION

View file

@ -26,7 +26,7 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
path_url=$YNH_APP_ARG_PATH
#admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
#language=$YNH_APP_ARG_LANGUAGE
@ -102,7 +102,7 @@ ynh_print_info "Installing dependencies ..."
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 8
ynh_install_nodejs 10
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -115,8 +115,7 @@ 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
#ynh_setup_source "$final_path"
git clone https://github.com/gobengo/distbin "$final_path"
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -150,6 +149,8 @@ chown -R "$app":"$app" "/var/log/$app"
#=================================================
mkdir -p "$final_path/distbin-db"
mkdir -p "$final_path/distbin-db/activities"
mkdir -p "$final_path/distbin-db/inbox"
#=================================================
# MAKE SETUP
@ -195,10 +196,16 @@ ynh_add_systemd_config
### (It's compatible with sed regular expressions syntax)
cp "../conf/.env" "$final_path/.env"
if [ "$path_url" == "/" ]
then
domain_uri="$domain"
else
domain_uri="$domain$path_url"
fi
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$final_path/.env"
ynh_replace_string "__PORT__" "$port" "$final_path/.env"
ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "$final_path/.env"
ynh_replace_string "__DOMAIN_URI__" "$domain_uri" "$final_path/.env"
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/.env"
#=================================================
@ -280,7 +287,7 @@ systemctl reload nginx
# START SERVICE
#=================================================
ynh_systemd_action --action=start --service_name=$app --line_match="http://localhost:"
ynh_systemd_action --action=start --service_name=$app --line_match="http"
#=================================================
# END OF SCRIPT

View file

@ -90,7 +90,7 @@ ynh_print_info "Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 8
ynh_install_nodejs 10
#=================================================
# RESTORE SYSTEMD

View file

@ -82,11 +82,7 @@ ynh_systemd_action --action=stop --service_name=$app
ynh_print_info "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src#
#ynh_setup_source "$final_path"
git clone --quiet https://github.com/gobengo/distbin "$final_path/upgrade"
cp -a "$final_path/upgrade/." "$final_path/."
rm -r "$final_path/upgrade"
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -102,7 +98,8 @@ ynh_add_nginx_config
ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 8
ynh_remove_nodejs
ynh_install_nodejs 10
#=================================================
# CREATE DEDICATED USER