mirror of
https://github.com/YunoHost-Apps/distbin_ynh.git
synced 2024-09-03 18:26:10 +02:00
commit
f982ae9867
20 changed files with 294 additions and 144 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
||||
*.test
|
||||
.gitignore
|
|
@ -1,7 +0,0 @@
|
|||
language: python
|
||||
|
||||
before_install:
|
||||
- git clone https://github.com/YunoHost/package_linter /tmp/package_linter
|
||||
|
||||
script:
|
||||
- /tmp/package_linter/package_linter.py ./
|
60
README.md
60
README.md
|
@ -1,55 +1,51 @@
|
|||
<!--
|
||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||
It shall NOT be edited by hand.
|
||||
-->
|
||||
|
||||
# Distbin for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/distbin)  
|
||||
[](https://install-app.yunohost.org/?app=distbin)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *This package allows you to install Distbin quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||
|
||||
## Overview
|
||||
|
||||
A distributed pastebin. i.e. it is a service where anyone can post things on the web, and others can react by posting anywhere else on the web (including here).
|
||||
|
||||
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.3.0
|
||||
### Features
|
||||
|
||||
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
|
||||
- Laboris nisi ut aliquip ex ea commodo consequat ;
|
||||
- Duis aute irure dolor in reprehenderit in voluptate ;
|
||||
- Velit esse cillum dolore eu fugiat nulla pariatur ;
|
||||
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
|
||||
|
||||
|
||||
**Shipped version:** 1.3.0~ynh9
|
||||
|
||||
**Demo:** https://distbin.com/
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||

|
||||
|
||||
## Demo
|
||||
## Disclaimers / important information
|
||||
|
||||
* [Official demo](https://distbin.com/)
|
||||
* No configuration parameters available for now.
|
||||
|
||||
## Configuration
|
||||
|
||||
No configuration parameters available for now.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-user support
|
||||
|
||||
LDAP and HTTP are not supported.
|
||||
|
||||
The app can be used by multiple users, anonymously.
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/distbin/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/distbin/)
|
||||
|
||||
## Limitations
|
||||
|
||||
* No known limitations.
|
||||
|
||||
## Links
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: https://distbin.com/about
|
||||
* Upstream app code repository: https://github.com/gobengo/distbin
|
||||
* YunoHost documentation for this app: https://yunohost.org/app_distbin
|
||||
* Report a bug: https://github.com/YunoHost-Apps/distbin_ynh/issues
|
||||
* App website: https://distbin.com/about
|
||||
* Upstream app repository: https://github.com/gobengo/distbin
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
## Developer info
|
||||
|
||||
|
@ -61,3 +57,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/distbin_ynh/tree/test
|
|||
or
|
||||
sudo yunohost app upgrade distbin -u https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**More info regarding app packaging:** https://yunohost.org/packaging_apps
|
57
README_fr.md
Normal file
57
README_fr.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Distbin pour YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/distbin)  
|
||||
[](https://install-app.yunohost.org/?app=distbin)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *Ce package vous permet d'installer Distbin 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.*
|
||||
|
||||
## Vue d'ensemble
|
||||
|
||||
A distributed pastebin. i.e. it is a service where anyone can post things on the web, and others can react by posting anywhere else on the web (including here).
|
||||
|
||||
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.
|
||||
|
||||
### Features
|
||||
|
||||
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
|
||||
- Laboris nisi ut aliquip ex ea commodo consequat ;
|
||||
- Duis aute irure dolor in reprehenderit in voluptate ;
|
||||
- Velit esse cillum dolore eu fugiat nulla pariatur ;
|
||||
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
|
||||
|
||||
|
||||
**Version incluse :** 1.3.0~ynh9
|
||||
|
||||
**Démo :** https://distbin.com/
|
||||
|
||||
## Captures d'écran
|
||||
|
||||

|
||||
|
||||
## Avertissements / informations importantes
|
||||
|
||||
* No configuration parameters available for now.
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l'app : https://distbin.com/about
|
||||
* Dépôt de code officiel de l'app : https://github.com/gobengo/distbin
|
||||
* Documentation YunoHost pour cette app : https://yunohost.org/app_distbin
|
||||
* Signaler un bug : https://github.com/YunoHost-Apps/distbin_ynh/issues
|
||||
|
||||
## Informations pour les développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/distbin_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade distbin -u https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
|
|
@ -1,13 +1,8 @@
|
|||
# See here for more information
|
||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||
|
||||
# Move this file from check_process.default to check_process when you have filled it.
|
||||
|
||||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
is_public=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -26,6 +21,8 @@
|
|||
upgrade=1 from_commit=cdec64125b179f6b19470ceb8379225ed03c10a8
|
||||
# 1.3.0~ynh7
|
||||
upgrade=1 from_commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a
|
||||
# 1.3.0~ynh8
|
||||
upgrade=1 from_commit=e53a85de775501b13d8ef9c546d6b523c0a99e4f
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
|
@ -44,3 +41,5 @@ Notification=all
|
|||
name=1.3.0~ynh6
|
||||
; commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a
|
||||
name=1.3.0~ynh7
|
||||
; commit=e53a85de775501b13d8ef9c546d6b523c0a99e4f
|
||||
name=1.3.0~ynh8
|
||||
|
|
|
@ -5,7 +5,7 @@ PATH=__YNH_NODE_LOAD_PATH__
|
|||
PORT=__PORT__
|
||||
|
||||
# The directory where is store the database
|
||||
DB_DIR=__FINALPATH__/distbin-db
|
||||
DB_DIR=__DATADIR__/distbin-db
|
||||
|
||||
# The external URL
|
||||
EXTERNAL_URL=https://__DOMAIN____PATH__/
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
proxy_pass http://127.0.0.1:__PORT__/;
|
||||
proxy_pass_request_headers on;
|
||||
proxy_redirect ~^/(.*) $scheme://$http_host__PATH__/$1;
|
||||
|
|
|
@ -6,9 +6,42 @@ After=network.target
|
|||
Type=simple
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
EnvironmentFile=__FINALPATH__/.env
|
||||
WorkingDirectory=__FINALPATH__/
|
||||
ExecStart=/bin/sh -c 'node ./dist/bin/server >> /var/log/__APP__/__APP__.log 2>&1'
|
||||
ExecStart=__YNH_NODE__ __FINALPATH__/dist/bin/server >>
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
EnvironmentFile=__FINALPATH__/.env
|
||||
|
||||
# Sandboxing options to harden security
|
||||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
# .. but this should be a good baseline
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
DevicePolicy=closed
|
||||
ProtectSystem=full
|
||||
ProtectControlGroups=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
|
||||
# Denying access to capabilities that should not be relevant for webapps
|
||||
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
|
||||
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
|
||||
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
|
||||
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
|
||||
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
|
||||
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
|
||||
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
|
||||
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
|
||||
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
|
||||
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
11
doc/DESCRIPTION.md
Normal file
11
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
A distributed pastebin. i.e. it is a service where anyone can post things on the web, and others can react by posting anywhere else on the web (including here).
|
||||
|
||||
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.
|
||||
|
||||
### Features
|
||||
|
||||
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
|
||||
- Laboris nisi ut aliquip ex ea commodo consequat ;
|
||||
- Duis aute irure dolor in reprehenderit in voluptate ;
|
||||
- Velit esse cillum dolore eu fugiat nulla pariatur ;
|
||||
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
|
1
doc/DISCLAIMER.md
Normal file
1
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1 @@
|
|||
* No configuration parameters available for now.
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
BIN
doc/screenshots/screenshot.PNG
Normal file
BIN
doc/screenshots/screenshot.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
|
@ -6,14 +6,20 @@
|
|||
"en": "Distributed pastebin with ActivityPub.",
|
||||
"fr": "Pastebin distribué utilisant le protocole ActivityPub."
|
||||
},
|
||||
"version": "1.3.0~ynh8",
|
||||
"url": "https://distbin.com/",
|
||||
"version": "1.3.0~ynh9",
|
||||
"url": "https://distbin.com",
|
||||
"upstream": {
|
||||
"license": "Apache-2.0",
|
||||
"website": "https://distbin.com/about",
|
||||
"demo": "https://distbin.com/",
|
||||
"code": "https://github.com/gobengo/distbin"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"maintainer": {
|
||||
"name": "yalh76"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.1.3"
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
|
@ -23,8 +29,7 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"example": "example.com"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
|
|
|
@ -29,6 +29,7 @@ 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)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -41,6 +42,12 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$datadir" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
|
|
@ -140,6 +140,7 @@ ynh_script_progression --message="Starting a systemd service..."
|
|||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Distbin Service"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
sleep 60
|
||||
fi
|
||||
|
|
|
@ -73,7 +73,7 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
|||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -98,27 +98,6 @@ ynh_add_nginx_config
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# CREATE LOG FOLDER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating log folder..."
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chown -R "$app":"$app" "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# CREATE DB FOLDER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating DB folder..."
|
||||
|
||||
mkdir -p "$final_path/distbin-db"
|
||||
mkdir -p "$final_path/distbin-db/activities"
|
||||
mkdir -p "$final_path/distbin-db/inbox"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# INSTALLING DISTBIN
|
||||
#=================================================
|
||||
|
@ -126,19 +105,46 @@ ynh_script_progression --message="Installing Distbin..."
|
|||
|
||||
pushd $final_path
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts
|
||||
ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm run build
|
||||
sudo -u $app cp -af package* dist/
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
|
||||
ynh_exec_warn_less ynh_exec_as $app cp -af package* dist/
|
||||
popd
|
||||
|
||||
pushd $final_path/dist
|
||||
ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# CREATE LOG DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating log folder..."
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
chmod 750 "/var/log/$app"
|
||||
chmod -R o-rwx "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..."
|
||||
|
||||
datadir=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
mkdir -p "$datadir/distbin-db"
|
||||
mkdir -p "$datadir/distbin-db/activities"
|
||||
mkdir -p "$datadir/distbin-db/inbox"
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a config file..."
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
|
||||
|
||||
|
@ -177,6 +183,7 @@ ynh_script_progression --message="Starting a systemd service..."
|
|||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Distbin Service"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
sleep 60
|
||||
fi
|
||||
|
|
|
@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -42,13 +43,12 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
|||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
|
@ -58,6 +58,17 @@ ynh_script_progression --message="Removing app main directory..."
|
|||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# 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..."
|
||||
ynh_secure_remove --file="$datadir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -67,17 +78,18 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
|
|||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE THE LOG FILES
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# Remove the log files
|
||||
|
|
|
@ -30,14 +30,13 @@ 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)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
|
@ -56,7 +55,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
|
@ -69,12 +68,28 @@ chmod 750 "$final_path"
|
|||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||
|
||||
mkdir -p $datadir
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
|
||||
#=================================================
|
||||
# CREATE LOG FOLDER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating log folder..."
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
chmod 750 "/var/log/$app"
|
||||
chmod -R o-rwx "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
|
@ -96,6 +111,13 @@ ynh_script_progression --message="Restoring the systemd configuration..."
|
|||
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..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -109,17 +131,11 @@ yunohost service add $app --description="Distributed pastebin" --log="/var/log/$
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Distbin Service"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -20,6 +20,7 @@ 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)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -28,18 +29,6 @@ ynh_script_progression --message="Checking version..."
|
|||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -64,13 +53,54 @@ ynh_script_progression --message="Stopping a systemd service..."
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped Distbin Service"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Creating storage folder..."
|
||||
|
||||
if [ -z "$datadir" ]; then
|
||||
datadir=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
fi
|
||||
|
||||
mkdir -p "$datadir/distbin-db/"
|
||||
|
||||
# Move old db
|
||||
if [ -d "$final_path/db/" ]; then
|
||||
rsync -arz "$final_path/db/" "$datadir/distbin-db/" --delete-after --remove-source-files
|
||||
ynh_secure_remove --file="$final_path/db"
|
||||
fi
|
||||
|
||||
# Move old db
|
||||
if [ -d "$final_path/distbin-db/" ]; then
|
||||
if [ -d "$final_path/distbin-db/db/" ]; then
|
||||
rsync -arz "$final_path/distbin-db/db/" "$datadir/distbin-db/" --delete-after --remove-source-files
|
||||
ynh_secure_remove --file="$final_path/distbin-db/db"
|
||||
fi
|
||||
rsync -arz "$final_path/distbin-db/" "$datadir/distbin-db/" --delete-after --remove-source-files
|
||||
ynh_secure_remove --file="$final_path/distbin-db"
|
||||
fi
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:$app "$datadir"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -112,23 +142,11 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
|||
ynh_script_progression --message="Creating log folder..."
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
|
||||
chmod 750 "/var/log/$app"
|
||||
chmod -R o-rwx "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# CREATE STORAGE FOLDER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating storage folder..."
|
||||
|
||||
DIRECTORY="$final_path/db"
|
||||
#Move old db
|
||||
if [ -d "$DIRECTORY" ]; then
|
||||
mv "$final_path/db" "$final_path/distbin-db"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# MAKE UPGRADE
|
||||
#=================================================
|
||||
|
@ -136,13 +154,13 @@ ynh_script_progression --message="Making upgrade..."
|
|||
|
||||
pushd $final_path
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts
|
||||
ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm run build
|
||||
sudo -u $app cp -af package* dist/
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
|
||||
ynh_exec_warn_less ynh_exec_as $app cp -af package* dist/
|
||||
popd
|
||||
|
||||
pushd $final_path/dist
|
||||
ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -186,6 +204,7 @@ yunohost service add $app --description="Distributed pastebin" --log="/var/log/$
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started Distbin Service"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
sleep 60
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue