mirror of
https://github.com/elisspace/rtinst.git
synced 2026-09-22 02:27:27 +00:00
25 lines
551 B
Bash
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
|