scripts/update/calibre.sh
2023-06-05 23:04:30 +08:00

18 lines
675 B
Bash

#!/bin/bash
# get the pid of calibre, and write it into file /tmp/calibre_pids
ps -ef | grep '/opt/apps/calibre/venv/bin/cps' | grep -v grep | awk '{print $2}' > /tmp/calibre_pids
# if not exist, signifying that there is no calibre process
if [[ ! -s /tmp/calibre_pids ]]; then
echo -e "\e[1;31mCannot terminate Calibre process cause there is no such things, will run calibre later automatically.\e[0m"
else
for calibre_pid in `cat /tmp/calibre_pids`; do
kill -9 $calibre_pid > /dev/null 2>&1
done
fi
nohup /opt/apps/calibre/venv/bin/python /opt/apps/calibre/venv/bin/cps > /dev/null 2>&1 &
echo -e "\e[1;32mCalibre process started successfully\e[0m"