forked from mirrors/fancyindex
		
	first version
This commit is contained in:
		
						commit
						9d467e78c1
					
				
					 7 changed files with 254 additions and 0 deletions
				
			
		
							
								
								
									
										38
									
								
								src/cmd/addauth.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/cmd/addauth.sh
									
										
									
									
									
										Normal 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 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 fraoustin
						fraoustin