Software / code / prosody-modules
Comparison
mod_rest/example/rest.sh @ 6344:eb834f754f57 draft default tip
Merge update
| author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
|---|---|
| date | Fri, 18 Jul 2025 20:45:38 +0700 |
| parent | 6329:c95dffd984a4 |
comparison
equal
deleted
inserted
replaced
| 6309:342f88e8d522 | 6344:eb834f754f57 |
|---|---|
| 16 } | 16 } |
| 17 | 17 |
| 18 # Settings | 18 # Settings |
| 19 HOST="" | 19 HOST="" |
| 20 DOMAIN="" | 20 DOMAIN="" |
| 21 PRINT="b" | |
| 21 | 22 |
| 22 SESSION="session-read-only" | 23 SESSION="session-read-only" |
| 23 | 24 |
| 24 if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then | 25 if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then |
| 25 # Config file can contain the above settings | 26 # Config file can contain the above settings |
| 26 source "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" | 27 source "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" |
| 27 | 28 |
| 28 if [ -z "${SCOPE:-}" ]; then | 29 if [ -z "${SCOPE:-}" ]; then |
| 29 SCOPE="openid xmpp" | 30 SCOPE="openid offline_access xmpp" |
| 30 fi | 31 fi |
| 31 fi | 32 fi |
| 32 | 33 |
| 33 if [[ $# == 0 ]]; then | 34 if [[ $# == 0 ]]; then |
| 34 usage | 35 usage |
| 35 exit 1 | 36 exit 1 |
| 36 fi | 37 fi |
| 37 | 38 |
| 38 while getopts 'r:h:' flag; do | 39 while getopts 'vr:h:' flag; do |
| 39 case "$flag" in | 40 case "$flag" in |
| 41 v) | |
| 42 case "$PRINT" in | |
| 43 b) | |
| 44 PRINT="Bb" | |
| 45 ;; | |
| 46 Bb) | |
| 47 PRINT="HBhb" | |
| 48 ;; | |
| 49 HBhb) | |
| 50 PRINT="HBhbm" | |
| 51 ;; | |
| 52 esac | |
| 53 ;; | |
| 40 r) | 54 r) |
| 41 case "$OPTARG" in | 55 case "$OPTARG" in |
| 42 o) | 56 o) |
| 43 # Default | 57 # Default |
| 44 SESSION="session-read-only" | 58 SESSION="session-read-only" |
| 86 if [[ "$1" == /* ]]; then | 100 if [[ "$1" == /* ]]; then |
| 87 GET_PATH="$1" | 101 GET_PATH="$1" |
| 88 shift 1 | 102 shift 1 |
| 89 fi | 103 fi |
| 90 | 104 |
| 91 https --check-status -p b --"$SESSION" rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@" | 105 https --check-status -p "$PRINT" --"$SESSION" rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@" |