commit 7f9032bf4787139f8c8074a2a58c5edb15482209 Author: nvpie exozyme Date: Mon May 22 07:19:10 2023 +0000 calibrary added diff --git a/calibrary b/calibrary new file mode 100755 index 0000000..aafbf1f --- /dev/null +++ b/calibrary @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ "$1" = "add" ] && [ -n "$2" ] && [ -n "$3" ]; then + printf "Adding book '$2' to library '$3'\n"; + systemctl --user stop calibre-server.service; + calibredb add "$2" --with-library "$3"; + systemctl --user daemon-reload; + systemctl --user restart calibre-server.service; + rm "$2"; +elif [ "$1" = "rm" ] && [ -n "$2" ] && [ -n "$3" ]; then + printf "Removing book '$2' from library '$3'\n"; + systemctl --user stop calibre-server.service; + calibredb remove "$2" --with-library "$3"; + systemctl --user daemon-reload; + systemctl --user restart calibre-server.service; +elif [ "$1" = "list" ] && [ -n "$2" ]; then + systemctl --user stop calibre-server.service; + calibredb list --with-library "$2"; + systemctl --user daemon-reload; + systemctl --user restart calibre-server.service; +elif [ "$1" = "help" ]; then + printf "add book.epub lib1 - adds the book to lib1\n"; + printf "rm book.epub lib2 - removes the book from lib2\n"; +else + printf "Invalid command. Use 'help'.\n"; + printf "Please provide bookname as the second argument.\nand library path as the third argument\n"; +fi +