Skip to content

Environment not passed to aw-update scripts #3

@wvengen

Description

@wvengen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions