1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snipeit_ynh.git synced 2024-09-03 20:26:16 +02:00

Manifest v2 and upgrade to v6.1.0 (#34)

* convert to v2

* cleanup and example_ynh

* Update

* Update

* Auto-update README

* Update tests.toml

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
This commit is contained in:
Tagada 2023-10-23 18:56:48 +02:00 committed by GitHub
parent 2705c4c232
commit b613280d3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 238 additions and 495 deletions

View file

@ -6,6 +6,7 @@ It shall NOT be edited by hand.
# Snipe-IT for YunoHost
[![Integration level](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![Working status](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg)
[![Install Snipe-IT with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snipeit)
*[Lire ce readme en français.](./README_fr.md)*
@ -15,10 +16,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
Manage assets for IT operations
**Shipped version:** 5.3.1~ynh3
This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.
**Shipped version:** 6.1.0~ynh1
**Demo:** https://snipeitapp.com/demo/
@ -29,7 +29,8 @@ Manage assets for IT operations
## Documentation and resources
* Official app website: <https://snipeitapp.com>
* Official admin documentation: <https://snipe-it.readme.io/docs>
* Official user documentation: <https://snipe-it.readme.io/docs/overview>
* Official admin documentation: <https://snipe-it.readme.io/docs/introduction>
* Upstream app code repository: <https://github.com/snipe/snipe-it>
* YunoHost documentation for this app: <https://yunohost.org/app_snipeit>
* Report a bug: <https://github.com/YunoHost-Apps/snipeit_ynh/issues>

View file

@ -5,32 +5,33 @@ It shall NOT be edited by hand.
# Snipe-IT pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg)
[![Niveau dintégration](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg)
[![Installer Snipe-IT avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snipeit)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Snipe-IT rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
> *Ce package vous permet dinstaller Snipe-IT rapidement et simplement sur un serveur YunoHost.
Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
## Vue d'ensemble
## Vue densemble
Gestionnaire de ressources informatiques
**Version incluse :** 5.3.1~ynh3
This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.
**Version incluse :** 6.1.0~ynh1
**Démo :** https://snipeitapp.com/demo/
## Captures d'écran
## Captures décran
![Capture d'écran de Snipe-IT](./doc/screenshots/screenshot-license-list.png)
![Capture décran de Snipe-IT](./doc/screenshots/screenshot-license-list.png)
## Documentations et ressources
* Site officiel de l'app : <https://snipeitapp.com>
* Documentation officielle de l'admin : <https://snipe-it.readme.io/docs>
* Dépôt de code officiel de l'app : <https://github.com/snipe/snipe-it>
* Site officiel de lapp : <https://snipeitapp.com>
* Documentation officielle utilisateur : <https://snipe-it.readme.io/docs/overview>
* Documentation officielle de ladmin : <https://snipe-it.readme.io/docs/introduction>
* Dépôt de code officiel de lapp : <https://github.com/snipe/snipe-it>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_snipeit>
* Signaler un bug : <https://github.com/YunoHost-Apps/snipeit_ynh/issues>
@ -46,4 +47,4 @@ ou
sudo yunohost app upgrade snipeit -u https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
**Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>

View file

@ -1,25 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
language="fr"
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 5.0.4~ynh1
upgrade=1 from_commit=c0be2e5239ccad4cff25d5bd1584eabd11617220
# 5.3.1~ynh2
upgrade=1 from_commit=7461b1d0f1f0da643e348da3d7ac76c51fd7c576
backup_restore=1
multi_instance=0
port_already_use=0
change_url=0
;;; Options
Email=anmol@datamol.org
Notification=none

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/snipe/snipe-it/archive/v5.3.1.tar.gz
SOURCE_SUM=0870373e35dbe34574322d49da647a4c5cf8912a153ab520eb065cc4b06787e0
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -2,7 +2,7 @@
location ^~ __PATH__/ {
# Path to source
alias __FINALPATH__/public/;
alias __INSTALL_DIR__/public/;
index index.php;

View file

@ -4,15 +4,27 @@
APP_ENV=production
APP_DEBUG=false
APP_KEY=__APP_KEY__
APP_URL=http://__DOMAIN__
APP_TIMEZONE='UTC'
APP_URL=https://__DOMAIN__
APP_TIMEZONE='__TIMEZONE__'
APP_LOCALE=__LANGUAGE__
MAX_RESULTS=500
# --------------------------------------------
# REQUIRED: UPLOADED FILE STORAGE SETTINGS
# --------------------------------------------
PRIVATE_FILESYSTEM_DISK=local
PUBLIC_FILESYSTEM_DISK=local_public
#PRIVATE_FILESYSTEM_DISK=s3_private
#PUBLIC_FILESYSTEM_DISK=s3_public
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=__DB_NAME__
DB_USERNAME=__DB_USER__
DB_PASSWORD=__DB_PWD__
@ -25,6 +37,7 @@ DB_COLLATION=utf8mb4_unicode_ci
# OPTIONAL: SSL DATABASE SETTINGS
# --------------------------------------------
DB_SSL=false
DB_SSL_IS_PAAS=false
DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null
@ -43,6 +56,7 @@ MAIL_FROM_ADDR=snipeit@__DOMAIN__
MAIL_FROM_NAME='Snip-IT'
MAIL_REPLYTO_ADDR=snipeit@__DOMAIN__
MAIL_REPLYTO_NAME='Snipe-IT'
MAIL_AUTO_EMBED_METHOD='attachment'
# --------------------------------------------
# REQUIRED: IMAGE LIBRARY
@ -50,27 +64,41 @@ MAIL_REPLYTO_NAME='Snipe-IT'
# --------------------------------------------
IMAGE_LIB=gd
# --------------------------------------------
# OPTIONAL: BACKUP SETTINGS
# --------------------------------------------
MAIL_BACKUP_NOTIFICATION_DRIVER=null
MAIL_BACKUP_NOTIFICATION_ADDRESS=null
BACKUP_ENV=true
ALLOW_BACKUP_DELETE=false
ALLOW_DATA_PURGE=false
# --------------------------------------------
# OPTIONAL: SESSION SETTINGS
# --------------------------------------------
SESSION_DRIVER=file
SESSION_LIFETIME=12000
EXPIRE_ON_CLOSE=false
ENCRYPT=false
COOKIE_NAME=snipeit_session
COOKIE_DOMAIN=null
SECURE_COOKIES=false
API_TOKEN_EXPIRATION_YEARS=15
# --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS
# --------------------------------------------
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
ALLOW_IFRAMING=false
REFERRER_POLICY=same-origin
ENABLE_CSP=false
CORS_ALLOWED_ORIGINS=null
ENABLE_HSTS=false
# --------------------------------------------
# OPTIONAL: CACHE SETTINGS
# --------------------------------------------
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
CACHE_PREFIX=snipeit
@ -88,12 +116,31 @@ MEMCACHED_HOST=null
MEMCACHED_PORT=null
# --------------------------------------------
# OPTIONAL: AWS S3 SETTINGS
# OPTIONAL: PUBLIC S3 Settings
# --------------------------------------------
AWS_SECRET=null
AWS_KEY=null
AWS_REGION=null
AWS_BUCKET=null
PUBLIC_AWS_SECRET_ACCESS_KEY=null
PUBLIC_AWS_ACCESS_KEY_ID=null
PUBLIC_AWS_DEFAULT_REGION=null
PUBLIC_AWS_BUCKET=null
PUBLIC_AWS_URL=null
PUBLIC_AWS_BUCKET_ROOT=null
# --------------------------------------------
# OPTIONAL: PRIVATE S3 Settings
# --------------------------------------------
PRIVATE_AWS_ACCESS_KEY_ID=null
PRIVATE_AWS_SECRET_ACCESS_KEY=null
PRIVATE_AWS_DEFAULT_REGION=null
PRIVATE_AWS_BUCKET=null
PRIVATE_AWS_URL=null
PRIVATE_AWS_BUCKET_ROOT=null
# --------------------------------------------
# OPTIONAL: AWS Settings
# --------------------------------------------
AWS_ACCESS_KEY_ID=null
AWS_SECRET_ACCESS_KEY=null
AWS_DEFAULT_REGION=null
# --------------------------------------------
# OPTIONAL: LOGIN THROTTLING
@ -101,15 +148,34 @@ AWS_BUCKET=null
LOGIN_MAX_ATTEMPTS=5
LOGIN_LOCKOUT_DURATION=60
# --------------------------------------------
# OPTIONAL: FORGOTTEN PASSWORD SETTINGS
# --------------------------------------------
RESET_PASSWORD_LINK_EXPIRES=15
PASSWORD_CONFIRM_TIMEOUT=10800
PASSWORD_RESET_MAX_ATTEMPTS_PER_MIN=50
# --------------------------------------------
# OPTIONAL: MISC
# --------------------------------------------
APP_LOG=single
APP_LOG_MAX_FILES=10
LOG_CHANNEL=single
LOG_MAX_DAYS=10
APP_LOCKED=false
FILESYSTEM_DISK=local
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
ALLOW_IFRAMING=false
APP_CIPHER=AES-256-CBC
APP_FORCE_TLS=false
APP_ALLOW_INSECURE_HOSTS=false
GOOGLE_MAPS_API=
BACKUP_ENV=true
LDAP_MEM_LIM=500M
LDAP_TIME_LIM=600
IMPORT_TIME_LIMIT=600
IMPORT_MEMORY_LIMIT=500M
REPORT_TIME_LIMIT=12000
REQUIRE_SAML=false
API_THROTTLE_PER_MINUTE=120
CSV_ESCAPE_FORMULAS=true
# --------------------------------------------
# OPTIONAL: SCIM
# --------------------------------------------
SCIM_TRACE=false
SCIM_STANDARDS_COMPLIANCE=false

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.

1
doc/POST_INSTALL.md Normal file
View file

@ -0,0 +1 @@
You can finish the Pre-Flight setup at https://__DOMAIN__ following [the documentation](https://snipe-it.readme.io/docs/pre-flight-setup)!

View file

@ -1,59 +0,0 @@
{
"name": "Snipe-IT",
"id": "snipeit",
"packaging_format": 1,
"description": {
"en": "Manage assets for IT operations",
"fr": "Gestionnaire de ressources informatiques"
},
"version": "5.3.1~ynh3",
"url": "https://snipeitapp.com",
"upstream": {
"license": "MIT",
"website": "https://snipeitapp.com",
"demo": "https://snipeitapp.com/demo/",
"admindoc": "https://snipe-it.readme.io/docs",
"code": "https://github.com/snipe/snipe-it"
},
"license": "MIT",
"maintainer": {
"name": "",
"email": ""
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx",
"php7.3-fpm",
"mysql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["en", "fr"],
"default": "en"
},
{
"name": "admin",
"type": "user"
}
]
}
}

67
manifest.toml Normal file
View file

@ -0,0 +1,67 @@
packaging_format = 2
id = "snipeit"
name = "Snipe-IT"
description.en = "Manage assets for IT operations"
description.fr = "Gestionnaire de ressources informatiques"
version = "6.1.0~ynh1"
maintainers = []
[upstream]
license = "AGPL-3.0-or-later"
website = "https://snipeitapp.com"
demo = "https://snipeitapp.com/demo/"
admindoc = "https://snipe-it.readme.io/docs/introduction"
userdoc = "https://snipe-it.readme.io/docs/overview"
code = "https://github.com/snipe/snipe-it"
cpe = "cpe:2.3:a:snipeitapp:snipe-it"
fund = "https://snipeitapp.com/donate"
[integration]
yunohost = ">= 11.1.20"
architectures = "all"
multi_instance = false
ldap = false
sso = false
disk = "200M"
ram.build = "150M"
ram.runtime = "50M"
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
full_domain = true
[install.init_main_permission]
type = "group"
default = "visitors"
[install.language]
ask.en = "Choose the application language"
ask.fr = "Choisissez la langue de l'application"
type = "string"
choices = ["en", "fr"]
default = "en"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/snipe/snipe-it/archive/refs/tags/v6.1.0.tar.gz"
sha256 = "002e8bd89bdbba24a12259e0b32d08a85df3723d25427d2d906d97122b66daab"
autoupdate.strategy = "latest_github_tag"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "mariadb-server, openssl, redis, php8.1-curl, php8.1-ldap, php8.1-mysql, php8.1-gd, php8.1-xml, php8.1-mbstring, php8.1-zip, php8.1-bcmath, php8.1-redis"
[resources.database]
type = "mysql"

View file

@ -6,11 +6,8 @@
# Packages requirements: https://snipe-it.readme.io/docs/requirements
YNH_PHP_VERSION="7.3"
YNH_COMPOSER_VERSION=2.0.14
# dependencies used by the app
pkg_dependencies="openssl redis php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-redis"
YNH_COMPOSER_VERSION=2.5.8
timezone=$(cat /etc/timezone)
#=================================================
# PERSONAL HELPERS

View file

@ -10,28 +10,6 @@
source ../settings/scripts/_common.sh
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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -41,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
@ -49,12 +27,6 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================

View file

@ -10,121 +10,42 @@ source _common.sh
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
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=3
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=7
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_mysql_setup_db --db_user=$db_user --db_name=$db_name
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
# Create a dedicated PHP-FPM config using the conf/php-fpm.conf or conf/extra_php-fpm.conf
ynh_add_fpm_config --usage=low --footprint=low
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=5
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
ynh_script_progression --message="Installing Composer..." --weight=21
# Install composer
ynh_install_composer
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_script_progression --message="Adding a configuration file..." --weight=1
app_key=""
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
chmod 600 "$final_path/.env"
chown $app:$app "$final_path/.env"
chmod 600 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
#=================================================
# BUILDING
@ -132,44 +53,28 @@ chown $app:$app "$final_path/.env"
ynh_script_progression --message="Building..."
# setup application config
pushd "$final_path"
pushd "$install_dir"
php$phpversion artisan key:generate -n --force --env
php$phpversion artisan migrate -n --force
php$phpversion artisan config:clear -n
php$phpversion artisan config:cache -n
popd
app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)"
app_key="$(grep "^APP_KEY=" "$install_dir/.env" | cut -d= -f2)"
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
ynh_store_file_checksum --file="$final_path/.env"
ynh_store_file_checksum --file="$install_dir/.env"
# Set permissions to app files
chown -R $app:www-data $final_path
chmod -R o-rwx $final_path
chmod -R 755 $final_path/storage
chmod -R 755 $final_path/public/uploads
chown -R $app:www-data $install_dir
chmod -R o-rwx $install_dir
chmod -R 755 $install_dir/storage
chmod -R 755 $install_dir/public/uploads
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
# ...
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=3
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

View file

@ -10,69 +10,16 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
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
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=5
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=2
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,100 +10,39 @@
source ../settings/scripts/_common.sh
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_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=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..." --weight=7
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=8
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
# Restore the file first, so it can have a backup if different
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Recreate a dedicated php-fpm config
ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# Recreate a dedicated php-fpm config
ynh_add_fpm_config --usage=low --footprint=low
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1

View file

@ -9,22 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
language=$(ynh_app_setting_get --app=$app --key=language)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
app_key=$(ynh_app_setting_get --app=$app --key=app_key)
#=================================================
# CHECK VERSION
#=================================================
@ -32,20 +16,6 @@ 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=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -53,39 +23,14 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# 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 app_key doesn't exist, create it
if [ -z "$app_key" ]; then
app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)"
app_key="$(grep "^APP_KEY=" "$install_dir/.env" | cut -d= -f2)"
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN COMPOSER BUILD...)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -95,34 +40,22 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=7
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep=".env"
ynh_setup_source --dest_dir="$install_dir" --keep=".env storage/oauth-private.key storage/oauth-public.key storage/private_uploads public/uploads"
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=3
ynh_install_app_dependencies $pkg_dependencies
chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
@ -138,35 +71,28 @@ ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload"
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_backup_if_checksum_is_different --file="$final_path/.env"
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/.env"
ynh_store_file_checksum --file="$install_dir/.env"
# XXX: Regenerate .env instead ?
# ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..."
pushd "$final_path"
pushd "$install_dir"
php$phpversion artisan migrate -n --force
php$phpversion artisan config:clear -n
php$phpversion artisan config:cache -n
popd
# Set permissions on app files
chown -R $app:www-data $final_path
chmod -R o-rwx $final_path
chmod -R 755 $final_path/storage
chmod -R 755 $final_path/public/uploads
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
chown -R $app:www-data $install_dir
chmod -R o-rwx $install_dir
chmod -R 755 $install_dir/storage
chmod -R 755 $install_dir/public/uploads
#=================================================
# END OF SCRIPT

11
tests.toml Normal file
View file

@ -0,0 +1,11 @@
test_format = 1.0
[default]
exclude = ["install.subdir", "install.nourl", "change_url"]
test_upgrade_from.ebf4c0a.name = "Upgrade from 5.3.1~ynh3 (manifest v1)"
test_upgrade_from.ebf4c0a.args.domain="domain.tld"
test_upgrade_from.ebf4c0a.args.is_public=1
test_upgrade_from.ebf4c0a.args.language="fr"
test_upgrade_from.ebf4c0a.args.admin="package_checker"