Created
July 3, 2020 18:29
-
-
Save frennkie/a52d1eddfad03d3cda94d49fdd364e16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# store values from environment | |
env_IP2TOR_SHOP_URL=${IP2TOR_SHOP_URL-notset} | |
env_IP2TOR_HOST_ID=${IP2TOR_HOST_ID-notset} | |
env_IP2TOR_HOST_TOKEN=${IP2TOR_HOST_TOKEN-notset} | |
# if config file exists use it (but vars set from environment overwrite file vars) | |
if [ -f /etc/ip2tor.conf ]; then | |
unset IP2TOR_SHOP_URL | |
unset IP2TOR_HOST_ID | |
unset IP2TOR_HOST_TOKEN | |
source /etc/ip2tor.conf | |
if [ -n "${env_IP2TOR_SHOP_URL}" ]; then | |
IP2TOR_SHOP_URL=${env_IP2TOR_SHOP_URL} | |
fi | |
if [ -n "${env_IP2TOR_HOST_ID}" ]; then | |
IP2TOR_HOST_ID=${env_IP2TOR_HOST_ID} | |
fi | |
if [ -n "${env_IP2TOR_HOST_TOKEN}" ]; then | |
IP2TOR_HOST_TOKEN=${env_IP2TOR_HOST_TOKEN} | |
fi | |
fi | |
if [ "${IP2TOR_SHOP_URL}" = "notset" ] && [ "${IP2TOR_HOST_ID}" = "notset" ] && [ "${IP2TOR_HOST_TOKEN}" = "notset" ]; then | |
echo "Error: IP2TOR_SHOP_URL, IP2TOR_HOST_ID and IP2TOR_HOST_TOKEN must be set via environment or config file!" | |
exit 1 | |
fi | |
if [ -z "${IP2TOR_SHOP_URL}" ] && [ -z "${IP2TOR_HOST_ID}" ] && [ -z "${IP2TOR_HOST_TOKEN}" ]; then | |
echo "Error: IP2TOR_SHOP_URL, IP2TOR_HOST_ID and IP2TOR_HOST_TOKEN must be set via environment or config file!" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment