mirror of
				https://github.com/usememos/memos.git
				synced 2025-10-31 08:46:39 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
	
		
			500 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			500 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/usr/bin/env sh
 | |
| 
 | |
| file_env() {
 | |
|    var="$1"
 | |
|    fileVar="${var}_FILE"
 | |
| 
 | |
|    val_var="$(printenv "$var")"
 | |
|    val_fileVar="$(printenv "$fileVar")"
 | |
| 
 | |
|    if [ -n "$val_var" ] && [ -n "$val_fileVar" ]; then
 | |
|       echo "error: both $var and $fileVar are set (but are exclusive)" >&2
 | |
|       exit 1
 | |
|    fi
 | |
| 
 | |
|    if [ -n "$val_var" ]; then
 | |
|       val="$val_var"
 | |
|    elif [ -n "$val_fileVar" ]; then
 | |
|       val="$(cat "$val_fileVar")"
 | |
|    fi
 | |
| 
 | |
|    export "$var"="$val"
 | |
|    unset "$fileVar"
 | |
| }
 | |
| 
 | |
| file_env "MEMOS_DSN"
 | |
| 
 | |
| exec "$@"
 |