Mercurial > gemma
diff style-templates/upload-styles.sh @ 4917:0098cfd602be fairway-marks-import
Allow uploading of single SLD templates
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 13 Feb 2020 11:37:22 +0100 |
parents | 15372dd971e9 |
children | a9fac2394238 |
line wrap: on
line diff
--- a/style-templates/upload-styles.sh Tue Feb 11 16:51:09 2020 +0100 +++ b/style-templates/upload-styles.sh Thu Feb 13 11:37:22 2020 +0100 @@ -19,9 +19,11 @@ usage() { cat <<EOF -$ME [OPTION]... +$ME [OPTION]... [input-file]... -Upload map styles to gemma. +Upload map styles to gemma. Uses either the given input files or all files +in the directory where this script resides. Input files must have the name +of a published layer in gemma and the suffix .sld-template. Options: -P, --g_port=GPORT connect to gemma server at GPORT. Default 8000. @@ -83,10 +85,6 @@ esac done -if [ $# != 0 ] ; then - { usage ; exit 23 ; } -fi - # Main ------------------------------------------------------------ # Login to gemma server @@ -108,11 +106,17 @@ if jq -e 'any(. == "sys_admin")' <<<"$roles" > /dev/null then echo "== Configuring geoserver styles" >&2 - for style in $(basename -s .sld-template $(ls $datadir/*.sld-template)) + if [ $# -gt 0 ]; then + files=("$@") + else + files=($(ls $datadir/*.sld-template)) + fi + for file in ${files[@]} do - echo "uploading $style ..." + style=$(basename "$file" .sld-template) + echo "uploading ${style} ..." curl -f -s -S -H "X-Gemma-Auth:${token}" -X POST \ - -F style=@"${datadir}/${style}.sld-template" \ + -F style=@"${file}" \ "http://${g_host}:${g_port}/api/geo/style/${style}" done echo 'done.'