mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
commit
32f7842c54
25 changed files with 144 additions and 1139 deletions
11
README.md
11
README.md
|
@ -5,7 +5,8 @@ It shall NOT be edited by hand.
|
||||||
|
|
||||||
# Lstu for YunoHost
|
# Lstu for YunoHost
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/lstu)  
|
[](https://dash.yunohost.org/appci/app/lstu)  
|
||||||
|
|
||||||
[](https://install-app.yunohost.org/?app=lstu)
|
[](https://install-app.yunohost.org/?app=lstu)
|
||||||
|
|
||||||
*[Lire ce readme en français.](./README_fr.md)*
|
*[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
|
||||||
Lstu means Let's Shorten That URL.
|
Lstu means Let's Shorten That URL.
|
||||||
|
|
||||||
|
|
||||||
**Shipped version:** 0.26.0~ynh2
|
**Shipped version:** 0.26.0~ynh3
|
||||||
|
|
||||||
**Demo:** https://lstu.fr
|
**Demo:** https://lstu.fr
|
||||||
|
|
||||||
|
@ -26,12 +27,6 @@ Lstu means Let's Shorten That URL.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Disclaimers / important information
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH.
|
|
||||||
|
|
||||||
## Documentation and resources
|
## Documentation and resources
|
||||||
|
|
||||||
* Official app website: <https://lstu.fr>
|
* Official app website: <https://lstu.fr>
|
||||||
|
|
29
README_fr.md
29
README_fr.md
|
@ -5,38 +5,33 @@ It shall NOT be edited by hand.
|
||||||
|
|
||||||
# Lstu pour YunoHost
|
# Lstu pour YunoHost
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/lstu)  
|
[](https://dash.yunohost.org/appci/app/lstu)  
|
||||||
|
|
||||||
[](https://install-app.yunohost.org/?app=lstu)
|
[](https://install-app.yunohost.org/?app=lstu)
|
||||||
|
|
||||||
*[Read this readme in english.](./README.md)*
|
*[Read this readme in english.](./README.md)*
|
||||||
|
|
||||||
> *Ce package vous permet d'installer Lstu rapidement et simplement sur un serveur YunoHost.
|
> *Ce package vous permet d’installer Lstu 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.*
|
Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.*
|
||||||
|
|
||||||
## Vue d'ensemble
|
## Vue d’ensemble
|
||||||
|
|
||||||
Raccourcisseur d'URL
|
Raccourcisseur d'URL
|
||||||
|
|
||||||
|
|
||||||
**Version incluse :** 0.26.0~ynh2
|
**Version incluse :** 0.26.0~ynh3
|
||||||
|
|
||||||
**Démo :** https://lstu.fr
|
**Démo :** https://lstu.fr
|
||||||
|
|
||||||
## Captures d'écran
|
## Captures d’écran
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Avertissements / informations importantes
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu.conf` avec SSH.
|
|
||||||
|
|
||||||
## Documentations et ressources
|
## Documentations et ressources
|
||||||
|
|
||||||
* Site officiel de l'app : <https://lstu.fr>
|
* Site officiel de l’app : <https://lstu.fr>
|
||||||
* Documentation officielle de l'admin : <https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home>
|
* Documentation officielle de l’admin : <https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home>
|
||||||
* Dépôt de code officiel de l'app : <https://framagit.org/fiat-tux/hat-softwares/lstu>
|
* Dépôt de code officiel de l’app : <https://framagit.org/fiat-tux/hat-softwares/lstu>
|
||||||
* Documentation YunoHost pour cette app : <https://yunohost.org/app_lstu>
|
* Documentation YunoHost pour cette app : <https://yunohost.org/app_lstu>
|
||||||
* Signaler un bug : <https://github.com/YunoHost-Apps/lstu_ynh/issues>
|
* Signaler un bug : <https://github.com/YunoHost-Apps/lstu_ynh/issues>
|
||||||
|
|
||||||
|
@ -52,4 +47,4 @@ ou
|
||||||
sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug
|
sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
|
**Plus d’infos sur le packaging d’applications :** <https://yunohost.org/packaging_apps>
|
77
actions.json
77
actions.json
|
@ -1,77 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": "public_private",
|
|
||||||
"name": "Move to public or private",
|
|
||||||
"command": "/bin/bash scripts/actions/public_private",
|
|
||||||
"user": "root",
|
|
||||||
"accepted_return_codes": [
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"description": {
|
|
||||||
"en": "Change the public access of the app.",
|
|
||||||
"fr": "Modifiez l'accès public de l'application."
|
|
||||||
},
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"type": "boolean",
|
|
||||||
"ask": {
|
|
||||||
"en": "Is it a public app?",
|
|
||||||
"fr": "Est-ce une application publique ?"
|
|
||||||
},
|
|
||||||
"default": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "change_password",
|
|
||||||
"name": "Change the admin password",
|
|
||||||
"command": "/bin/bash scripts/actions/change_password",
|
|
||||||
"user": "root",
|
|
||||||
"accepted_return_codes": [
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"description": {
|
|
||||||
"en": "Change the admin password of the app.",
|
|
||||||
"fr": "Change le mot de passe administrateur de l'app."
|
|
||||||
},
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "password",
|
|
||||||
"type": "password",
|
|
||||||
"ask": {
|
|
||||||
"en": "New password",
|
|
||||||
"fr": "Nouveau mot de passe"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "change_theme",
|
|
||||||
"name": "Change the theme",
|
|
||||||
"command": "/bin/bash scripts/actions/change_theme",
|
|
||||||
"user": "root",
|
|
||||||
"accepted_return_codes": [
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"description": {
|
|
||||||
"en": "Change the theme of the app.",
|
|
||||||
"fr": "Change le thème de l'app."
|
|
||||||
},
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "theme",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a theme",
|
|
||||||
"fr": "Choisissez un theme"
|
|
||||||
},
|
|
||||||
"choices": [
|
|
||||||
"default",
|
|
||||||
"milligram"
|
|
||||||
],
|
|
||||||
"default": "milligram"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,27 +0,0 @@
|
||||||
;; Test complet
|
|
||||||
; Manifest
|
|
||||||
domain="domain.tld"
|
|
||||||
path="/path"
|
|
||||||
is_public=1
|
|
||||||
theme="milligram"
|
|
||||||
password="1Strong-Password"
|
|
||||||
; Checks
|
|
||||||
pkg_linter=1
|
|
||||||
setup_sub_dir=1
|
|
||||||
setup_root=1
|
|
||||||
setup_nourl=0
|
|
||||||
setup_private=1
|
|
||||||
setup_public=1
|
|
||||||
upgrade=1
|
|
||||||
#Merge pull request #52
|
|
||||||
upgrade=1 from_commit=469fb267ebc496d2c63b10de35aaf3493ce8124f
|
|
||||||
backup_restore=1
|
|
||||||
multi_instance=1
|
|
||||||
port_already_use=0
|
|
||||||
change_url=1
|
|
||||||
;;; Options
|
|
||||||
Email=
|
|
||||||
Notification=none
|
|
||||||
;;; Upgrade options
|
|
||||||
; commit=469fb267ebc496d2c63b10de35aaf3493ce8124f
|
|
||||||
name=Merge pull request #52
|
|
|
@ -1,7 +0,0 @@
|
||||||
SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.26-0/lstu-0.26-0.tar.gz
|
|
||||||
SOURCE_SUM=323c81b4cb04a97eda7cb37b2a63d16e808591fd46eb4326f6619200ce742960
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
||||||
SOURCE_FILENAME=
|
|
||||||
SOURCE_EXTRACT=true
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
__FINALPATH__/log/production.log {
|
__INSTALL_DIR__/log/production.log {
|
||||||
# Effectue une rotation des logs tout les mois
|
# Effectue une rotation des logs tout les mois
|
||||||
monthly
|
monthly
|
||||||
# Ou si le fichier de log dépasse 100Mo
|
# Ou si le fichier de log dépasse 100Mo
|
||||||
|
|
|
@ -7,7 +7,7 @@ Type=forking
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
WorkingDirectory=__FINALPATH__
|
WorkingDirectory=__INSTALL_DIR__
|
||||||
ExecStart=/usr/bin/carton exec script/application minion worker
|
ExecStart=/usr/bin/carton exec script/application minion worker
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
|
@ -10,8 +10,8 @@ User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
WorkingDirectory=__FINALPATH__
|
WorkingDirectory=__INSTALL_DIR__
|
||||||
PIDFile=__FINALPATH__/script/hypnotoad.pid
|
PIDFile=__INSTALL_DIR__/script/hypnotoad.pid
|
||||||
ExecStart=/usr/bin/carton exec hypnotoad script/lstu
|
ExecStart=/usr/bin/carton exec hypnotoad script/lstu
|
||||||
ExecStop=/usr/bin/carton exec hypnotoad -s script/lstu
|
ExecStop=/usr/bin/carton exec hypnotoad -s script/lstu
|
||||||
ExecReload=/usr/bin/carton exec hypnotoad script/lstu
|
ExecReload=/usr/bin/carton exec hypnotoad script/lstu
|
||||||
|
|
1
doc/ADMIN.md
Normal file
1
doc/ADMIN.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
How to configure this app: a plain file at `__INSTALL_DIR__/lstu.conf` with SSH.
|
1
doc/ADMIN_fr.md
Normal file
1
doc/ADMIN_fr.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Comment configurer cette application : un fichier simple à `__INSTALL_DIR__/lstu.conf` avec SSH.
|
|
@ -1,3 +0,0 @@
|
||||||
## Configuration
|
|
||||||
|
|
||||||
How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH.
|
|
|
@ -1,3 +0,0 @@
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu.conf` avec SSH.
|
|
|
@ -1,63 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Lstu",
|
|
||||||
"id": "lstu",
|
|
||||||
"packaging_format": 1,
|
|
||||||
"description": {
|
|
||||||
"en": "URL Shortener",
|
|
||||||
"fr": "Raccourcisseur d'URL"
|
|
||||||
},
|
|
||||||
"version": "0.26.0~ynh2",
|
|
||||||
"url": "https://lstu.fr",
|
|
||||||
"upstream": {
|
|
||||||
"license": "WTFPL",
|
|
||||||
"website": "https://lstu.fr",
|
|
||||||
"demo": "https://lstu.fr",
|
|
||||||
"admindoc": "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home",
|
|
||||||
"code": "https://framagit.org/fiat-tux/hat-softwares/lstu"
|
|
||||||
},
|
|
||||||
"license": "WTFPL",
|
|
||||||
"maintainer": {
|
|
||||||
"name": "frju365",
|
|
||||||
"email": "abld@abld.info"
|
|
||||||
},
|
|
||||||
"requirements": {
|
|
||||||
"yunohost": ">= 4.3.0"
|
|
||||||
},
|
|
||||||
"multi_instance": true,
|
|
||||||
"services": [
|
|
||||||
"nginx"
|
|
||||||
],
|
|
||||||
"arguments": {
|
|
||||||
"install": [
|
|
||||||
{
|
|
||||||
"name": "domain",
|
|
||||||
"type": "domain"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "path",
|
|
||||||
"type": "path",
|
|
||||||
"example": "/lstu",
|
|
||||||
"default": "/lstu"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "theme",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a theme",
|
|
||||||
"fr": "Choisissez un theme"
|
|
||||||
},
|
|
||||||
"choices": ["default", "milligram"],
|
|
||||||
"default": "milligram"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "password",
|
|
||||||
"type": "password"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
69
manifest.toml
Normal file
69
manifest.toml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "lstu"
|
||||||
|
name = "Lstu"
|
||||||
|
description.en = "URL Shortener"
|
||||||
|
description.fr = "Raccourcisseur d'URL"
|
||||||
|
|
||||||
|
version = "0.26.0~ynh3"
|
||||||
|
|
||||||
|
maintainers = ["frju365"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "WTFPL"
|
||||||
|
website = "https://lstu.fr"
|
||||||
|
demo = "https://lstu.fr"
|
||||||
|
admindoc = "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home"
|
||||||
|
code = "https://framagit.org/fiat-tux/hat-softwares/lstu"
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 11.1.20"
|
||||||
|
architectures = "all"
|
||||||
|
multi_instance = true
|
||||||
|
ldap = true
|
||||||
|
sso = true
|
||||||
|
disk = "50M"
|
||||||
|
ram.build = "50M"
|
||||||
|
ram.runtime = "50M"
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
type = "domain"
|
||||||
|
|
||||||
|
[install.path]
|
||||||
|
type = "path"
|
||||||
|
default = "/lstu"
|
||||||
|
|
||||||
|
[install.init_main_permission]
|
||||||
|
type = "group"
|
||||||
|
default = false
|
||||||
|
|
||||||
|
[install.theme]
|
||||||
|
ask.en = "Choose a theme"
|
||||||
|
ask.fr = "Choisissez un theme"
|
||||||
|
type = "string"
|
||||||
|
choices = ["default", "milligram"]
|
||||||
|
default = "milligram"
|
||||||
|
|
||||||
|
[install.password]
|
||||||
|
type = "password"
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.sources.main]
|
||||||
|
url = "https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.26-0/lstu-0.26-0.tar.gz"
|
||||||
|
sha256 = "323c81b4cb04a97eda7cb37b2a63d16e808591fd46eb4326f6619200ce742960"
|
||||||
|
|
||||||
|
[resources.ports]
|
||||||
|
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[resources.apt]
|
||||||
|
packages = "build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl"
|
||||||
|
|
||||||
|
[resources.database]
|
||||||
|
type = "postgresql"
|
|
@ -4,9 +4,6 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
|
||||||
pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql carton libpod-parser-perl"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -15,141 +12,6 @@ pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev mem
|
||||||
# EXPERIMENTAL HELPERS
|
# 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 " " "\ \ " mail_to_send
|
|
||||||
ynh_replace_string "\t" "\ \ " 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"
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# FUTURE OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source scripts/_common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Get is_public
|
|
||||||
password=${YNH_ACTION_PASSWORD}
|
|
||||||
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
|
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF AN ACTION HAS TO BE DONE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
hashed_password_old=$(ynh_app_setting_get $app hashed_password)
|
|
||||||
|
|
||||||
if [ "$hashed_password" == "$hashed_password_old" ]
|
|
||||||
then
|
|
||||||
ynh_die --message="Same password." --ret_code=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC ACTION
|
|
||||||
#=================================================
|
|
||||||
# MOVE TO PUBLIC OR PRIVATE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
|
|
||||||
ynh_replace_string "$hashed_password_old" "$hashed_password" "${final_path}/lstu.conf"
|
|
||||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
|
||||||
|
|
||||||
# Update the config of the app
|
|
||||||
ynh_app_setting_set $app hashed_password $hashed_password
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="reload" --log_path="systemd" --line_match="Server available at"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# END OF SCRIPT
|
|
||||||
#=================================================
|
|
|
@ -1,55 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source scripts/_common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Get is_public
|
|
||||||
theme=${YNH_ACTION_THEME}
|
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF AN ACTION HAS TO BE DONE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
theme_old=$(ynh_app_setting_get $app theme)
|
|
||||||
|
|
||||||
if [ "$theme" == "$theme_old" ]
|
|
||||||
then
|
|
||||||
ynh_die --message="Same theme." --ret_code=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC ACTION
|
|
||||||
#=================================================
|
|
||||||
# MOVE TO PUBLIC OR PRIVATE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
|
|
||||||
ynh_replace_string "$theme_old" "$theme" "${final_path}/lstu.conf"
|
|
||||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
|
||||||
|
|
||||||
# Update the config of the app
|
|
||||||
ynh_app_setting_set $app theme $theme
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="reload" --log_path="systemd" --line_match="Server available at"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# END OF SCRIPT
|
|
||||||
#=================================================
|
|
|
@ -1,94 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source scripts/_common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Get is_public
|
|
||||||
is_public=${YNH_ACTION_IS_PUBLIC}
|
|
||||||
|
|
||||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
|
||||||
port=$(ynh_app_setting_get $app port)
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
|
||||||
secret=$(ynh_app_setting_get $app secret)
|
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get $app psqlpwd)
|
|
||||||
theme=$(ynh_app_setting_get $app theme)
|
|
||||||
hashed_password=$(ynh_app_setting_get $app hashed_password)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF ARGUMENTS ARE CORRECT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF AN ACTION HAS TO BE DONE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
is_public_old=$(ynh_app_setting_get $app is_public)
|
|
||||||
|
|
||||||
if [ $is_public -eq $is_public_old ]
|
|
||||||
then
|
|
||||||
ynh_die --message="is_public is already set as $is_public." --ret_code=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC ACTION
|
|
||||||
#=================================================
|
|
||||||
# MOVE TO PUBLIC OR PRIVATE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ];
|
|
||||||
then
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
|
|
||||||
else
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]; then
|
|
||||||
public_private="private"
|
|
||||||
else
|
|
||||||
public_private="public"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then
|
|
||||||
# If the app is private, only the shortened URLs are publics.
|
|
||||||
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 protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
|
|
||||||
else
|
|
||||||
ynh_app_setting_delete $app protected_regex
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Regen ssowat configuration
|
|
||||||
yunohost app ssowatconf
|
|
||||||
|
|
||||||
# Update the config of the app
|
|
||||||
ynh_app_setting_set $app is_public $is_public
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="reload" --log_path="systemd" --line_match="Server available at"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# END OF SCRIPT
|
|
||||||
#=================================================
|
|
|
@ -10,27 +10,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# 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)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -40,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
|
|
@ -9,70 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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..."
|
|
||||||
|
|
||||||
# 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
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
db_user=$db_name
|
|
||||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
|
||||||
theme=$(ynh_app_setting_get --app=$app --key=theme)
|
|
||||||
hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -87,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
@ -119,31 +33,9 @@ fi
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
|
||||||
domain="$new_domain"
|
domain="$new_domain"
|
||||||
path_url="$new_path"
|
path="$new_path"
|
||||||
|
|
||||||
if [ $is_public -eq 0 ];
|
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
|
||||||
then
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
|
|
||||||
else
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reconfigure SSOwat"
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then
|
|
||||||
# If the app is private, only the shortened URLs are publics.
|
|
||||||
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 protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
@ -155,13 +47,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
147
scripts/install
147
scripts/install
|
@ -9,104 +9,31 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
|
||||||
path_url=$YNH_APP_ARG_PATH
|
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
||||||
theme=$YNH_APP_ARG_THEME
|
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
secret=$(ynh_string_random --length=24)
|
secret=$(ynh_string_random --length=24)
|
||||||
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
|
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
|
||||||
|
|
||||||
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
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
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=theme --value=$theme
|
|
||||||
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
||||||
ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
|
ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
|
||||||
# FIND AND OPEN A PORT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Finding an available port..."
|
|
||||||
|
|
||||||
# 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..."
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..."
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE A POSTGRESQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
|
||||||
|
|
||||||
# Create postgresql database
|
|
||||||
ynh_psql_test_if_first_run
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
db_user=$db_name
|
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..."
|
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
|
# 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 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -116,6 +43,14 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
# Use logrotate to manage application logfile(s)
|
||||||
|
ynh_use_logrotate
|
||||||
|
|
||||||
|
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -123,45 +58,17 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..."
|
ynh_script_progression --message="Adding a configuration file..."
|
||||||
|
|
||||||
if [ $is_public -eq 0 ];
|
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
|
||||||
then
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
|
|
||||||
else
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL LSTU
|
# INSTALL LSTU
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Lstu..."
|
ynh_script_progression --message="Installing Lstu..."
|
||||||
|
|
||||||
pushd $final_path
|
pushd $install_dir
|
||||||
carton install --deployment --without=sqlite --without=mysql
|
carton install --deployment --without=sqlite --without=mysql
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring a systemd service..."
|
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
ynh_add_systemd_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
|
||||||
ynh_use_logrotate
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -170,34 +77,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring permissions..."
|
|
||||||
|
|
||||||
# Everyone can access the app.
|
|
||||||
# The "main" permission is automatically created before the install script.
|
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then
|
|
||||||
# If the app is private, only the shortened URLs are publics.
|
|
||||||
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/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -9,19 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -35,74 +22,18 @@ then
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STOP AND REMOVE SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing logrotate configuration..."
|
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE THE POSTGRESQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
|
||||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE APP MAIN DIR
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing app main directory..."
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
|
||||||
ynh_secure_remove --file="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC REMOVE
|
|
||||||
#=================================================
|
|
||||||
# REMOVE VARIOUS FILES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing various files..."
|
|
||||||
|
|
||||||
# Remove the log files
|
# Remove the log files
|
||||||
ynh_secure_remove --file="/var/log/$app.log"
|
ynh_secure_remove --file="/var/log/$app.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
|
||||||
|
|
||||||
# Delete a system user
|
|
||||||
ynh_system_user_delete --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -10,68 +10,15 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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..."
|
|
||||||
|
|
||||||
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)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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 "
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
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 "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC RESTORATION
|
|
||||||
#=================================================
|
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
|
||||||
|
|
||||||
# Define and install dependencies
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
@ -85,45 +32,31 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostregSQL database..."
|
ynh_script_progression --message="Restoring the PostregSQL database..."
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
#ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service --quiet
|
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"
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# START SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
174
scripts/upgrade
174
scripts/upgrade
|
@ -9,47 +9,12 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation 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)
|
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
theme=$(ynh_app_setting_get --app=$app theme)
|
|
||||||
hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
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)..."
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -59,67 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
||||||
|
|
||||||
# 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 [ -z "$db_pwd" ]; then
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) # Fix old db_pwd
|
|
||||||
if [ -z "$db_pwd" ]; then
|
|
||||||
ynh_psql_test_if_first_run
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
|
||||||
db_user=$db_name
|
|
||||||
# Initialize database and store postgres password for upgrade
|
|
||||||
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name"
|
|
||||||
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function
|
|
||||||
else
|
|
||||||
ynh_app_setting_delete --app=$app --key=db_pwd
|
|
||||||
ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$theme" ]; then
|
|
||||||
theme="milligram"
|
|
||||||
ynh_app_setting_set --app=$app --key=theme --value=$theme
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$hashed_password" ]; then
|
|
||||||
# Generate random password
|
|
||||||
password=$(ynh_string_random --length=8)
|
|
||||||
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
|
|
||||||
|
|
||||||
echo "The new version of LSTU provide an admin and a stats area which required a password." > mail_to_send
|
|
||||||
echo "" >> mail_to_send
|
|
||||||
echo "This password is: $password" >> mail_to_send
|
|
||||||
|
|
||||||
ynh_send_readme_to_admin --app_message="mail_to_send" --type="upgrade"
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
|
|
||||||
fi
|
|
||||||
|
|
||||||
# In previous versions, the port was mistakenly exposed to the outside world >_>
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Closing port $port..."
|
|
||||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -129,48 +33,27 @@ then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..."
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path" #--keep="$final_path/lstu.conf"
|
ynh_setup_source --dest_dir="$install_dir" --keep="lstu.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod -R o-rwx "$install_dir"
|
||||||
chmod -R o-rwx "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app:www-data "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
#ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
|
||||||
if [ $is_public -eq 0 ];
|
#ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
|
||||||
then
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
|
|
||||||
else
|
|
||||||
ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD LSU
|
# BUILD LSU
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building lstu..."
|
ynh_script_progression --message="Building lstu..."
|
||||||
|
|
||||||
pushd $final_path
|
pushd $install_dir
|
||||||
carton install --deployment --without=sqlite --without=mysql
|
carton install --deployment --without=sqlite --without=mysql
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
@ -179,24 +62,15 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -204,35 +78,7 @@ yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/pro
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd"
|
ynh_systemd_action --service_name=$app --action=reload --log_path="systemd" --line_match="Reloaded Shortened URLs service."
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring permissions..."
|
|
||||||
|
|
||||||
# Everyone can access the app.
|
|
||||||
# The "main" permission is automatically created before the install script.
|
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then
|
|
||||||
# If the app is private, only the shortened URLs are publics.
|
|
||||||
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/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
14
tests.toml
Normal file
14
tests.toml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
test_format = 1.0
|
||||||
|
|
||||||
|
[default]
|
||||||
|
# -------------------------------
|
||||||
|
# Default args to use for install
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
args.theme = "milligram"
|
||||||
|
|
||||||
|
# -------------------------------
|
||||||
|
# Commits to test upgrade from
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
test_upgrade_from.af9f0258204e71bc567206ef2dc00d151319fa21.name = "Upgrade from 0.26.0~ynh2"
|
Loading…
Add table
Reference in a new issue