1
0
mirror of https://github.com/elisspace/rtinst.git synced 2026-08-30 16:12:12 +00:00

Update rtsetpass

This commit is contained in:
arakasi72
2014-09-27 09:49:47 +01:00
parent d26b9f89b7
commit 2072e54d4e

View File

@@ -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