]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/tilecache/templates/default/nginx_generate_tilecache_qos_map.erb
tilecache: cleaner nginx reload
[chef.git] / cookbooks / tilecache / templates / default / nginx_generate_tilecache_qos_map.erb
index e6c17f8a9f5860d8f4ef705a19b0e58597085cd4..9a386a3e73c8f3c686a09781d24f63d8b5c907f1 100755 (executable)
@@ -4,7 +4,7 @@
 set -e
 NUM_TOKENS=4 # current + 4
 VALID_TOKEN=3600 # in seconds
-QOS_TOKENS=($(/usr/bin/oathtool --totp --window=${NUM_TOKENS} --time-step-size=${VALID_TOKEN}s <%= web_passwords[:totp_key] %>))
+QOS_TOKENS=($(/usr/bin/oathtool --totp --window=${NUM_TOKENS} --time-step-size=${VALID_TOKEN}s -b <%= @totp_key %>))
 
 # ${qos_tokens[3]/[-1] } = OSM.org exclusive / current
 # ${qos_tokens[2]/[-2] } = tile.openstreetmap.org default
@@ -28,17 +28,18 @@ if [ -z "$QOS_TOKEN_OSM" -o -z "$QOS_TOKEN_DEFAULT" -o -z "$QOS_TOKEN_STALE" ];
 fi
 
 cat <<EOF >/etc/nginx/conf.d/tile_qos_rates.map
-default 4096; # Default Rate (No QoS cookie)
-"${QOS_TOKEN_STALE}" 16384; # Stale
+default 24576; # Default Rate (No QoS cookie)
+"${QOS_TOKEN_STALE}" 24576; # Stale
 "${QOS_TOKEN_DEFAULT}" 24576; # Default
 "${QOS_TOKEN_OSM_STALE}" 32768; # Exclusive Stale
 "${QOS_TOKEN_OSM}" 32768; # Exclusive
 EOF
 
 cat <<EOF >/etc/nginx/conf.d/tile_qos_cookies.map
-default 'qos_token=${QOS_TOKEN_DEFAULT}; Secure; httponly; Max-Age=${VALID_TOKEN}; Domain=openstreetmap.org; Path=/'; # Cookie Domain per RFC6265
+default 'qos_token=${QOS_TOKEN_DEFAULT}; Max-Age=${VALID_TOKEN}; Domain=openstreetmap.org; Path=/'; # Cookie Domain per RFC6265
 "${QOS_TOKEN_DEFAULT}" ''; # Do not Set-Cookie. # Default
 "${QOS_TOKEN_OSM}" ''; # Do not Set-Cookie. # Exclusive
 EOF
 
-/etc/init.d/nginx configtest && service nginx reload
+# Check config, reload config and fail safe
+/etc/init.d/nginx configtest && ( /usr/sbin/service nginx reload || true )