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

Merge pull request #32 from YunoHost-Apps/upgrade

Apply example_ynh
This commit is contained in:
yalh76 2022-07-12 21:38:43 +02:00 committed by GitHub
commit ae1b11340f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 166 additions and 191 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Snipe-IT for YunoHost # Snipe-IT for YunoHost
[![Integration level](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg) [![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) [![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)* *[Lire ce readme en français.](./README_fr.md)*
@ -17,31 +17,32 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Manage assets for IT operations Manage assets for IT operations
**Shipped version:** 5.3.1~ynh2 **Shipped version:** 5.3.1~ynh3
**Demo:** https://snipeitapp.com/demo/ **Demo:** https://snipeitapp.com/demo/
## Screenshots ## Screenshots
![](./doc/screenshots/screenshot-license-list.png) ![Screenshot of Snipe-IT](./doc/screenshots/screenshot-license-list.png)
## Documentation and resources ## Documentation and resources
* Official app website: https://snipeitapp.com/ * Official app website: <https://snipeitapp.com>
* Official admin documentation: https://snipe-it.readme.io/docs * Official admin documentation: <https://snipe-it.readme.io/docs>
* Upstream app code repository: https://github.com/snipe/snipe-it * Upstream app code repository: <https://github.com/snipe/snipe-it>
* YunoHost documentation for this app: https://yunohost.org/app_snipeit * YunoHost documentation for this app: <https://yunohost.org/app_snipeit>
* Report a bug: https://github.com/YunoHost-Apps/snipeit_ynh/issues * Report a bug: <https://github.com/YunoHost-Apps/snipeit_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug
or or
sudo yunohost app upgrade snipeit -u https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug sudo yunohost app upgrade snipeit -u https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps **More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Snipe-IT pour YunoHost # Snipe-IT pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg) [![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)
[![Installer Snipe-IT avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snipeit) [![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)* *[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Snipe-IT rapidement et simplement sur un serveur YunoHost. > *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.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -13,31 +17,32 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Gestionnaire de ressources informatiques Gestionnaire de ressources informatiques
**Version incluse :** 5.3.1~ynh2 **Version incluse :** 5.3.1~ynh3
**Démo :** https://snipeitapp.com/demo/ **Démo :** https://snipeitapp.com/demo/
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/screenshot-license-list.png) ![Capture d'écran de Snipe-IT](./doc/screenshots/screenshot-license-list.png)
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : https://snipeitapp.com/ * Site officiel de l'app : <https://snipeitapp.com>
* Documentation officielle de l'admin : https://snipe-it.readme.io/docs * 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 * Dépôt de code officiel de l'app : <https://github.com/snipe/snipe-it>
* Documentation YunoHost pour cette app : https://yunohost.org/app_snipeit * Documentation YunoHost pour cette app : <https://yunohost.org/app_snipeit>
* Signaler un bug : https://github.com/YunoHost-Apps/snipeit_ynh/issues * Signaler un bug : <https://github.com/YunoHost-Apps/snipeit_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing). Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade snipeit -u https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug 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 d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,9 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path"
admin="john"
language="fr"
is_public=1 is_public=1
language="fr"
admin="john"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=0
@ -13,12 +12,14 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 5.0.4~ynh1
upgrade=1 from_commit=c0be2e5239ccad4cff25d5bd1584eabd11617220 upgrade=1 from_commit=c0be2e5239ccad4cff25d5bd1584eabd11617220
# 5.3.1~ynh2
upgrade=1 from_commit=7461b1d0f1f0da643e348da3d7ac76c51fd7c576
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
incorrect_path=1 port_already_use=0
change_url=0 change_url=0
;;; Options ;;; Options
Email=anmol@datamol.org Email=anmol@datamol.org
Notification=change Notification=none

View file

@ -3,7 +3,7 @@
# -------------------------------------------- # --------------------------------------------
APP_ENV=production APP_ENV=production
APP_DEBUG=false APP_DEBUG=false
APP_KEY=__KEY__ APP_KEY=__APP_KEY__
APP_URL=http://__DOMAIN__ APP_URL=http://__DOMAIN__
APP_TIMEZONE='UTC' APP_TIMEZONE='UTC'
APP_LOCALE=__LANGUAGE__ APP_LOCALE=__LANGUAGE__
@ -79,7 +79,7 @@ CACHE_PREFIX=snipeit
# -------------------------------------------- # --------------------------------------------
REDIS_HOST="127.0.0.1" REDIS_HOST="127.0.0.1"
REDIS_PASSWORD=null REDIS_PASSWORD=null
REDIS_PORT=__REDIS_DB__ REDIS_PORT=6379
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: MEMCACHED SETTINGS # OPTIONAL: MEMCACHED SETTINGS

View file

@ -3,3 +3,5 @@ SOURCE_SUM=0870373e35dbe34574322d49da647a4c5cf8912a153ab520eb065cc4b06787e0
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -6,19 +6,19 @@
"en": "Manage assets for IT operations", "en": "Manage assets for IT operations",
"fr": "Gestionnaire de ressources informatiques" "fr": "Gestionnaire de ressources informatiques"
}, },
"version": "5.3.1~ynh2", "version": "5.3.1~ynh3",
"url": "https://snipeitapp.com/", "url": "https://snipeitapp.com",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",
"website": "https://snipeitapp.com/", "website": "https://snipeitapp.com",
"demo": "https://snipeitapp.com/demo/", "demo": "https://snipeitapp.com/demo/",
"admindoc": "https://snipe-it.readme.io/docs", "admindoc": "https://snipe-it.readme.io/docs",
"code": "https://github.com/snipe/snipe-it" "code": "https://github.com/snipe/snipe-it"
}, },
"license": "MIT", "license": "MIT",
"maintainer": { "maintainer": {
"name": "Anmol Sharma", "name": "",
"email": "anmol@datamol.org" "email": ""
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.3.0" "yunohost": ">= 4.3.0"
@ -30,15 +30,11 @@
"mysql" "mysql"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
}, },
{
"name": "admin",
"type": "user"
},
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
@ -53,6 +49,10 @@
}, },
"choices": ["en", "fr"], "choices": ["en", "fr"],
"default": "en" "default": "en"
},
{
"name": "admin",
"type": "user"
} }
] ]
} }

