29 lines
1.1 KiB
Bash
Executable File
29 lines
1.1 KiB
Bash
Executable File
#!/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
|
|
|