1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/calibreweb_ynh.git synced 2024-09-03 18:16:20 +02:00
This commit is contained in:
Krakinou 2019-01-12 11:36:30 +01:00
parent 13ba7b2803
commit c1f803b8d5
3 changed files with 41 additions and 39 deletions

View file

@ -40,18 +40,6 @@
}, },
"example": "/calibre", "example": "/calibre",
"default": "/calibre" "default": "/calibre"
},
{
"name": "calibre_path",
"ask": {
"en": "Select the folder containing the Calibre library",
"fr": "Choisissez le répertoire contenant la bibliothèque Calibre"
},
"help": {
"en": "This folder should have read write access. It will be created if it does not exist.",
"fr": "Le répertoire doit être accessible en lecture écriture, il sera créé s'il n'existe pas."
},
"default": "/home/yunohost.app/calibreweb"
}, },
{ {
"name": "admin", "name": "admin",
@ -73,6 +61,7 @@
}, },
{ {
"name": "language", "name": "language",
"optional": true,
"ask": { "ask": {
"en": "Select a default language (you may change it later in the app)", "en": "Select a default language (you may change it later in the app)",
"fr": "Choisissez une langue par défaut (vous pourrez la changer ultérieurement dans l'application)" "fr": "Choisissez une langue par défaut (vous pourrez la changer ultérieurement dans l'application)"
@ -82,13 +71,24 @@
}, },
{ {
"name": "upload", "name": "upload",
"type":"boolean", "type":"boolean",
"optional": true,
"ask": { "ask": {
"en": "Do you want to allow uploading of books (you may change it later in the app)?", "en": "Do you want to allow uploading of books (you may change it later in the app)?",
"fr": "Voulez vous autoriser l'upload de livres (vous pourrez le changer ultérieurement dans l'application)?" "fr": "Voulez vous autoriser l'upload de livres (vous pourrez le changer ultérieurement dans l'application)?"
}, },
"default": false "default": false
}, },
{
"name": "public_library",
"type":"boolean",
"optional": true,
"ask": {
"en": "Do you want to allow access to the library to all Yunohost users?",
"fr": "Voulez vous autoriser l'accès à la bibliothèque à tous les utilisateurs Yunohost?"
},
"default": false
},
{ {
"name": "password", "name": "password",
"type": "password", "type": "password",

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
pkg_dependencies="sqlite3 python-pip imagemagick" PKG_DEPENDENCIES="sqlite3 python-pip imagemagick"
DOSSIER_MEDIA=/home/yunohost.multimedia
create_dir=0 create_dir=0
@ -101,7 +102,7 @@ ynh_systemd_action() {
# usage: ynh_multimedia_build_main_dir # usage: ynh_multimedia_build_main_dir
ynh_multimedia_build_main_dir () { ynh_multimedia_build_main_dir () {
local ynh_media_release="v1.2" local ynh_media_release="v1.2"
local checksum="b933c446b4aff8a7619804480c06a879" local checksum="806a827ba1902d6911095602a9221181"
# Download yunohost.multimedia scripts # Download yunohost.multimedia scripts
wget -nv https://github.com/Krakinou/yunohost.multimedia/archive/${ynh_media_release}.tar.gz wget -nv https://github.com/Krakinou/yunohost.multimedia/archive/${ynh_media_release}.tar.gz

View file

@ -29,9 +29,8 @@ ynh_print_OFF
pass=$YNH_APP_ARG_PASSWORD pass=$YNH_APP_ARG_PASSWORD
ynh_print_ON ynh_print_ON
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#removing / at the end for consistency upload=$6
calibre_dir=${3%/} public_library=$7
upload=$7
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
@ -56,7 +55,7 @@ ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app calibre_dir $calibre_dir
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -80,13 +79,12 @@ ynh_print_info "Downloading sources to $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 "$final_path" ynh_setup_source "$final_path"
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies and pip packages" ynh_print_info "Installing dependencies and pip packages"
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $PKG_DEPENDENCIES
pip install --target $final_path/vendor -r $final_path/requirements.txt pip install --target $final_path/vendor -r $final_path/requirements.txt
#================================================= #=================================================
@ -120,24 +118,30 @@ ynh_add_systemd_config
# CREATE FILES AND DIRECTORIES # CREATE FILES AND DIRECTORIES
#================================================= #=================================================
#Logic is as follow : if app is set to be publicly accessible, we will assume that the library should be set in "Share" multimedia directory
# If app is set to be private but access is requested for all user, we will assume the same
# If app is set to be private but access is limited to the admin user, we will set it inside his own multimedia directory.
# Access to the app is managed in the SSOwat part of the script.
#Check if library folder exists. If not create it #build multimedia directory
if [ ! -e "$calibre_dir" ]; then ynh_multimedia_build_main_dir
ynh_print_info "Create calibre library folder $calibre_dir" ynh_multimedia_addaccess $app
mkdir -p $calibre_dir
chown -R $app:$app $calibre_dir if [ $is_public -eq 1 ]; then #app is public, library is public
create_dir=1 calibre_dir=$DOSSIER_MEDIA/Share/eBook
elif [$is_public -eq 0 ] && [ $public_library -eq 1 ]; then #app is private, library is public
calibre_dir=$DOSSIER_MEDIA/Share/eBook
else #app is private, library is private
calibre_dir=$DOSSIER_MEDIA/$admin/eBook
fi fi
#Check if metadata.db file exists. If not create it (empty library) #Check if metadata.db file exists. If not create it (empty library)
if [ ! -e "$calibre_dir"/metadata.db ]; then if [ ! -e "$calibre_dir"/metadata.db ]; then
cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db
chown $app:$app $calibre_dir/* chown $app:$app $calibre_dir/*
fi fi
ynh_app_setting_set $app calibre_dir $calibre_dir
ynh_multimedia_build_main_dir
#ynh_multimedia_addaccess $app
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -210,6 +214,11 @@ then
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set $app unprotected_uris "/"
fi fi
if [ $public_library -eq 0 ]; then
yunohost app addaccess $app -u $admin
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
@ -217,11 +226,3 @@ fi
ynh_print_info "Reload nginx and start $app" ynh_print_info "Reload nginx and start $app"
systemctl reload nginx systemctl reload nginx
ynh_systemd_action -l "INFO in server: Starting Gevent server" ynh_systemd_action -l "INFO in server: Starting Gevent server"
#=================================================
# WARNING FOR READ ACCESS
#=================================================
if [[ $create_dir = 0 ]] ; then
ynh_print_warn "Please, give required access to $app user to the $calibre_dir folder."
fi