View file

@ -7,11 +7,11 @@
# Packages requirements: https://snipe-it.readme.io/docs/requirements # Packages requirements: https://snipe-it.readme.io/docs/requirements
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"
pkg_dependencies="openssl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd"
YNH_COMPOSER_VERSION=2.0.14 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"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
@ -20,44 +20,3 @@ YNH_COMPOSER_VERSION=2.0.14
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
#=================================================
# REDIS HELPERS
#=================================================
# get the first available redis database
#
# usage: ynh_redis_get_free_db
# | returns: the database number to use
ynh_redis_get_free_db() {
local result max db
result="$(redis-cli INFO keyspace)"
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
db=0
# default Debian setting is 15 databases
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
db=$i
break 1
fi
db=-1
done
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
echo "$db"
}
# Create a master password and set up global settings
# Please always call this script in install and restore scripts
#
# usage: ynh_redis_remove_db database
# | arg: database - the database to erase
ynh_redis_remove_db() {
local db=$1
redis-cli -n "$db" flushall
}

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers

View file

@ -25,12 +25,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
email=$(ynh_user_get_info --username=$admin --key=mail) admin=$YNH_APP_ARG_ADMIN
key=$(ynh_string_random --length=24)
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -52,9 +49,8 @@ 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=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion ynh_app_setting_set --app=$app --key=admin --value=$admin
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -65,6 +61,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=3
ynh_install_app_dependencies $pkg_dependencies 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 # CREATE A MYSQL DATABASE
#================================================= #=================================================
@ -75,14 +79,6 @@ db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$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 ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -92,14 +88,6 @@ 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="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=5
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -107,6 +95,15 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low 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 # SPECIFIC SETUP
@ -119,19 +116,21 @@ ynh_script_progression --message="Installing Composer..." --weight=21
ynh_install_composer ynh_install_composer
#================================================= #=================================================
# BUILDING # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Building..." ynh_script_progression --message="Adding a configuration file..."
# Configure redis
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
app_key=""
ynh_add_config --template="../conf/.env" --destination="$final_path/.env" ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
chmod 600 "$final_path/.env" chmod 600 "$final_path/.env"
chown $app:$app "$final_path/.env" chown $app:$app "$final_path/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..."
# setup application config # setup application config
pushd "$final_path" pushd "$final_path"
php$phpversion artisan key:generate -n --force --env php$phpversion artisan key:generate -n --force --env
@ -140,12 +139,9 @@ pushd "$final_path"
php$phpversion artisan config:cache -n php$phpversion artisan config:cache -n
popd popd
#================================================= app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)"
# GENERIC FINALIZATION ynh_app_setting_set --app=$app --key=app_key --value=$app_key
#================================================= ynh_store_file_checksum --file="$final_path/.env"
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files # Set permissions to app files
chown -R $app:www-data $final_path chown -R $app:www-data $final_path
@ -153,15 +149,19 @@ chmod -R o-rwx $final_path
chmod -R 755 $final_path/storage chmod -R 755 $final_path/storage
chmod -R 755 $final_path/public/uploads chmod -R 755 $final_path/public/uploads
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=3 ynh_script_progression --message="Configuring permissions..." --weight=3
# Make app public if necessary or protect it # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
ynh_permission_update --permission "main" --add "visitors" # Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================

