From 2072e54d4e693274ed35c01ecfc329f53ff7a5ff Mon Sep 17 00:00:00 2001 From: arakasi72 Date: Sat, 27 Sep 2014 09:49:47 +0100 Subject: [PATCH] Update rtsetpass --- rtsetpass | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/rtsetpass b/rtsetpass index 79bef1c..373f698 100644 --- a/rtsetpass +++ b/rtsetpass @@ -6,28 +6,17 @@ parent_pid() { echo ${stat[3]} } - user=$1 PARENT=$(parent_pid $PPID) -echo "On Ubuntu systems 13.10 and later, verify existing password" -echo "Debian and older Ubuntu releases just enter the new password" if [ "$(ps --no-heading -o %c $PARENT)" = "rtpass" ] then - htpasswd -v /var/www/rutorrent/.htpasswd "$user" 2> /dev/null - exitcond=$? - if [ $exitcond = 0 ] - then - htpasswd /var/www/rutorrent/.htpasswd "$user" - elif [ $exitcond = 2 ] && [ -n "$(grep $user /var/www/rutorrent/.htpasswd)" ] - then - htpasswd /var/www/rutorrent/.htpasswd "$user" - elif [ $exitcond = 3 ] - then - echo "Incorrect password" - elif [ ! -n "$(grep $user /var/www/rutorrent/.htpasswd)" ] - then - echo "Invalid user, contact your sysadmin for help" - fi + echo "Can only be run using rtpass" + exit 1 +elif [ -n "$(grep $user /var/www/rutorrent/.htpasswd)" ] + then + echo "Invalid user. Please contact your sysadmin for assistance" + exit 1 else - echo "Error: Can only be run from rtpass script" + htpasswd /var/www/rutorrent/.htpasswd "$user" fi +