Update restart_rtorrent.sh

This commit is contained in:
Demonic 2022-05-13 09:34:50 +02:00
parent 06e90c55b9
commit aab44e79d4

View File

@ -1,27 +1,13 @@
#!/bin/bash
while getopts ":a:" opt; do
while getopts ":u:" opt; do
case "${opt}" in
a) user="${OPTARG}";;
u) user="${OPTARG}";;
esac
done
# A MODIFIER AVEC LES USERS SOUHAITES
# users=(stan thomas guenot denis)
# EXTRACTION DU PID DE RTORRENT DU USER
pid=$(ps -u $user -o pid,command | grep '[0-9] rtorrent$' | cut -d "r" -f1)
# A ADAPTER AU BESOIN
file=/home/$user/.session/rtorrent.lock
# EXTRACTION DU PID DE RTORRENT DU USER
pid=$(ps -u $user -o pid,command | grep '[0-9] rtorrent$' | cut -d "r" -f1)
# SI RTORRENT EST ACTIF LE PID NE SERA PAS VIDE
if [ ! $pid ];then
# ON SUPPRIME rtorrent.lock CAR CA EMPECHE RTORRENT DE DEMARRER
rm -f $file
# RESTART RTORRENT USER
bash /etc/init.d/$user-rtorrent restart
# LOG
echo "$(date) : le rtorrent de $user a ete redemarre" >> /var/log/rtorrent-check.log
fi
done
kill -9 $pid
/root/rtorrent-check