View file

@ -20,37 +20,21 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the MySQL database" --weight=1 ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
ynh_script_progression --message="Removing the redis database..."
ynh_redis_remove_db "$redis_db"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies" --weight=2
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing Snipe-IT main directory" --weight=5 ynh_script_progression --message="Removing app main directory..." --weight=5
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -58,7 +42,7 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration" --weight=1 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -66,17 +50,25 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing PHP-FPM configuration" --weight=2 ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_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 # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user" --weight=1 ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -22,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -43,13 +44,6 @@ test ! -d $final_path \
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
@ -61,7 +55,7 @@ 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 Snipe-IT main directory..." --weight=7 ynh_script_progression --message="Restoring the app main directory..." --weight=7
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -69,17 +63,6 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring 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
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
@ -90,6 +73,24 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=8
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_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"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================

View file

@ -18,37 +18,48 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) 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) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
app_key=$(ynh_app_setting_get --app=$app --key=app_key)
#================================================= #=================================================
# 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 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up Snipe-IT before upgrading (may take a while)..." --weight=4 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 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 db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -61,11 +72,10 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# Cleaning legacy permissions # If app_key doesn't exist, create it
if ynh_legacy_permissions_exists; then if [ -z "$app_key" ]; then
ynh_legacy_permissions_delete_all app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)"
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
ynh_app_setting_delete --app=$app --key=is_public
fi fi
#================================================= #=================================================
@ -76,8 +86,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -90,14 +98,6 @@ then
ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env" ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env"
fi fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -113,6 +113,14 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low 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 # SPECIFIC UPGRADE
#================================================= #=================================================
@ -125,22 +133,25 @@ ynh_install_composer
ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload" ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload"
pushd "$final_path" #=================================================
php$phpversion artisan migrate -n --force # UPDATE A CONFIG FILE
php$phpversion artisan config:clear -n #=================================================
php$phpversion artisan config:cache -n ynh_script_progression --message="Updating a configuration file..."
popd
ynh_backup_if_checksum_is_different --file="$final_path/.env" ynh_backup_if_checksum_is_different --file="$final_path/.env"
# Recalculate and store the checksum of the file for the next upgrade. # 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="$final_path/.env"
#================================================= #=================================================
# GENERIC FINALIZATION # BUILDING
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES ynh_script_progression --message="Building..."
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1 pushd "$final_path"
php$phpversion artisan migrate -n --force
php$phpversion artisan config:clear -n
php$phpversion artisan config:cache -n
popd
# Set permissions on app files # Set permissions on app files
chown -R $app:www-data $final_path chown -R $app:www-data $final_path
@ -148,6 +159,8 @@ chmod -R o-rwx $final_path
chmod -R 755 $final_path/storage chmod -R 755 $final_path/storage
chmod -R 755 $final_path/public/uploads chmod -R 755 $final_path/public/uploads
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================