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

Merge pull request #134 from YunoHost-Apps/example

Example
This commit is contained in:
yalh76 2021-03-04 14:54:04 +01:00 committed by GitHub
commit 8e17d517de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 109 deletions

View file

@ -4,3 +4,4 @@ SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -9,7 +9,8 @@ location / {
rewrite ^ https://$server_name$request_uri? permanent;
}
client_max_body_size 0;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
client_max_body_size 50M;
proxy_set_header Accept-Encoding "";
proxy_pass http://localhost:__PORT__;

View file

@ -1,6 +1,6 @@
---
name: Bug report
about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all.
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
@ -9,14 +9,16 @@ about: Create a report to help us debug, it would be nice to fill the template a
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to Wiki.js itself. Refer to its documentation or repository for help.*
- *If you have a doubt, post here, we will figure it out together.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
**Describe the bug**
### Describe the bug
*A clear and concise description of what the bug is.*
**Versions**
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
@ -25,8 +27,8 @@ about: Create a report to help us debug, it would be nice to fill the template a
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
**To Reproduce**
*Steps to reproduce the behavior.*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install wikijs
@ -38,9 +40,16 @@ about: Create a report to help us debug, it would be nice to fill the template a
3. *Scroll down to '...'*
4. *See error*
**Expected behavior**
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
**Logs**
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

View file

@ -13,7 +13,7 @@
"name": "yalh76"
},
"requirements": {
"yunohost": ">= 3.8.1"
"yunohost": ">= 4.1.7.3"
},
"multi_instance": true,
"services": [

View file

@ -13,6 +13,4 @@
## Package_check results
---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wikijs_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wikijs_ynh%20PR-NUM-%20(USERNAME)/)
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*

View file

@ -33,6 +33,7 @@ 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=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP

View file

@ -51,7 +51,6 @@ 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=ldap_user --value=$ldap_user
ynh_app_setting_set --app=$app --key=ldap_password --value=$ldap_password
@ -136,20 +135,7 @@ ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH"
#=================================================
ynh_script_progression --message="Modifying a config file..."
config_file="$final_path/config.yml"
cp -f ../conf/config.sample.yml $config_file
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config_file"
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
#=================================================
# GENERIC FINALIZATION
@ -179,13 +165,14 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..."
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
@ -200,12 +187,8 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
ynh_script_progression --message="Sending ReadMe to admin..."
ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="../conf/ldap_message"
ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="../conf/ldap_message"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/ldap_message"
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/ldap_message"
ynh_send_readme_to_admin --app_message="../conf/ldap_message" --recipients="root" --type='install'
ynh_add_config --template="../conf/ldap_message" --destination="../conf/message_install"
ynh_send_readme_to_admin --app_message="../conf/message_install" --recipients="root" --type='install'
#=================================================
# END OF SCRIPT

View file

@ -32,7 +32,7 @@ ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user)
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..."
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi

View file

@ -19,10 +19,7 @@ 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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port)
@ -41,27 +38,6 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
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 ldap_user doesn't exist, retrieve it or create it
if [[ -z "$ldap_user" ]]; then
ldap_user="svc_${app}_ldap"
@ -84,6 +60,13 @@ ynh_psql_create_user $db_name $db_pwd
ynh_psql_test_if_first_run
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -91,14 +74,9 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
#Workaround to be remove in next version
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="HTTP Server:"
ynh_clean_setup () {
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -124,24 +102,24 @@ then
tmpdir="$(mktemp -d)"
rsync -a "$config_file" "$tmpdir/."
if [ -d "$final_path/.ssh" ]; then
rsync -a "$final_path/.ssh" "$tmpdir/."
fi
if [ -d "$final_path/data" ]; then
rsync -a "$final_path/data" "$tmpdir/."
fi
if [ -d "$final_path/.ssh" ]; then
rsync -a "$final_path/.ssh" "$tmpdir/."
fi
if [ -d "$final_path/data" ]; then
rsync -a "$final_path/data" "$tmpdir/."
fi
ynh_secure_remove --file="$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
rsync -a "$tmpdir/config.yml" "$final_path/."
if [ -d "$tmpdir/.ssh" ]; then
rsync -a "$tmpdir/.ssh" "$final_path/."
fi
if [ -d "$tmpdir/data" ]; then
rsync -a "$tmpdir/data" "$final_path/."
fi
if [ -d "$tmpdir/.ssh" ]; then
rsync -a "$tmpdir/.ssh" "$final_path/."
fi
if [ -d "$tmpdir/data" ]; then
rsync -a "$tmpdir/data" "$final_path/."
fi
fi
#=================================================
@ -176,16 +154,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
ynh_script_progression --message="Modifying a config file..."
config_file="$final_path/config.yml"
ynh_backup_if_checksum_is_different --file=$config_file
cp -f ../conf/config.sample.yml $config_file
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config_file"
ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml"
#=================================================
# SETUP SYSTEMD
@ -212,18 +181,6 @@ ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for Wiki.js" --log="/var/log/$app/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
@ -243,12 +200,8 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
ynh_script_progression --message="Sending ReadMe to admin..."
ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="../conf/ldap_message"
ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="../conf/ldap_message"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/ldap_message"
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/ldap_message"
ynh_send_readme_to_admin --app_message="../conf/ldap_message" --recipients="root" --type='upgrade'
ynh_add_config --template="../conf/ldap_message" --destination="../conf/message_upgrade"
ynh_send_readme_to_admin --app_message="../conf/message_upgrade" --recipients="root" --type='upgrade'
#=================================================
# END OF SCRIPT