1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00

Version 2 (#73)

* v2

* Auto-update README

* v2

* Auto-update README

* Update manifest.toml

* Update _common.sh

* Update manifest.toml

* Update tests.toml

* fix

* fix

* Update upgrade

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
This commit is contained in:
Éric Gaspar 2023-04-16 17:12:12 +02:00 committed by GitHub
parent ba4cd7f025
commit 3d83ceb5ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 181 additions and 993 deletions

View file

@ -1,83 +0,0 @@
Changelog
=========
## [0.12.1~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/46) - 2020-10-18
#### Changed
* [Update to Lutim 0.12.1](https://github.com/YunoHost-Apps/lutim_ynh/pull/52)
## [0.11.6~ynh4](https://github.com/YunoHost-Apps/lutim_ynh/pull/46) - 2020-04-25
#### Added
- [Add new badges](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/4e28257f0550378297789c77a5354b004100f5ae)
* [New reset actions](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/e1c90a7c1b2c0c66c4d7bfc8a8e2a221d5c817ab)
#### Fixed
- [Fix potential error on install](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/e481e03e0511787f297e10f85d6a54b3fedb5470)
#### Changed
- [Indentation](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/a934b7369842dfbdc45e7c1dfdf3483276d4c755)
- [Misc upgrade](https://github.com/YunoHost-Apps/lutim_ynh/pull/46/commits/750ea401950f4e8b3facfa7caa5bc2388b6a4272)
## [0.11.6~ynh3](https://github.com/YunoHost-Apps/lutim_ynh/pull/45) - 2020-03-12
#### Changed
- [ Fix migration to new permission system](https://github.com/YunoHost-Apps/lutim_ynh/pull/45/commits/e0d3764ffbcde3d354b7c27154f829cad8172e2e)
## [0.11.6~ynh2](https://github.com/YunoHost-Apps/lutim_ynh/pull/43) - 2020-01-04
#### Fixed
- [Fix config-panel](https://github.com/YunoHost-Apps/lutim_ynh/pull/43/commits/a549f8139737d0ed3f641a8b0425dfdeefb50ef4)
## [0.11.6~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/42) - 2020-01-02
#### Added
* [Set workers according to cpu](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/58e291949769d678ec48306199bcc03e3be20631)
- [Add changelog](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/b0859ab1612c22d210321d6302cad7872ec17abd)
#### Fixed
- [Fix cron tasks](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/dec8d0820fb46e984b2ca65e1012f5f737861965)
#### Changed
- [Update to last standard](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/5e5bf7c7a8f68b0768555005797ec3024a223299) [(twice)](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/51113ba7544991a3400abc9a78258ba594d58b4b)
- [Use toml for actions and config-panel](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/4f7bac24481138654e3e3128ba6637cdf8855855)
* [Update to 0.11.6](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/4b50a261fb4515aa2a32b7ca20c750c322bfd5c0)
## [0.11.5~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/35) - 2019-05-06
#### Changed
* [Update to Lutim 0.11.5](https://github.com/YunoHost-Apps/lutim_ynh/pull/35)
## [0.11.4~ynh3](https://github.com/YunoHost-Apps/lutim_ynh/pull/33) - 2019-02-18
#### Changed
- [Upgrade protected_regex](https://github.com/YunoHost-Apps/lutim_ynh/pull/33)
## [0.11.4~ynh2](https://github.com/YunoHost-Apps/lutim_ynh/pull/31) - 2019-02-03
#### Added
- [Add progression bar](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/6b63a2ce2feca4550e55f2404e8b18f13ef58fc7)
- [Changelog & html email](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/746d00174c3fde429f64b514d4f113b01780e701)
#### Fixed
- [Do not open port](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/0c2af89b610a420129588e62537bb248d7810777)
- [Delete dedicated user](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/f9d7f124f0966870004aa620ac4626dd8ebb19ff)
## [0.11.4~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/30) - 2019-01-21
#### Changed
* [Update to Lutim 0.11.4](https://github.com/YunoHost-Apps/lutim_ynh/pull/30/commits/0b3640581ce18b9f823baae7130ab0645f9f1e8e)
- [Update to last standart](https://github.com/YunoHost-Apps/lutim_ynh/pull/30/commits/9d37c8b9f50ef728ebe4a05031de4c70f76940b4)
## [0.10.4~ynh2](https://github.com/YunoHost-Apps/lutim_ynh/pull/29) - 2018-09-30
#### Added
* [Panel-config + actions fully tested](https://github.com/YunoHost-Apps/lutim_ynh/pull/29/commits/6cf6b6331170fd6f36575c9c06a17b11a9da66d0)

View file

@ -22,13 +22,6 @@ Images are indefinitely stored unless you request that they will be deleted at f
**Shipped version:** 0.12.1~ynh4
**Demo:** https://lut.im/
## Disclaimers / important information
## Configuration
Edit the file `/var/www/lutim/lutim.conf` to configure Lutim.
Then reload the lutim service.
## Documentation and resources
* Official app website: <https://lut.im>

View file

@ -22,13 +22,6 @@ Les images sont stockées indéfiniment à moins que vous ne demandiez qu'elles
**Version incluse :** 0.12.1~ynh4
**Démo :** https://lut.im/
## Avertissements / informations importantes
## Configuration
Éditez le fichier `/var/www/lutim/lutim.conf` pour configurer Lutim.
Rechargez ensuite le service Lutim.
## Documentations et ressources
* Site officiel de lapp : <https://lut.im>

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.12.1/lutim-0.12.1.tar.gz
SOURCE_SUM=141f142d47e3a8367e0c292304ddbecfc34b49ae7e561e2c3526000040318973
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,11 +1,11 @@
# Génération des statistiques. Tous les jours, à 5h.
0 5 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron stats
0 5 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron stats
# Suppression des adresses IP obsolètes. Tous les jours, à 6h.
0 6 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanbdd
0 6 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron cleanbdd
# Suppression des images dont le délai a expiré. Tous les jours, à 6h.
0 6 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanfiles
0 6 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron cleanfiles
# Vérification de l'occupation du dossier des images. Tous les jours, à 7h.
0 7 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron watch
0 7 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron watch

View file

@ -1,16 +1,50 @@
[Unit]
Description=Lutim: Image hosting and sharing service
Description=Lutim: image hosting and sharing service
After=network.target
[Service]
Type=forking
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
PIDFile=__FINALPATH__/script/hypnotoad.pid
WorkingDirectory=__INSTALL_DIR__/
PIDFile=__INSTALL_DIR__/script/hypnotoad.pid
ExecStart=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1
ExecStop=/usr/bin/carton exec hypnotoad -s script/lutim >> /var/log/lutim/production.log 2>&1
ExecReload=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1
# 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 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectClock=yes
ProtectHostname=yes
ProtectProc=invisible
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallArchitectures=native
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged
# 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

4
doc/ADMIN.md Normal file
View file

@ -0,0 +1,4 @@
## Configuration
Edit the file `__INSTALL_DIR__/lutim.conf` to configure Lutim.
Then reload the lutim service.

2
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1,2 @@
Éditez le fichier `__INSTALL_DIR__/lutim.conf` pour configurer Lutim.
Rechargez ensuite le service Lutim.

View file

@ -1,4 +0,0 @@
## Configuration
Edit the file `/var/www/lutim/lutim.conf` to configure Lutim.
Then reload the lutim service.

View file

@ -1,4 +0,0 @@
## Configuration
Éditez le fichier `/var/www/lutim/lutim.conf` pour configurer Lutim.
Rechargez ensuite le service Lutim.

View file

@ -1,66 +0,0 @@
{
"name": "Lutim",
"id": "lutim",
"packaging_format": 1,
"description": {
"en": "Anonymous image hosting service",
"fr": "Service d'hébergement anonyme d'images"
},
"version": "0.12.1~ynh4",
"url": "https://lut.im",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://lut.im",
"demo": "https://lut.im/",
"userdoc": "https://framagit.org/luc/lutim/wikis/home",
"code": "https://framagit.org/fiat-tux/hat-softwares/lutim"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "",
"email": ""
},
"previous_maintainers": [{
"name": "Maniack Crudelis et matlink",
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/lutim",
"default": "/lutim"
},
{
"name": "is_public",
"type": "boolean",
"default": false,
"help": {
"en": "If you set Lutim as public, everyone will be able to upload images and share them.<br>But even if not public, everyone can see an image from a link shared with your Lutim.",
"fr": "Si vous définissez Lutim comme public, tout le monde pourra télécharger des images et les partager.<br>Mais même si ce n'est pas public, tout le monde peut voir une image à partir d'un lien partagé avec votre Lutim."
}
},
{
"name": "always_encrypt",
"type": "boolean",
"ask": {
"en": "Force the encryption of images?",
"fr": "Forcer le chiffrement des images ?"
},
"default": true
}
]
}
}

64
manifest.toml Normal file
View file

@ -0,0 +1,64 @@
packaging_format = 2
id = "lutim"
name = "Lutim"
description.en = "Anonymous image hosting service"
description.fr = "Service d'hébergement anonyme d'images"
version = "0.12.1~ynh4"
maintainers = []
[upstream]
license = "AGPL-3.0-only"
website = "https://lut.im"
demo = "https://lut.im/"
userdoc = "https://framagit.org/luc/lutim/wikis/home"
code = "https://framagit.org/fiat-tux/hat-softwares/lutim"
[integration]
yunohost = ">= 11.1.17"
architectures = "all"
multi_instance = false
ldap = false
sso = false
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/lutim"
[install.init_main_permission]
help.en = "If you set Lutim as visitors, everyone will be able to upload images and share them.<br>But even if not public, everyone can see an image from a link shared with your Lutim."
help.fr = "Si vous définissez Lutim comme visitors, tout le monde pourra télécharger des images et les partager.<br>Mais même si ce n'est pas public, tout le monde peut voir une image à partir d'un lien partagé avec votre Lutim."
type = "group"
default = "visitors"
[install.always_encrypt]
ask.en = "Force the encryption of images?"
ask.fr = "Forcer le chiffrement des images ?"
type = "boolean"
default = true
[resources]
[resources.sources.main]
url = "https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.12.1/lutim-0.12.1.tar.gz"
sha256 = "141f142d47e3a8367e0c292304ddbecfc34b49ae7e561e2c3526000040318973"
[resources.ports]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "carton perlmagick libpq-dev shared-mime-info"

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="carton perlmagick libpq-dev shared-mime-info"
#=================================================
# PERSONAL HELPERS
#=================================================
@ -15,152 +12,10 @@ pkg_dependencies="carton perlmagick libpq-dev shared-mime-info"
# EXPERIMENTAL HELPERS
#=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
# | arg: -m --app_message= - The file with the content to send to the administrator.
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
ynh_send_readme_to_admin() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
local app_message
local recipients
local type
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
app_message="${app_message:-}"
recipients="${recipients:-root}"
type="${type:-install}"
# Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
# Subject base
local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
# Adapt the subject according to the type of mail required.
if [ "$type" = "backup" ]; then
mail_subject="$mail_subject has just been backup."
elif [ "$type" = "change_url" ]; then
mail_subject="$mail_subject has just been moved to a new URL!"
elif [ "$type" = "remove" ]; then
mail_subject="$mail_subject has just been removed!"
elif [ "$type" = "restore" ]; then
mail_subject="$mail_subject has just been restored!"
elif [ "$type" = "upgrade" ]; then
mail_subject="$mail_subject has just been upgraded!"
else # install
mail_subject="$mail_subject has just been installed!"
fi
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$(if [ -n "$app_message" ]
then
cat "$app_message"
else
echo "...No specific information..."
fi)
---
Automatic diagnosis data from YunoHost
__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
# Store the message into a file for further modifications.
echo "$mail_message" > mail_to_send
# If a html email is required. Apply html tags to the message.
if [ "$admin_mail_html" -eq 1 ]
then
# Insert 'br' tags at each ending of lines.
ynh_replace_string "$" "<br>" mail_to_send
# Insert starting HTML tags
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
# Keep tabulations
ynh_replace_string " " "\&#160;\&#160;" mail_to_send
ynh_replace_string "\t" "\&#160;\&#160;" mail_to_send
# Insert url links tags
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
# Insert pre tags
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
# Insert finishing HTML tags
echo -e "\n</body>\n</html>" >> mail_to_send
# Otherwise, remove tags to keep a plain text.
else
# Remove URL tags
ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
ynh_replace_string "__URL_TAG2__" ": " mail_to_send
# Remove PRE tags
ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
fi
# Define binary to use for mail command
if [ -e /usr/bin/bsd-mailx ]
then
local mail_bin=/usr/bin/bsd-mailx
else
local mail_bin=/usr/bin/mail.mailutils
fi
if [ "$admin_mail_html" -eq 1 ]
then
content_type="text/html"
else
content_type="text/plain"
fi
# Send the email to the recipients
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
}
#=================================================
ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
path_url=$(ynh_app_setting_get $app path)
# Load value of $path and $domain from the config if their not set
if [ -z $path ]; then
path=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
@ -190,10 +45,10 @@ ynh_maintenance_mode_ON () {
</html>" > "/var/www/html/maintenance.$app.html"
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
# Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ {
location ${path}_maintenance/ {
alias /var/www/html/ ;
try_files maintenance.$app.html =503;
@ -204,7 +59,7 @@ include conf.d/yunohost_panel.conf.inc;
# The current config file will redirect all requests to the root of the app.
# To keep the full path, we can use the following rewrite rule:
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
# rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect;
# The difference will be in the $1 at the end, which keep the following queries.
# But, if it works perfectly for a html request, there's an issue with any php files.
# This files are treated as simple files, and will be downloaded by the browser.
@ -214,16 +69,16 @@ include conf.d/yunohost_panel.conf.inc;
}
ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
path_url=$(ynh_app_setting_get $app path)
# Load value of $path and $domain from the config if their not set
if [ -z $path ]; then
path=$(ynh_app_setting_get $app path)
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
# Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.
echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
@ -236,143 +91,6 @@ ynh_maintenance_mode_OFF () {
systemctl reload nginx
}
#=================================================
# Create a changelog for an app after an upgrade from the file CHANGELOG.md.
#
# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
# | arg: -f --format= - Format in which the changelog will be printed
# markdown: Default format.
# html: Turn urls into html format.
# plain: Plain text changelog
# | arg: -o --output= - Output file for the changelog file (Default ./changelog)
# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
#
# The changelog is printed into the file ./changelog and ./changelog_lite
ynh_app_changelog () {
# Declare an array to define the options of this helper.
local legacy_args=foc
declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
local format
local output
local changelog
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
format=${format:-markdown}
output=${output:-changelog}
changelog=${changelog:-../CHANGELOG.md}
local original_changelog="$changelog"
local temp_changelog="changelog_temp"
local final_changelog="$output"
if [ ! -n "$original_changelog" ]
then
echo "No changelog available..." > "$final_changelog"
echo "No changelog available..." > "${final_changelog}_lite"
return 0
fi
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
# Get the line of the version to update to into the changelog
local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
# If there's no entry for this version yet into the changelog
# Get the first available version
if [ -z "$update_version_line" ]
then
update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
fi
# Get the length of the complete changelog.
local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
# Cut the file before the version to update to.
tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
# Get the length of the troncated changelog.
changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
# Get the line of the current version into the changelog
# Keep only the last line found
local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
# If there's no entry for this version into the changelog
# Get the last available version
if [ -z "$current_version_line" ]
then
current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
fi
# Cut the file before the current version.
# Then grep the previous version into the changelog to get the line number of the previous version
local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
"$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
# If there's no previous version into the changelog
# Go until the end of the changelog
if [ -z "$previous_version_line" ]
then
previous_version_line=$changelog_length
fi
# Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
if [ "$format" = "html" ]
then
# Replace markdown links by html links
ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
elif [ "$format" = "plain" ]
then
# Change title format.
ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
# Change modifications lines format.
ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
fi
# else markdown. As the file is already in markdown, nothing to do.
# Keep only important changes into the changelog
# Remove all minor changes
sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
# Remove all blank lines (to keep a clear workspace)
sed --in-place '/^$/d' "${final_changelog}_lite"
# Add a blank line at the end
echo "" >> "${final_changelog}_lite"
# Clean titles if there's no significative changes
local line
local previous_line=""
while read line <&3
do
if [ -n "$previous_line" ]
then
# Remove the line if it's a title or a blank line, and the previous one was a title as well.
if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
then
ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
fi
fi
previous_line="$line"
done 3< "${final_changelog}_lite"
# Remove all blank lines again
sed --in-place '/^$/d' "${final_changelog}_lite"
# Restore changelog format with blank lines
ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
# Remove the 2 first blank lines
sed --in-place '1,2d' "${final_changelog}_lite"
# Add a blank line at the end
echo "" >> "${final_changelog}_lite"
# If changelog are empty, add an info
if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
then
echo "No changes from the changelog..." > "$final_changelog"
fi
if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
then
echo "No significative changes from the changelog..." > "${final_changelog}_lite"
fi
}
#=================================================

View file

@ -10,23 +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)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -36,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

View file

@ -9,73 +9,15 @@
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=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=20
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# 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
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Activating maintenance mode..."
path_url=$old_path
path=$old_path
domain=$old_domain
ynh_maintenance_mode_ON
#=================================================
# 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
#=================================================
@ -90,46 +32,7 @@ ynh_systemd_action --service_name=$app --action="stop"
#=================================================
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
#=================================================
# UPDATE SSOWAT
#=================================================
ynh_script_progression --message="Reconfiguring SSOwat..."
if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image
then
# If the app is private, viewing images stays publicly accessible.
if [ "$new_path" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex.
new_path=""
fi
# Modify the domain to be used in a regex
domain_regex=$(echo "$new_domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$"
fi
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
@ -137,7 +40,7 @@ fi
# REPLACE THE PATH IN THE CONFIG OF LUTIM
#=================================================
ynh_replace_string --match_string="\(^ *prefix.*=> '\).*" --replace_string="\1$new_path'," --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string="\(^ *prefix.*=> '\).*" --replace_string="\1$new_path'," --target_file="$install_dir/lutim.conf"
#=================================================
# GENERIC FINALISATION
@ -149,19 +52,11 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Disabling maintenance mode..."
path_url=$old_path
path=$old_path
domain=$old_domain
ynh_maintenance_mode_OFF

View file

@ -9,48 +9,16 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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
always_encrypt=$YNH_APP_ARG_ALWAYS_ENCRYPT
app=$YNH_APP_INSTANCE_NAME
secret=$(ynh_string_random)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2
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 --value=$path_url
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt
ynh_app_setting_set --app=$app --key=secret --value="$secret"
@ -59,44 +27,16 @@ ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=3
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=60
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# 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..."
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"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# NGINX CONFIGURATION
@ -114,10 +54,10 @@ ynh_add_nginx_config
ynh_script_progression --message="Adding a configuration file..." --weight=2
workers="$(( $(nproc) * 2 ))"
ynh_add_config --template="../conf/lutim.conf.template" --destination="$final_path/lutim.conf"
ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
chmod 400 "$final_path/lutim.conf"
chown $app:$app "$final_path/lutim.conf"
chmod 400 "$install_dir/lutim.conf"
chown $app:$app "$install_dir/lutim.conf"
#=================================================
# SETUP HOOKS FILE
@ -131,7 +71,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
#=================================================
ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
chmod +x $final_path/script/lutim
chmod +x $install_dir/script/lutim
#=================================================
# INSTALL LUTIM WITH CARTON
@ -139,16 +79,16 @@ chmod +x $final_path/script/lutim
ynh_script_progression --message="Installing $app with Carton..." --weight=60
mkdir -p /var/log/$app/
(cd $final_path
(cd $install_dir
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
# Use a perl path adapted to the system architecture
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
arch_dir=$(ls -1 $install_dir/local/lib/perl5/ | grep linux-gnu)
if [ "$?" -ne 0 ]
then
ynh_die --message="Unable to find the perl directory for your architecture."
fi
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$final_path/script/lutim"
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$install_dir/script/lutim"
#=================================================
# SETUP LOG FILE
@ -157,7 +97,7 @@ ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --t
# Making log a symbolic link to /var/log
touch /var/log/$app/production.log
chown $app -R /var/log/$app
ln -s /var/log/$app/production.log "$final_path/log/production.log"
ln -s /var/log/$app/production.log "$install_dir/log/production.log"
#=================================================
# SETUP SYSTEMD
@ -182,7 +122,7 @@ ynh_use_logrotate
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="$final_path/log/production.log"
yunohost service add $app --log="$install_dir/log/production.log"
#=================================================
# START SYSTEMD SERVICE
@ -194,61 +134,11 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="
ynh_systemd_action --action=stop
# Set right permissions on new files created at first start
chown -R $app:$app $final_path
chown -R $app:$app $install_dir
# Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
ynh_permission_update --permission="main" --add="visitors"
# This is a fake permission without any URL.
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
# We can't use a real permission for now because the actual permision system doesn't support regex.
ynh_permission_create --permission="upload images" --allowed="visitors"
if [ $is_public -eq 0 ]
then
# If the app is private, viewing images stays publicly accessible.
if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex.
path_url=""
fi
# Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
# If the app is not public, then the "visitors" group doesn't have this permission
ynh_permission_update --permission="upload images" --remove="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
# Get main domain and buid the URL of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo "You can find a config file at $final_path/lutim.conf
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,16 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
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)
#=================================================
# STANDARD REMOVE
#=================================================
@ -48,14 +38,6 @@ ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# 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
#=================================================
@ -64,14 +46,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=20
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
@ -82,16 +56,6 @@ ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,72 +10,21 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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=2
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)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Activating maintenance mode..." --weight=2
ynh_maintenance_mode_ON
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# 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..."
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:$app "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=60
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# RESTORE THE NGINX CONFIGURATION
@ -116,7 +65,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="$final_path/log/production.log"
yunohost service add $app --log="$install_dir/log/production.log"
#=================================================
# START SYSTEMD SERVICE
@ -137,26 +86,9 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Disabling maintenance mode..." --weight=7
ynh_maintenance_mode_OFF
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo "You can find a config file at $final_path/lutim.conf
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,52 +9,12 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=4
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get --app=$app --key=port)
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
secret=$(ynh_app_setting_get --app=$app --key=secret)
overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings)
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd)
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
# Optional parameters from config-panel feature
antiflood=$(ynh_app_setting_get --app=$app --key=antiflood)
delay=$(ynh_app_setting_get --app=$app --key=delay)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking 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=15
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
@ -76,94 +36,39 @@ ynh_systemd_action --service_name=$app --action="stop"
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris)
# Unused with the permission system
if [ ! -z "$skipped_uris" ]; then
ynh_app_setting_delete --app=$app --key=skipped_uris
fi
# Create the permission "upload images" only if it doesn't exist.
if ! ynh_permission_exists --permission="upload images"
then
# This is a fake permission without any URL.
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
# We can't use a real permission for now because the actual permision system doesn't support regex.
ynh_permission_create --permission="upload images" --allowed="visitors"
if [ $is_public -eq 0 ]
then
# If the app is private, viewing images stays publicly accessible.
if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex.
path_url=""
fi
# Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
# If the app is not public, then the "visitors" group doesn't have this permission
ynh_permission_update --permission="upload images" --remove="visitors"
fi
fi
# if final_path isn't set, which can happens with old scripts, set final_path.
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# Fix always_encrypt as a boolean
if [ "$always_encrypt" = "Yes" ]; then
if [ "${always_encrypt:-}" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=always_encrypt --value=1
always_encrypt=1
elif [ "$always_encrypt" = "No" ]; then
elif [ "${always_encrypt:-}" = "No" ]; then
ynh_app_setting_set --app=$app --key=always_encrypt --value=0
always_encrypt=0
fi
# If overwrite_settings doesn't exist, create it
if [ -z "$overwrite_settings" ]; then
if [ -z "${overwrite_settings:-}" ]; then
overwrite_settings=1
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
if [ -z "${overwrite_nginx:-}" ]; then
overwrite_nginx=1
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi
# If overwrite_systemd doesn't exist, create it
if [ -z "$overwrite_systemd" ]; then
if [ -z "${overwrite_systemd:-}" ]; then
overwrite_systemd=1
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd
fi
# If secret doesn't exist, create it
if [ -z "$secret" ]; then
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2)
if [ -z "${secret:-}" ]; then
secret=$(grep "secrets *=>" "$install_dir/lutim.conf" | cut -d\' -f2)
ynh_app_setting_set --app=$app --key=secret --value=$secret
fi
# Close opened port
if yunohost firewall list | grep -q "\- $port$"
then
ynh_exec_quiet yunohost firewall disallow TCP $port
fi
# Replace skipped_uris by unprotected_uris for the migration to the new permission system.
ynh_app_setting_delete --app=$app --key=skipped_uris
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#=================================================
# 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"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -173,19 +78,11 @@ then
ynh_script_progression --message="Upgrading source files..."
# 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"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=9
ynh_install_app_dependencies $pkg_dependencies
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
@ -209,21 +106,21 @@ ynh_script_progression --message="Reconfiguring $app..."
if [ $overwrite_settings -eq 1 ]
then
workers="$(( $(nproc) * 2 ))"
ynh_add_config --template="../conf/lutim.conf.template" --destination="$final_path/lutim.conf"
ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
chmod 400 "$final_path/lutim.conf"
chown $app:$app "$final_path/lutim.conf"
chmod 400 "$install_dir/lutim.conf"
chown $app:$app "$install_dir/lutim.conf"
# Optional parameters from config-panel feature
if [ -n "$antiflood" ]; then
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$install_dir/lutim.conf"
# Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$install_dir/lutim.conf"
fi
fi
if [ -n "$delay" ]; then
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$install_dir/lutim.conf"
fi
fi
@ -247,8 +144,8 @@ ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading $app with Carton..." --weight=4
pushd "$final_path"
ynh_secure_remove --file="$final_path/local"
pushd "$install_dir"
#REMOVEME? ynh_secure_remove --file="$install_dir/local"
carton install --without=mysql --without=htpasswd --without=test
popd
fi
@ -280,7 +177,7 @@ chown $app -R /var/log/$app
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="$final_path/log/production.log"
yunohost service add $app --log="$install_dir/log/production.log"
#=================================================
# START SYSTEMD SERVICE
@ -289,44 +186,12 @@ ynh_script_progression --message="Starting a systemd service..." --weight=4
ynh_systemd_action --service_name=$app --action="start" --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Disabling maintenance mode..." --weight=7
ynh_maintenance_mode_OFF
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
# Build the changelog
ynh_app_changelog || true
echo "You can find a config file at $final_path/lutim.conf
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__.
---
Changelog since your last upgrade:
$(cat changelog)" > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade
#=================================================
# END OF SCRIPT
#=================================================

15
tests.toml Normal file
View file

@ -0,0 +1,15 @@
test_format = 1.0
[default]
# -------------------------------
# Default args to use for install
# -------------------------------
args.always_encrypt=1
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.ec8858ed0d054049a0c8f46c6126ee8ae0798e8f.name = "Upgrade from 22 May 2020"