1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kiwix_ynh.git synced 2024-09-03 19:35:56 +02:00

Merge pull request #17 from YunoHost-Apps/testing

Testing
This commit is contained in:
Éric Gaspar 2023-08-13 20:21:23 +02:00 committed by GitHub
commit b7788c7dc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 66 additions and 76 deletions

View file

@ -28,7 +28,7 @@ Kiwix is an offline reader for online content like Wikipedia, Project Gutenberg,
- Able to deal with one ZIM file or XML library files
**Shipped version:** 3.5.0~ynh3
**Shipped version:** 3.5.0~ynh4
**Demo:** http://library.kiwix.org/

View file

@ -26,7 +26,7 @@ Kiwix est un lecteur hors-ligne pour contenus web qui permet en particulier d
- Embedded in Kiwix UI
- Capable de traiter un fichier ZIM ou des fichiers de bibliothèque XML
**Version incluse :** 3.5.0~ynh3
**Version incluse :** 3.5.0~ynh4
**Démo :** http://library.kiwix.org/

View file

@ -5,8 +5,7 @@ Description=Kiwix: Sharing Web content
Type=simple
User=__APP__
Group=__APP__
ExecStart=__INSTALL_DIR__/kiwix-serve --daemon --address 127.0.0.1 --port __PORT__ --library __DATA_DIR__/library.xml --urlRootLocation=__PATH__/
RemainAfterExit=yes
ExecStart=__INSTALL_DIR__/kiwix-serve --address 127.0.0.1 --port __PORT__ --library __DATA_DIR__/library.xml --urlRootLocation=__PATH__/
Restart=on-abort
RestartSec=5s

19
config_panel.toml Normal file
View file

@ -0,0 +1,19 @@
version = "1.0"
[main]
name.en = "Upload content"
[main.upload]
[main.upload.upload_url]
default = ""
type = "string"
ask.en = "Content URL"
help.en = "For example: https://download.kiwix.org/zim/other/pokepedia_fr_all_maxi_2021-01.zim"
help.fr = "Par exemple : https://download.kiwix.org/zim/other/pokepedia_fr_all_maxi_2021-01.zim"
[main.upload.upload_button]
ask.en = "Upload"
type = "button"
style = "success"
enabled = "upload_url"

View file

@ -1,5 +1,9 @@
### How to add zim files?
#### Add a zin file through its URL
- Click on the "Upload content" tab above.
#### Add a zim file by hand
- Download one or more ZIM files, e.g. from [https://download.kiwix.org/zim/](https://download.kiwix.org/zim/)
- Put the ZIM files into `__DATA_DIR__`
- Add them to the library with the following command:

View file

@ -1,5 +1,9 @@
### Comment ajouter des fichiers ZIM ?
#### Ajouter un fichier ZIM via son URL
- Sélectionnez l'onglet "Upload content" qui se trouve ci-dessus.
#### Ajouter un fichier ZIM à la main
- Téléchargez un ou plusieurs fichiers ZIM, par ex. [https://download.kiwix.org/zim/](https://download.kiwix.org/zim/)
- Mettez les fichiers ZIM dans `__DATA_DIR__/`
- Ajoutez-les à la bibliothèque avec la commande suivante :

View file

@ -5,7 +5,7 @@ name = "Kiwix"
description.en = "Sharing Web content with people without Internet access"
description.fr = "Partager du contenu Web avec des personnes sans accès à Internet"
version = "3.5.0~ynh3"
version = "3.5.0~ynh4"
maintainers = ["eric_G"]
@ -23,13 +23,12 @@ multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "50M"
ram.build = "100M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
full_domain = true
[install.init_main_permission]
type = "group"

15
scripts/config Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
source /usr/share/yunohost/helpers
ynh_abort_if_errors
function run__upload_button() {
local data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
local filename="$(echo "$upload_url" | awk -F/ '{print $NF}')"
ynh_print_info --message="Downloading file…"
wget --tries 3 --no-dns-cache --timeout 900 --output-document="$data_dir/$filename" "$upload_url" 2>&1
ynh_print_info --message="Adding file to Kiwix library"
$install_dir/kiwix-manage $data_dir/library.xml add "$data_dir/$filename"
yunohost service restart kiwix
}
ynh_app_config_run $1

View file

@ -23,13 +23,18 @@ chown -R $app:www-data "$install_dir"
chmod +x $install_dir/{kiwix-manage,kiwix-serve,kiwix-search}
#=================================================
# NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add $app --description="Internet without Internet access" --log="systemd"
#=================================================
# CREATE DATA DIRECTORY
#=================================================
@ -38,25 +43,9 @@ ynh_script_progression --message="Creating a data directory..." --weight=1
pushd $data_dir
ynh_exec_warn_less ynh_exec_as $app curl -LO https://download.kiwix.org/zim/wikipedia/wikipedia_fr_climate_change_mini_2023-04.zim > /dev/null
popd
ynh_exec_warn_less ynh_exec_as $app $install_dir/kiwix-manage $data_dir/library.xml add $data_dir/*.zim
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --log="systemd"
#=================================================
# START SYSTEMD SERVICE
#=================================================

View file

@ -10,10 +10,11 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# 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
@ -22,19 +23,9 @@ then
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config

View file

@ -10,15 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
@ -26,8 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
@ -40,21 +29,16 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory
chown -R $app:www-data "$data_dir"
#=================================================
# SPECIFIC RESTORATION
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --log="systemd"
yunohost service add $app --description="Internet without Internet access" --log="systemd"
#=================================================
# START SYSTEMD SERVICE

View file

@ -37,35 +37,21 @@ then
ynh_setup_source --dest_dir="$install_dir"
fi
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x $install_dir/{kiwix-manage,kiwix-serve,kiwix-search}
#=================================================
# NGINX CONFIGURATION
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=3
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add $app --log="systemd"
yunohost service add $app --description="Internet without Internet access" --log="systemd"
#=================================================
# START SYSTEMD SERVICE