You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
642 B
31 lines
642 B
![]()
3 years ago
|
#!/bin/bash
|
||
|
# ver_2; in /usr/local/bin/proxy-server
|
||
|
# users credentials script automatics
|
||
|
|
||
|
userfile=users.list
|
||
|
usr=$(echo $2 | tr '[:upper:]' '[:lower:]')
|
||
|
|
||
|
if [[ $1 = '' ]]; then
|
||
|
exit 1
|
||
|
elif [[ $2 = '' ]]; then
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
func1(){
|
||
|
pwgen -B -N 2 | tr -d '[:space:]'
|
||
|
}
|
||
|
passw=$(func1)
|
||
|
|
||
|
if [[ $1 = 'unvoke' ]]; then
|
||
|
sed -i "/$usr:/d" $userfile
|
||
|
echo "user $usr unvoked"
|
||
|
echo "users in list: $(cat $userfile | wc -l)"
|
||
|
elif [[ $1 = 'regen' ]]; then
|
||
|
sed -i "/$usr:/d" $userfile
|
||
|
echo "$usr:$passw" >> $userfile
|
||
|
echo "new $usr password: $passw"
|
||
|
echo "users in list: $(cat $userfile | wc -l)"
|
||
|
fi
|
||
|
unset passw
|
||
|
sudo systemctl restart proxy-server
|