diff --git a/empty_library/metadata.db b/empty_library/metadata.db new file mode 100644 index 0000000..ab66a70 Binary files /dev/null and b/empty_library/metadata.db differ diff --git a/empty_library/metadata_db_prefs_backup.json b/empty_library/metadata_db_prefs_backup.json new file mode 100644 index 0000000..d182b15 --- /dev/null +++ b/empty_library/metadata_db_prefs_backup.json @@ -0,0 +1,590 @@ +{ + "field_metadata": { + "cover": { + "label": "cover", + "kind": "field", + "search_terms": [ + "cover" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "int", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 17, + "column": null, + "name": "Couverture" + }, + "uuid": { + "label": "uuid", + "kind": "field", + "search_terms": [ + "uuid" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 16, + "column": null, + "name": null + }, + "series": { + "label": "series", + "kind": "field", + "search_terms": [ + "series" + ], + "table": "series", + "is_multiple": {}, + "is_csp": false, + "datatype": "series", + "link_column": "series", + "is_custom": false, + "category_sort": "(title_sort(name))", + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 8, + "column": "name", + "name": "S\u00e9rie" + }, + "pubdate": { + "label": "pubdate", + "kind": "field", + "search_terms": [ + "pubdate" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "datetime", + "is_custom": false, + "display": { + "date_format": "MMM yyyy" + }, + "is_category": false, + "is_editable": true, + "rec_index": 15, + "column": null, + "name": "Publi\u00e9" + }, + "au_map": { + "label": "au_map", + "kind": "field", + "search_terms": [], + "table": null, + "is_multiple": { + "list_to_ui": null, + "ui_to_list": null, + "cache_to_list": "," + }, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 18, + "column": null, + "name": null + }, + "rating": { + "label": "rating", + "kind": "field", + "search_terms": [ + "rating" + ], + "table": "ratings", + "is_multiple": {}, + "is_csp": false, + "datatype": "rating", + "link_column": "rating", + "is_custom": false, + "category_sort": "rating", + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 5, + "column": "rating", + "name": "Note" + }, + "news": { + "label": "news", + "kind": "category", + "search_terms": [], + "table": "news", + "is_multiple": {}, + "is_csp": false, + "datatype": null, + "is_custom": false, + "category_sort": "name", + "display": {}, + "is_category": true, + "is_editable": true, + "column": "name", + "name": "Actualit\u00e9s" + }, + "authors": { + "label": "authors", + "kind": "field", + "search_terms": [ + "authors", + "author" + ], + "table": "authors", + "is_multiple": { + "list_to_ui": " & ", + "ui_to_list": "&", + "cache_to_list": "," + }, + "is_csp": false, + "datatype": "text", + "link_column": "author", + "is_custom": false, + "category_sort": "sort", + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 2, + "column": "name", + "name": "Auteurs" + }, + "timestamp": { + "label": "timestamp", + "kind": "field", + "search_terms": [ + "date" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "datetime", + "is_custom": false, + "display": { + "date_format": "dd MMM yyyy" + }, + "is_category": false, + "is_editable": true, + "rec_index": 3, + "column": null, + "name": "Date" + }, + "sort": { + "label": "sort", + "kind": "field", + "search_terms": [ + "title_sort" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 11, + "column": null, + "name": "Tri par titre" + }, + "tags": { + "label": "tags", + "kind": "field", + "search_terms": [ + "tags", + "tag" + ], + "table": "tags", + "is_multiple": { + "list_to_ui": ", ", + "ui_to_list": ",", + "cache_to_list": "," + }, + "is_csp": false, + "datatype": "text", + "link_column": "tag", + "is_custom": false, + "category_sort": "name", + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 6, + "column": "name", + "name": "\u00c9tiquettes" + }, + "publisher": { + "label": "publisher", + "kind": "field", + "search_terms": [ + "publisher" + ], + "table": "publishers", + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "link_column": "publisher", + "is_custom": false, + "category_sort": "name", + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 9, + "column": "name", + "name": "\u00c9diteur" + }, + "title": { + "label": "title", + "kind": "field", + "search_terms": [ + "title" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 1, + "column": null, + "name": "Titre" + }, + "marked": { + "label": "marked", + "kind": "field", + "search_terms": [ + "marked" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 23, + "column": null, + "name": null + }, + "formats": { + "label": "formats", + "kind": "field", + "search_terms": [ + "formats", + "format" + ], + "table": null, + "is_multiple": { + "list_to_ui": ", ", + "ui_to_list": ",", + "cache_to_list": "," + }, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 13, + "column": null, + "name": "Formats" + }, + "languages": { + "label": "languages", + "kind": "field", + "search_terms": [ + "languages", + "language" + ], + "table": "languages", + "is_multiple": { + "list_to_ui": ", ", + "ui_to_list": ",", + "cache_to_list": "," + }, + "is_csp": false, + "datatype": "text", + "link_column": "lang_code", + "is_custom": false, + "category_sort": "lang_code", + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 21, + "column": "lang_code", + "name": "Langues" + }, + "id": { + "label": "id", + "kind": "field", + "search_terms": [ + "id" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "int", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 0, + "column": null, + "name": null + }, + "ondevice": { + "label": "ondevice", + "kind": "field", + "search_terms": [ + "ondevice" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 22, + "column": null, + "name": "Sur le dispositif" + }, + "size": { + "label": "size", + "kind": "field", + "search_terms": [ + "size" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "float", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 4, + "column": null, + "name": "Taille" + }, + "identifiers": { + "label": "identifiers", + "kind": "field", + "search_terms": [ + "identifiers", + "identifier", + "isbn" + ], + "table": null, + "is_multiple": { + "list_to_ui": ", ", + "ui_to_list": ",", + "cache_to_list": "," + }, + "is_csp": true, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": true, + "is_editable": true, + "rec_index": 20, + "column": null, + "name": "Identifiants" + }, + "series_index": { + "label": "series_index", + "kind": "field", + "search_terms": [ + "series_index" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "float", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 10, + "column": null, + "name": null + }, + "author_sort": { + "label": "author_sort", + "kind": "field", + "search_terms": [ + "author_sort" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 12, + "column": null, + "name": "Tri par auteur" + }, + "last_modified": { + "label": "last_modified", + "kind": "field", + "search_terms": [ + "last_modified" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "datetime", + "is_custom": false, + "display": { + "date_format": "dd MMM yyyy" + }, + "is_category": false, + "is_editable": true, + "rec_index": 19, + "column": null, + "name": "Modifi\u00e9" + }, + "path": { + "label": "path", + "kind": "field", + "search_terms": [], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 14, + "column": null, + "name": "Chemin" + }, + "series_sort": { + "label": "series_sort", + "kind": "field", + "search_terms": [ + "series_sort" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 24, + "column": null, + "name": "Tri par s\u00e9rie" + }, + "comments": { + "label": "comments", + "kind": "field", + "search_terms": [ + "comments", + "comment" + ], + "table": null, + "is_multiple": {}, + "is_csp": false, + "datatype": "text", + "is_custom": false, + "display": {}, + "is_category": false, + "is_editable": true, + "rec_index": 7, + "column": null, + "name": "Commentaires" + } + }, + "saved_searches": {}, + "bools_are_tristate": true, + "tag_browser_hidden_categories": [], + "library_view books view state": { + "last_modified_injected": true, + "hidden_columns": [ + "last_modified", + "languages" + ], + "sort_history": [ + [ + "authors", + true + ], + [ + "series", + true + ], + [ + "title", + true + ], + [ + "authors", + true + ], + [ + "series", + true + ], + [ + "title", + true + ], + [ + "timestamp", + false + ] + ], + "column_sizes": { + "tags": 101, + "rating": 60, + "languages": 0, + "last_modified": 0, + "timestamp": 72, + "publisher": 81, + "size": 104, + "series": 63, + "title": 60, + "pubdate": 71, + "authors": 95 + }, + "column_positions": { + "tags": 6, + "rating": 5, + "languages": 11, + "last_modified": 10, + "timestamp": 3, + "publisher": 8, + "ondevice": 0, + "size": 4, + "series": 7, + "title": 1, + "pubdate": 9, + "authors": 2 + }, + "languages_injected": true, + "column_alignment": { + "size": "center", + "timestamp": "center", + "pubdate": "center" + } + }, + "grouped_search_terms": {}, + "user_categories": {} +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 52a2847..d3fdb45 100644 --- a/manifest.json +++ b/manifest.json @@ -26,7 +26,7 @@ "install" : [ { "name": "domain", - "type": "domain", + "type": "domain", "ask": { "en": "Choose a domain name for BicBucStriim", "fr": "Choisissez un nom de domaine pour BicBucStriim" @@ -35,7 +35,7 @@ }, { "name": "path", - "type": "path", + "type": "path", "ask": { "en": "Choose a path for BicBucStriim", "fr": "Choisissez un chemin pour BicBucStriim" @@ -45,13 +45,21 @@ }, { "name": "admin", - "type": "user", + "type": "user", "ask": { "en": "Choose an admin user", "fr": "Choisissez l’administrateur" }, "example": "johndoe" }, + { + "name": "admin_pwd", + "type": "password", + "ask": { + "en": "Choose a password for the admin user", + "fr": "Choisissez un mot de passe pour l’administrateur" + } + }, { "name": "login", "type": "boolean", diff --git a/scripts/backup b/scripts/backup index af8ccd9..cceb424 100644 --- a/scripts/backup +++ b/scripts/backup @@ -12,6 +12,9 @@ source /usr/share/yunohost/helpers # Backup sources & data # Note: the last argument is where to save this path, see the restore script. ynh_backup "/var/www/${app}" "sources" +admin=$(ynh_app_setting_get "$app" admin) +books_path=/home/$admin/calibre_library +ynh_backup "$books_path" "data" ### MySQL (remove if not used) ### # If a MySQL database is used: diff --git a/scripts/install b/scripts/install index e717c6f..5b828d3 100644 --- a/scripts/install +++ b/scripts/install @@ -20,6 +20,7 @@ path=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC login=$YNH_APP_ARG_LOGIN +admin_pwd=$YNH_APP_ARG_ADMIN_PWD # Source YunoHost helpers source /usr/share/yunohost/helpers @@ -32,15 +33,23 @@ ynh_app_setting_set "$app" is_public "$is_public" sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" +# Install dependencies +if ! ynh_package_is_installed "php5-sqlite" ; then + ynh_package_install php5-sqlite +fi + # Copy source files src_path=/var/www/$app sudo mkdir -p $src_path -sudo wget -P "$src_path" http://projekte.textmulch.de/bicbucstriim/downloads/BicBucStriim-1.3.6.zip -O "$src_path"/bbs.zip +sudo wget -q -P "$src_path" http://projekte.textmulch.de/bicbucstriim/downloads/BicBucStriim-1.3.6.zip -O "$src_path"/bbs.zip sudo unzip -q "$src_path"/bbs.zip -d "$src_path" sudo cp -R "$src_path"/BicBucStriim-1.3.6/* "$src_path" sudo rm "$src_path"/bbs.zip sudo rm -rf "$src_path"/BicBucStriim-1.3.6 +books_path=/home/$admin/calibre_library +cp -r ../empty_library $books_path + # Disable BicBucStriim login if checked if [[ $login -eq 1 ]]; then sudo sed -i -- 's/\[LOGIN_REQUIRED\] = 1/\[LOGIN_REQUIRED\] = 0/g' "$src_path"/index.php @@ -49,7 +58,23 @@ fi # Set permissions to app files sudo chown -R root: $src_path sudo chmod -R ga+w $src_path/data +sudo chown -R $admin "$books_path" +cp password.php $src_path/ynh_password.php +cd $src_path +hash=$(php ynh_password.php $admin_pwd) +rm ynh_password.php +cd - +mail=$(ynh_user_get_info $admin mail) +if ! ynh_package_is_installed "sqlite3" ; then + ynh_package_install sqlite3 + echo "INSERT INTO config (name, val) VALUES ('calibre_dir', '$books_path');" | sqlite3 $src_path/data/data.db + echo "UPDATE user SET username = '$admin', password = '$hash', email='$mail' WHERE id = 1;" | sqlite3 $src_path/data/data.db + ynh_package_remove sqlite3 +else + echo "INSERT INTO config (name, val) VALUES ('calibre_dir', '$books_path');" | sqlite3 $src_path/data/data.db + echo "UPDATE user SET username = '$admin', password = '$hash', email='$mail' WHERE id = 1;" | sqlite3 $src_path/data/data.db +fi # Modify Nginx configuration file and copy it to Nginx conf directory nginx_conf=../conf/nginx.conf @@ -61,6 +86,8 @@ sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set "$app" unprotected_uris "/" +else + ynh_app_setting_set "$app" skipped_uris "/img/,/js/,/style/" fi # Reload services diff --git a/scripts/password.php b/scripts/password.php new file mode 100644 index 0000000..4769f90 --- /dev/null +++ b/scripts/password.php @@ -0,0 +1,6 @@ + diff --git a/scripts/remove b/scripts/remove index 9a5dc51..667bfef 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,10 +8,18 @@ source /usr/share/yunohost/helpers # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) +admin=$(ynh_app_setting_get "$app" admin) +books_path=/home/$admin/calibre_library + +# Remove php5-sqlite dependency +ynh_package_remove php5-sqlite # Remove sources sudo rm -rf /var/www/$app +# Remove calibre library +sudo rm -rf $books_path + # Remove nginx configuration file sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf diff --git a/scripts/restore b/scripts/restore index a83fa6d..9df957c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers # Retrieve old app settings domain=$(ynh_app_setting_get "$app" domain) path=$(ynh_app_setting_get "$app" path) +admin=$(ynh_app_setting_get "$app" admin) # Check domain/path availability sudo yunohost app checkurl "${domain}${path}" -a "$app" \ @@ -24,9 +25,13 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \ src_path="/var/www/${app}" sudo cp -a ./sources "$src_path" +books_path=/home/$admin/calibre_library +sudo cp -a ./data "$books_path" + # Restore permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) sudo chown -R root: "$src_path" +sudo chown -R $admin "$books_path" ### MySQL (remove if not used) ### # If a MySQL database is used: