Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Storm <[email protected]>
  • Loading branch information
mstormi committed Jul 15, 2023
1 parent f4599db commit 5b312a0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions functions/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -740,31 +740,34 @@ install_evcc() {


## Function for setting up EVCC, the Electric Vehicle Charge Controller
## The function can be invoked INTERACTIVE only and is German only for now.
## The function can be invoked INTERACTIVE only and setup is in German only for now.
##
## setup_evcc
##
setup_evcc() {
local evccuser
local evccConfig="evcc.yaml"
local dir
local port="${1:-7070}"
local introText="This will create a configuration for EVCC, the Electric Vehicle Charge Controller\\nUse the web interface on port $port to access EVCC's own web interface."
local successText="You have successfully created a configuration file for EVCC, the Electric Vehicle Charge Controller\\nIt replaces /etc/evcc.yaml."

if [[ -n $INTERACTIVE ]]; then
whiptail --title "EVCC configuration" --msgbox "$introText" 8 80
evcc configure --advanced
evcc configure --advanced # creates evcc.yaml in current dir
fi

evccuser="$(systemctl show -pUser evcc | cut -d= -f2)"
dir=${evccuser:-${username:-openhabian}}
if [[ -f ${evccConfig} ]]; then
cond_redirect cp /home/"${evccuser:-${username:-openhabian}}"/${evccConfig} /home/"${evccuser:-${username:-openhabian}}"/${evccConfig}.SAVE
cond_redirect mv "${evccConfig}" /home/"${evccuser:-${username:-openhabian}}"
cond_redirect cp /home/"${dir}"/${evccConfig} /home/"${dir}"/${evccConfig}.SAVE
cond_redirect mv "${evccConfig}" /home/"${dir}"
fi
cond_redirect touch /home/"${evccuser:-${username:-openhabian}}"/${evccConfig}
cond_redirect chown "${evccuser:-${username:-openhabian}}:openhab" /home/"${evccuser:-${username:-openhabian}}"/${evccConfig}*
cond_redirect chmod g+w /home/"${evccuser:-${username:-openhabian}}"/${evccConfig}*
cond_redirect touch /home/"${dir}"/${evccConfig}
cond_redirect chown "${dir}:openhab" /home/"${dir}"/${evccConfig}*
cond_redirect chmod g+w /home/"${dir}"/${evccConfig}*

echo -n "$(timestamp) [openHABian] Created EVCC config, restarting ... "
if cond_redirect systemctl restart evcc.service; then echo "OK"; else echo "FAILED"; fi
}

0 comments on commit 5b312a0

Please sign in to comment.