diff --git a/conf/init_calibre_db_ldap_settings b/conf/init_calibre_db_ldap_settings index 6652c9f..b0f6871 100644 --- a/conf/init_calibre_db_ldap_settings +++ b/conf/init_calibre_db_ldap_settings @@ -2,8 +2,8 @@ config_login_type=1, config_ldap_provider_url=\'localhost\', config_ldap_port=389, config_ldap_schema=\'ldap\', -config_ldap_serv_username=\'toto\', -config_ldap_serv_password=\'titi\', +config_ldap_serv_username=\'nicolas\', +config_ldap_serv_password=\'eXVub2hvc3RfZGV2\', config_ldap_dn=\'ou=users,dc=yunohost,dc=org\', config_ldap_user_object=\'uid=%s\', config_ldap_openldap=1 \ No newline at end of file diff --git a/conf/init_calibre_db_settings b/conf/init_calibre_db_settings index 2853f5d..24690a0 100644 --- a/conf/init_calibre_db_settings +++ b/conf/init_calibre_db_settings @@ -8,7 +8,7 @@ config_use_goodreads=0, config_logfile=\'\', config_converterpath=\'\', config_calibre=\'\', -config_logfile=\'/var/log/calibreweb/calibreweb.log\', +config_logfile=\'$LOG_FILE\', config_access_log=1, -config_access_logfile=\'/var/log/calibreweb/calibreweb-access.log\', +config_access_logfile=\'$ACCESS_LOG_FILE\', config_uploading=\'$upload\' \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index 4b60a68..d166c60 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=/bin/sh -c '/usr/bin/python __FINALPATH__/cps.py' +ExecStart=/bin/sh -c '/usr/bin/python3.5 __FINALPATH__/cps.py' [Install] WantedBy=multi-user.target diff --git a/scripts/_common.sh b/scripts/_common.sh index 6d2551a..349ee53 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,9 +1,5 @@ #!/bin/bash -PKG_DEPENDENCIES="sqlite3 python-pip imagemagick" -DOSSIER_MEDIA=/home/yunohost.multimedia -create_dir=0 - get_db() { # $1 = nom de la table # cette ligne de malade : @@ -20,84 +16,6 @@ get_db() { # TO BE DELETED WHEN RELEASED #================================================= -#================================================= -#YNH_SYSTEMD_ACTION -#================================================= - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_system_reload service_name [action] -# | arg: -n, --service_name= - Name of the service to reload. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout - - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - local wait_starting=true - - if [[ -z "${line_match:-}" ]] - then - wait_starting=false - fi - - ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 - } - - echo "Starting of $service_name" >&2 - systemctl $action $service_name || ( journalctl --lines=$length -u $service_name >&2 && false) - - if $wait_starting - then - # Following the starting of the app in its log - local templog="$(mktemp)" - tail -F -n1 "$log_path" > "$templog" & - # Get the PID of the tail command - local pid_tail=$! - - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - journalctl --lines=$length -u $service_name >&2 - fi - - echo "" - ynh_clean_check_starting - fi -} #================================================= diff --git a/scripts/_settings.sh b/scripts/_settings.sh new file mode 100644 index 0000000..79faedc --- /dev/null +++ b/scripts/_settings.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +PKG_DEPENDENCIES="sqlite3 python3-pip imagemagick" +DOSSIER_MEDIA=/home/yunohost.multimedia +create_dir=0 +LOG_FILE=/var/log/$app/$app.log +ACCESS_LOG_FILE=/var/log/$app/$app-access.log \ No newline at end of file diff --git a/scripts/install b/scripts/install index 91c7b31..f91a11b 100755 --- a/scripts/install +++ b/scripts/install @@ -32,6 +32,8 @@ public_library=$7 if [ $is_public -eq 1 ]; then public_library=1 fi +source _settings.sh + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -86,8 +88,8 @@ ynh_setup_source "$final_path" ynh_print_info "Installing dependencies and pip packages" 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/optional-requirements.txt +pip3 install --no-cache-dir --target $final_path/vendor -r $final_path/requirements.txt +pip3 install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/optional-requirements.txt #================================================= # NGINX CONFIGURATION @@ -162,15 +164,17 @@ chown -R $app:$app /var/log/$app ynh_print_info "Setting up database and settings" #we need to start and stop the service so that initial app.db file is created and that we can set default data -ynh_systemd_action -l "INFO in server: Starting Gevent server" +ynh_systemd_action #sleep required on low spec like raspberryPi -sleep 2s +sleep 5s ynh_systemd_action -a stop #set database settings as per conf file -conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))) $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" +#insertion of dummy value for config_ldap_serv_username and config_ldap_serv_password : required for calibreweb and simpleldap but not +#required by Yunohost ldap. +conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))), $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" conf="\"UPDATE user SET $(. <(echo -E echo $(<../conf/init_calibre_db_user))) WHERE ID=1\"" @@ -241,7 +245,8 @@ yunohost service add $app --log "/var/log/$app/$app.log" if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + #ynh_app_setting_set $app unprotected_uris "/" + ynh_permission_update --permission "main" --add visitors fi if [ $public_library -eq 0 ]; then yunohost app addaccess $app -u $admin diff --git a/scripts/restore b/scripts/restore index 4f9c05f..c1ea009 100755 --- a/scripts/restore +++ b/scripts/restore @@ -89,7 +89,8 @@ chown -R $app: $final_path # Define and install dependencies ynh_print_info "Installing dependencies and pip packages" ynh_install_app_dependencies $PKG_DEPENDENCIES -pip install --target $final_path/vendor -r $final_path/requirements.txt +#pip package not required as already in app directory +#pip install --target $final_path/vendor -r $final_path/requirements.txt #================================================= # ADVERTISE SERVICE IN ADMIN PANEL diff --git a/scripts/upgrade b/scripts/upgrade index 0c037a6..243e4ce 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,7 +80,8 @@ ynh_add_nginx_config #================================================= ynh_print_info "Download and install dependencies" ynh_install_app_dependencies $PKG_DEPENDENCIES -pip install --target $final_path/vendor -r $final_path/requirements.txt +pip3 install --no-cache-dir --target $final_path/vendor -r $final_path/requirements.txt +pip3 install --no-cache-dir --target $final_path/vendor -r $final_path/optional-requirements.txt #================================================= # CREATE DEDICATED USER @@ -111,9 +112,9 @@ ynh_multimedia_addaccess $app ynh_backup_if_checksum_is_different "$final_path/app.db" #set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap settings -ynh_systemd_action -l "INFO in server: Starting Gevent server" +ynh_systemd_action #sleep required on low spec like raspberryPi -sleep 2s +sleep 5s ynh_systemd_action -a stop conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" @@ -153,7 +154,8 @@ chown -R $app: $final_path if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set $app unprotected_uris "/" + #ynh_app_setting_set $app unprotected_uris "/" + ynh_permission_update --permission "main" --add visitors fi #================================================= @@ -169,4 +171,4 @@ fi #================================================= systemctl reload nginx -ynh_systemd_action -a restart -l "INFO in server: Starting Gevent server" +ynh_systemd_action -a restart diff --git a/sources/patches/app-optional-requirements.patch b/sources/patches/app-optional-requirements.patch new file mode 100644 index 0000000..1088286 --- /dev/null +++ b/sources/patches/app-optional-requirements.patch @@ -0,0 +1,37 @@ +--- a/optional-requirements.txt 2020-02-23 09:08:01.000000000 +0100 ++++ b/optional-requirements.txt 2020-04-13 10:50:30.317525119 +0200 +@@ -1,34 +1,3 @@ +-# GDrive Integration +-google-api-python-client==1.7.11,<1.8.0 +-gevent>=1.2.1,<1.5.0 +-greenlet>=0.4.12,<0.5.0 +-httplib2>=0.9.2,<0.18.0 +-oauth2client>=4.0.0,<4.14.0 +-uritemplate>=3.0.0,<3.1.0 +-pyasn1-modules>=0.0.8,<0.3.0 +-pyasn1>=0.1.9,<0.5.0 +-PyDrive>=1.3.1,<1.14.0 +-PyYAML>=3.12 +-rsa==3.4.2,<4.1.0 +-six>=1.10.0,<1.14.0 +- +-# goodreads +-goodreads>=0.3.2,<0.4.0 +-python-Levenshtein>=0.12.0,<0.13.0 +- + # ldap login + python_ldap>=3.0.0,<3.3.0 + flask-simpleldap>1.3.0,<1.5.0 +- +-#oauth +-flask-dance>=0.13.0 +-sqlalchemy_utils>=0.33.5,<0.37.0 +- +-# extracting metadata +-lxml>=3.8.0,<4.6.0 +-Pillow>=4.0.0,<7.1.0 +-rarfile>=2.7 +- +-# other +-natsort>=2.2.0,<7.1.0 +-git+https://github.com/OzzieIsaacs/comicapi.git@ad8bfe5a1c31db882480433f86db2c5c57634a3f#egg=comicapi