Files
rtinst/rtsetpass
T
2014-09-27 11:55:37 +01:00

25 lines
551 B
Bash

#!/bin/bash
parent_pid() {
# Look up the parent of the given PID.
pid=${1:-$$}
stat=($(</proc/${pid}/stat))
echo ${stat[3]}
}
user=$1
PARENT=$(parent_pid $PPID)
echo "Set rutorrent web interface password for $user"
if ! [ "$(ps --no-heading -o %c $PARENT)" = "rtpass" ]
then
echo "Can only be run using rtpass"
exit 1
elif [ -z "$(grep $user /var/www/rutorrent/.htpasswd)" ]
then
echo "Invalid user. Please contact your sysadmin for assistance"
exit 1
else
htpasswd /var/www/rutorrent/.htpasswd "$user"
fi