#!/bin/bash
#
# recordum_set_theme
#
# v0.1 2020-08-07 RE
#
# set aqi theme soft link (dark|light)

MYSELF=$( basename "$0" )

script_help() {
    cat <<EOF
${MYSELF} help:

This script sets the /var/www/public/layout/aqi/my_air_quality_theme.css soft link.

Usage: ${MYSELF} <INIT_FILE>

where:
    INIT_FILE ... absolut path / initialization file for theme

EOF
}

if [[ $# -lt 1 ]] || [[ $# -gt 1 ]]
then
    echo "Incorrect number of commandline parameters!"
    script_help
    exit 1
fi

if [ "$( id -un )" != www-data ]; then
    echo "$MYSELF needs to be run as www-data. You are $USER."
    exit 2
fi

INIT_FILE=$1
THEME_ROOT="/var/www/public/layout/aqi/my_air_quality_theme.css"
ln -sf "${INIT_FILE}" ${THEME_ROOT}

exit 0
