1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/haste_ynh.git synced 2024-09-03 20:36:28 +02:00
* Fix check_process warning

* Update change_url

* Update manifest.json

* Fix linter warning

* Update remove

* Set badge in SVG

* Use SVG for badge

* Finding an available port

* Patch (#21)

* Fix linter warnings

* Small fixes

* Cleaning up

* Update manifest.json

* Cleaning up

* Fix badges

* [autopatch] Update issue and PR templates (#25)

Co-authored-by: Yunohost-Bot <>

* Add templates

* Fix

* Update restore

* Fix

* Update install

* Fix

* Update check_process

* Patch (#27)

* Fix

* Auto-update README

* Update systemd.service

* Update nginx.conf

Co-authored-by: Yunohost-Bot <>

* Update manifest.json

* 4.3

* Fix ynh_npm

* Add purge option

* Auto-update README

* Update version (#30)

* update

* Auto-update README

Co-authored-by: Yunohost-Bot <>

* Upgrade (#32)

* Fix

* Auto-update README

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Update _common.sh (#34)

* Update _common.sh

* Fix

* cleaning up

* Update manifest.json

* Auto-update README

* Auto-update README

* set relative path for --keep opt

* Auto-update README

* Update manifest.json

* Auto-update README

* Upgrade to upstream

* Auto-update README

* Reorder script

* Update restore

* Update systemd.service

* Version 2 (#38)

* v2

* Auto-update README

* v2

* Auto-update README

* fix

* Update config.js

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Update manifest.toml

* Auto-update README

---------

Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: Yunohost-Bot <>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: yalh76 <yalh@yahoo.com>
This commit is contained in:
Éric Gaspar 2023-04-03 16:58:04 +02:00 committed by GitHub
parent 812a747233
commit 70ed710426
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 114 additions and 513 deletions

View file

@ -5,7 +5,8 @@ It shall NOT be edited by hand.
# Haste for YunoHost
[![Integration level](https://dash.yunohost.org/integration/haste.svg)](https://dash.yunohost.org/appci/app/haste) ![Working status](https://ci-apps.yunohost.org/ci/badges/haste.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/haste.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/haste.svg)](https://dash.yunohost.org/appci/app/haste) ![Working status](https://ci-apps.yunohost.org/ci/badges/haste.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/haste.maintain.svg)
[![Install Haste with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=haste)
*[Lire ce readme en français.](./README_fr.md)*
@ -18,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Haste is an open-source pastebin software written in node.js, which is easily installable in any network. YunoHost Project uses Haste as pastebin for log sharing: [paste.yunohost.org](https://paste.yunohost.org/)
**Shipped version:** 0.1.0~ynh13
**Shipped version:** 0.1.0~ynh14
**Demo:** http://hastebin.com/
@ -26,23 +27,6 @@ Haste is an open-source pastebin software written in node.js, which is easily in
![Screenshot of Haste](./doc/screenshots/screenshot.png)
## Disclaimers / important information
#### Multi-user support
* Are LDAP and HTTP auth supported? **No**
* Can the app be used by multiple users? **Yes**
## `haste` command
This Haste package for Yunohost includes the [`haste` command](https://github.com/diethnis/standalones/blob/master/hastebin.sh), allowing you to share content from terminal:
```bash
cat something | haste
https://haste.example.com/zuyejeduzu
```
The [Haste-client](https://github.com/seejohnrun/haste-client) is a simple client for uploading data to you Haste server.
## Documentation and resources
* Official app website: <http://hastebin.com/>

View file

@ -5,50 +5,33 @@ It shall NOT be edited by hand.
# Haste pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/haste.svg)](https://dash.yunohost.org/appci/app/haste) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/haste.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/haste.maintain.svg)
[![Niveau dintégration](https://dash.yunohost.org/integration/haste.svg)](https://dash.yunohost.org/appci/app/haste) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/haste.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/haste.maintain.svg)
[![Installer Haste avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=haste)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Haste rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
> *Ce package vous permet dinstaller Haste rapidement et simplement sur un serveur YunoHost.
Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
## Vue d'ensemble
## Vue densemble
Haste est un logiciel pastebin open-source écrit en node.js, facilement installable sur n'importe quel réseau. Le projet YunoHost utilise Haste comme pastebin pour le partage de log : [paste.yunohost.org](https://paste.yunohost.org/)
**Version incluse :** 0.1.0~ynh13
**Version incluse :** 0.1.0~ynh14
**Démo :** http://hastebin.com/
## Captures d'écran
## Captures décran
![Capture d'écran de Haste](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
### Support multi-utilisateur
* L'authentification LDAP et HTTP est-elle prise en charge ? **Non**
* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui**
## `haste` command
Ce paquet de Haste pour YunoHost comprend une commande [`haste`](https://github.com/diethnis/standalones/blob/master/hastebin.sh), vous permettant de partager du contenu avec le terminal :
```bash
cat something | haste
https://haste.example.com/zuyejeduzu
```
Le [client Haste](https://github.com/seejohnrun/haste-client) est un client simple pour télécharger des données sur votre serveur Haste.
![Capture décran de Haste](./doc/screenshots/screenshot.png)
## Documentations et ressources
* Site officiel de l'app : <http://hastebin.com/>
* Site officiel de lapp : <http://hastebin.com/>
* Documentation officielle utilisateur : <https://hastebin.com/about.md>
* Dépôt de code officiel de l'app : <https://github.com/seejohnrun/haste-server>
* Dépôt de code officiel de lapp : <https://github.com/seejohnrun/haste-server>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_haste>
* Signaler un bug : <https://github.com/YunoHost-Apps/haste_ynh/issues>
@ -64,4 +47,4 @@ ou
sudo yunohost app upgrade haste -u https://github.com/YunoHost-Apps/haste_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
**Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/seejohnrun/haste-server/archive/7c65fb2f9b2e4b292e03c5d70957431bcc27d2c0.tar.gz
SOURCE_SUM=8d420e2b47a640b38230114551ddffe86489cb6607af0659740385e6a9e36ebd
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -25,7 +25,7 @@
},
"storage": {
"type": "file",
"path": "__DATA_PATH__"
"path": "__DATA_DIR__"
},
"documents": {
"about": "./about.md"

View file

@ -1,12 +1,12 @@
[Unit]
Description=Haste is an open-source pastebin software
Description=Haste: pastebin software
After=network.target syslog.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
WorkingDirectory=__INSTALL_DIR__
Environment="PATH=__ENV_PATH__"
ExecStart=__YNH_NPM__ start
StandardOutput=append:/var/log/__APP__/__APP__.log

View file

@ -1,11 +1,6 @@
#### Multi-user support
* Are LDAP and HTTP auth supported? **No**
* Can the app be used by multiple users? **Yes**
## `haste` command
This Haste package for Yunohost includes the [`haste` command](https://github.com/diethnis/standalones/blob/master/hastebin.sh), allowing you to share content from terminal:
This Haste package for YunoHost includes the [`haste` command](https://github.com/diethnis/standalones/blob/master/hastebin.sh), allowing you to share content from terminal:
```bash
cat something | haste

View file

@ -1,8 +1,3 @@
### Support multi-utilisateur
* L'authentification LDAP et HTTP est-elle prise en charge ? **Non**
* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui**
## `haste` command
Ce paquet de Haste pour YunoHost comprend une commande [`haste`](https://github.com/diethnis/standalones/blob/master/hastebin.sh), vous permettant de partager du contenu avec le terminal :

View file

@ -1,55 +0,0 @@
{
"name": "Haste",
"id": "haste",
"packaging_format": 1,
"description": {
"en": "Open-source pastebin allowing to upload texts",
"fr": "Pastebin open-source permettant de mettre en ligne du texte"
},
"version": "0.1.0~ynh13",
"url": "http://hastebin.com/",
"upstream": {
"license": "MIT",
"website": "http://hastebin.com/",
"demo": "http://hastebin.com/",
"userdoc": "https://hastebin.com/about.md",
"code": "https://github.com/seejohnrun/haste-server"
},
"license": "MIT",
"maintainer": {
"name": "eric_G",
"email": ""
},
"previous_maintainers": [{
"name": "mbugeia",
"email": "maxime.bugeia@gmail.com"
}],
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"help": {
"en": "Haste can only be installed in a root domain or subdomain",
"fr": "Haste ne peut être installé que dans un domaine racine ou un sous-domaine"
}
},
{
"name": "is_public",
"type": "boolean",
"help": {
"en": "If enabled, Haste will be accessible by people who do not have an account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, Haste sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
},
"default": true
}
]
}
}

58
manifest.toml Normal file
View file

@ -0,0 +1,58 @@
packaging_format = 2
id = "haste"
name = "Haste"
description.en = "Open-source pastebin allowing to upload texts"
description.fr = "Pastebin open-source permettant de mettre en ligne du texte"
version = "0.1.0~ynh14"
maintainers = ["eric_G"]
[upstream]
license = "MIT"
website = "http://hastebin.com/"
demo = "http://hastebin.com/"
userdoc = "https://hastebin.com/about.md"
code = "https://github.com/seejohnrun/haste-server"
[integration]
yunohost = ">= 11.1.16"
architectures = "all"
multi_instance = false
ldap = false
sso = true
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
help.en = "Haste can only be installed in a root domain or subdomain"
help.fr = "Haste ne peut être installé que dans un domaine racine ou un sous-domaine"
type = "domain"
full_domain = true
[install.init_main_permission]
help.en = "If enabled, Haste 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, Haste sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
type = "group"
default = "visitors"
[resources]
[resources.sources.main]
url = "https://github.com/seejohnrun/haste-server/archive/7c65fb2f9b2e4b292e03c5d70957431bcc27d2c0.tar.gz"
sha256 = "8d420e2b47a640b38230114551ddffe86489cb6607af0659740385e6a9e36ebd"
autoupdate.upstream = "https://github.com/seejohnrun/haste-server/"
autoupdate.strategy = "latest_github_commit"
[resources.ports]
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"

View file

@ -10,24 +10,6 @@
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 --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -37,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -52,10 +34,10 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP DATADIR DIRECTORY
# BACKUP DATA_DIR DIRECTORY
#=================================================
ynh_backup --src_path="$data_path" --is_big
ynh_backup --src_path="$data_dir" --is_big
#=================================================
# BACKUP BINARY

View file

@ -9,60 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
@ -77,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
ynh_change_url_nginx_config
#=================================================
# GENERIC FINALISATION
@ -110,13 +34,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,69 +9,13 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# 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="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS 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=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path_url --value=$path_url
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=2
# Find an available port
port=$(ynh_find_port --port=7777)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
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
ynh_setup_source --dest_dir=$install_dir
#=================================================
# NGINX CONFIGURATION
@ -86,7 +30,7 @@ ynh_add_nginx_config
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=10
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=10
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
@ -104,44 +48,28 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Installing $app..." --weight=5
pushd "$final_path"
pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install
popd
#=================================================
# CREATE DIRECTORY FOR DATA
#=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1
# Define app's data directory
data_path=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
# Create app folders
mkdir -p "$data_path"
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
#=================================================
# CONFIGURE HASTE
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.js" --destination="$final_path/config.js"
ynh_add_config --template="../conf/config.js" --destination="$install_dir/config.js"
# Replace ajax.googleapis by local file
cp ../sources/jquery.min.js "$final_path/static/jquery.min.js"
cp ../sources/jquery.min.js "$install_dir/static/jquery.min.js"
ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" --replace_string="jquery.min.js" --target_file="$final_path/static/index.html"
ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" --replace_string="jquery.min.js" --target_file="$install_dir/static/index.html"
#=================================================
# ADD HASTE AS A BINARY FILE
#=================================================
haste_url="${domain}${path_url}"
haste_url="${domain}${path}"
ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app"
#=================================================
@ -150,9 +78,9 @@ ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app"
# SECURE FILES AND DIRECTORIES
#=================================================
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x /usr/bin/$app
#=================================================
@ -182,23 +110,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,17 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#=================================================
# STANDARD REMOVE
#=================================================
@ -41,14 +30,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -73,17 +54,6 @@ ynh_script_progression --message="Removing various files..." --weight=1
ynh_secure_remove --file="/usr/bin/$app"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$data_path"
fi
#=================================================
# REMOVE NODEJS
#=================================================
@ -91,16 +61,6 @@ ynh_script_progression --message="Removing dependencies..." --weight=5
ynh_remove_nodejs
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,60 +9,15 @@
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_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=6
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC RESTORE
@ -78,14 +33,9 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_path" --not_mandatory
ynh_restore_file --origin_path="$data_dir" --not_mandatory
# Create app folders
mkdir -p "$data_path"
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
chown -R $app:www-data "$data_dir"
#=================================================
# RESTORE BINARY
@ -108,21 +58,13 @@ chown $app -R /var/log/$app
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Haste is a pastebin software" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=2
yunohost service add $app --description="Haste is a pastebin software" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
@ -132,13 +74,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -9,38 +9,12 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path_url)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# 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
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
@ -48,41 +22,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# If data_path doesn't exist, create it
if [ -z "$data_path" ]; then
data_path="/home/yunohost.app/${app}"
mkdir -p "$data_path"
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -92,7 +31,7 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=7
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="config.js"
ynh_setup_source --dest_dir="$install_dir" --keep="config.js"
fi
#=================================================
@ -117,7 +56,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
ynh_script_progression --message="Installing $app..." --weight=8
pushd "$final_path"
pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install
popd
@ -143,16 +82,16 @@ ynh_add_systemd_config
#=================================================
# Replace ajax.googleapis by local file
cp ../sources/jquery.min.js "$final_path/static/jquery.min.js"
cp ../sources/jquery.min.js "$install_dir/static/jquery.min.js"
ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" --replace_string="jquery.min.js" --target_file="$final_path/static/index.html"
ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" --replace_string="jquery.min.js" --target_file="$install_dir/static/index.html"
#=================================================
# UPGRADE HASTE BINARY
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
haste_url="${domain}${path_url}"
haste_url="${domain}${path}"
ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app"
#=================================================
@ -161,9 +100,9 @@ ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app"
# SECURE FILES AND DIRECTORIES
#=================================================
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x /usr/bin/$app
#=================================================
@ -180,13 +119,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
test_format = 1.0
[default]
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.0ea46c37.name = "Upgrade from #33"