mirror of
https://github.com/YunoHost-Apps/wallabag2_ynh.git
synced 2024-10-01 13:35:06 +02:00
Add app actions and app config
This commit is contained in:
parent
4d7912c900
commit
5cec281661
5 changed files with 190 additions and 0 deletions
20
actions.json
Normal file
20
actions.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
[{
|
||||
"id": "clear_cache",
|
||||
"name": "Clear the cache",
|
||||
"command": "/bin/bash scripts/actions/clear_cache",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Clean the cache of wallabag"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "clean_duplicate",
|
||||
"name": "Clean duplicates",
|
||||
"command": "/bin/bash scripts/actions/clean_duplicate",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Clean the articles list in case of duplicates."
|
||||
}
|
||||
}]
|
25
config_panel.json
Normal file
25
config_panel.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "Wallabag configuration panel",
|
||||
"version": "0.1",
|
||||
"panel": [{
|
||||
"name": "Users registration",
|
||||
"id": "users_registration",
|
||||
"sections": [{
|
||||
"name": "Users registration",
|
||||
"id": "users_registration",
|
||||
"options": [{
|
||||
"name": "Public registration",
|
||||
"id": "fosuser_registration",
|
||||
"type": "bool",
|
||||
"help": "True to enable public registration",
|
||||
"default": false
|
||||
}, {
|
||||
"name": "Email confirmation",
|
||||
"id": "fosuser_confirmation",
|
||||
"type": "bool",
|
||||
"help": "True to send a confirmation by email for each registration",
|
||||
"default": true
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}
|
34
scripts/actions/clean_duplicate
Normal file
34
scripts/actions/clean_duplicate
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_ID
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# CLEAR THE CACHE
|
||||
#=================================================
|
||||
|
||||
exec_console $app $final_path wallabag:clean-duplicates
|
34
scripts/actions/clear_cache
Normal file
34
scripts/actions/clear_cache
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_ID
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# CLEAR THE CACHE
|
||||
#=================================================
|
||||
|
||||
exec_console $app $final_path cache:clear
|
77
scripts/config
Executable file
77
scripts/config
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_ID
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC CODE
|
||||
#=================================================
|
||||
# DECLARE GENERIC FUNCTION
|
||||
#=================================================
|
||||
|
||||
wb_conf="$final_path/app/config/parameters.yml"
|
||||
|
||||
get_config_value() {
|
||||
option_name="$1"
|
||||
# Get the value of this option in the config file
|
||||
grep "$option_name:" "$wb_conf" | awk ' { print $2 } '
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||
#=================================================
|
||||
|
||||
show_config() {
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
echo "YNH_CONFIG_USERS_REGISTRATION_USERS_REGISTRATION_FOSUSER_REGISTRATION=$(get_config_value fosuser_registration)"
|
||||
echo "YNH_CONFIG_USERS_REGISTRATION_USERS_REGISTRATION_FOSUSER_CONFIRMATION=$(get_config_value fosuser_confirmation)"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# MODIFY THE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
apply_config() {
|
||||
old_fosuser_registration="$(get_config_value fosuser_registration)"
|
||||
old_fosuser_confirmation="$(get_config_value fosuser_confirmation)"
|
||||
new_fosuser_registration="${YNH_CONFIG_USERS_REGISTRATION_USERS_REGISTRATION_FOSUSER_REGISTRATION:-$old_fosuser_registration}"
|
||||
new_fosuser_confirmation="${YNH_CONFIG_USERS_REGISTRATION_USERS_REGISTRATION_FOSUSER_CONFIRMATION:-$old_fosuser_confirmation}"
|
||||
|
||||
# If 'fosuser_registration' has been changed, modify the config file
|
||||
if [ "$old_fosuser_registration" != "$new_fosuser_registration" ]
|
||||
then
|
||||
ynh_replace_string "fosuser_registration: .*" "fosuser_registration: $new_fosuser_registration" "$wb_conf"
|
||||
fi
|
||||
|
||||
if [ "$old_fosuser_confirmation" != "$new_fosuser_confirmation" ]
|
||||
then
|
||||
ynh_replace_string "fosuser_confirmation: .*" "fosuser_confirmation: $new_fosuser_confirmation" "$wb_conf"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
|
||||
#=================================================
|
||||
|
||||
case $1 in
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
esac
|
Loading…
Add table
Reference in a new issue