Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment not passed to aw-update scripts #3

Open
wvengen opened this issue Nov 30, 2020 · 0 comments
Open

Environment not passed to aw-update scripts #3

wvengen opened this issue Nov 30, 2020 · 0 comments

Comments

@wvengen
Copy link

wvengen commented Nov 30, 2020

It took me a while to figure out that environment variables are not passed to aw-update scripts, because they are run from a cronjob. As a workaround I've put environment variables that I need in a file from an aw-setup script, and this file can be sources from an aw-update script. But it's not that pretty.

#!/bin/sh
#
# /aw-setup.d/update-env.sh
#
# As aw-update scripts run from a cronjob, the environment variables are not available :(
# We store the relevant variables in a config file that can be sourced.
#
cat >/etc/awstats/aw-update-env <<EOF
MY_VAR="${MY_VAR}"
<<EOF
#!/bin/sh
# 
# /aw-update.d/foo.sh
# 
# Do foo before updating the stats.
# 

# This file runs in a cronjob, hence the environment variables are not available :(
# The relevant variables are stored in a config file in an aw-setup script.
. /etc/awstats/aw-update-env

echo "Foo with ${MY_VAR}!"

I'm configuring some things from a docker-compose.yml file, that's why I need to reference environment variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant