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 #!/bin/bash
while getopts ":a:" opt; do while getopts ":u:" opt; do
case "${opt}" in case "${opt}" in
a) user="${OPTARG}";; u) user="${OPTARG}";;
esac esac
done done
# A MODIFIER AVEC LES USERS SOUHAITES # EXTRACTION DU PID DE RTORRENT DU USER
# users=(stan thomas guenot denis) pid=$(ps -u $user -o pid,command | grep '[0-9] rtorrent$' | cut -d "r" -f1)
# A ADAPTER AU BESOIN kill -9 $pid
file=/home/$user/.session/rtorrent.lock /root/rtorrent-check
# 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