first version

This commit is contained in:
fraoustin 2018-07-03 21:12:36 +02:00
commit 9d467e78c1
7 changed files with 254 additions and 0 deletions

38
src/cmd/addauth.sh Normal file
View file

@ -0,0 +1,38 @@
#!/bin/bash
FPASS="/etc/nginx/.htpasswd"
error(){
echo "ERROR : parameters invalid !" >&2
exit 1
}
usage(){
echo "Usage: addauth user password"
echo "--help or -h : view help"
}
load(){
if [ ! -f $FPASS ]; then
htpasswd -bc $FPASS $1 $2
else
htpasswd -b $FPASS $1 $2
fi
}
# no parameters
[[ $# -lt 1 ]] && error
case "$1" in
--help)
usage
;;
-h)
usage
;;
*)
[[ $# -ne 2 ]] && error
load $1 $2
esac