58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| ##@cooked comments # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
 | |
| ## Pilotage de wotaskd
 | |
| ##@cooked nocomments
 | |
| ##@require base
 | |
| ##@require sysinfos
 | |
| ##@require webobjects
 | |
| uprovide wotaskd
 | |
| urequire base sysinfos webobjects
 | |
| 
 | |
| WOT_DEFAULT_HOST=localhost
 | |
| WOT_DEFAULT_PORT="${WOTASKD_PORT:-1085}"
 | |
| 
 | |
| function __get_woturl() {
 | |
|     # $1 est un nom d'hôte de la forme host[:port]
 | |
|     # Le transfomer en url pour attaquer le wotaskd:
 | |
|     #     http://host:port/cgi-bin/WebObjects/wotaskd.woa/$2[&$3...]
 | |
|     # $2 est l'url relative à attaquer. Si $3 est spécifié, c'est le mot de
 | |
|     # passe pour l'accès au moniteur. Si $4...* sont spécifiés, ce sont d'autres
 | |
|     # paramètres.
 | |
|     local host port paramsep="?"
 | |
|     splitpair "$1" host port; shift
 | |
|     [ -n "$host" ] || host="$WOT_DEFAULT_HOST"
 | |
|     [ -n "$port" ] || port="$WOT_DEFAULT_PORT"
 | |
| 
 | |
|     local woturl="http://$host:$port/cgi-bin/WebObjects/wotaskd.woa"
 | |
|     if [ -n "$1" ]; then
 | |
|         [ "${1#/}" == "$1" ] && woturl="$woturl/"
 | |
|         woturl="$woturl$1"
 | |
|     fi; shift
 | |
|     if [ -n "$1" ]; then
 | |
|         woturl="$woturl${paramsep}pw=$1"
 | |
|         paramsep="&"
 | |
|     fi; shift
 | |
|     while [ -n "$1" ]; do
 | |
|         woturl="$woturl${paramsep}$1"; shift
 | |
|         paramsep="&"
 | |
|     done
 | |
|     echo "$woturl"
 | |
| }
 | |
| 
 | |
| function wot_config() {
 | |
|     # Afficher la configuration de wotaskd
 | |
|     local clean status=1
 | |
|     if [ -z "$WORAURL_DATA" ]; then
 | |
|         local WORAURL_DATA
 | |
|         ac_set_tmpfile WORAURL_DATA
 | |
|         clean=1
 | |
|     fi
 | |
|     if wogeturl "$(__get_woturl "$1" wa/woconfig)"; then
 | |
|         cat "$WORAURL_DATA"
 | |
|         status=0
 | |
|     else
 | |
|         status=1
 | |
|     fi
 | |
|     [ -n "$clean" ] && rm -f "$WORAURL_DATA"
 | |
|     return $status
 | |
| }
 |