From 301fc39a85a7c755113034bf5f5dda82f82a237e Mon Sep 17 00:00:00 2001
From: CanbiZ <47820557+MickLesk@users.noreply.github.com>
Date: Tue, 15 Oct 2024 11:49:56 +0200
Subject: [PATCH] Add new LXC: evcc (#3896)

---
 ct/evcc.sh              | 70 +++++++++++++++++++++++++++++++++++++++++
 install/evcc-install.sh | 44 ++++++++++++++++++++++++++
 2 files changed, 114 insertions(+)
 create mode 100644 ct/evcc.sh
 create mode 100644 install/evcc-install.sh

diff --git a/ct/evcc.sh b/ct/evcc.sh
new file mode 100644
index 000000000..a5aae019a
--- /dev/null
+++ b/ct/evcc.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
+# Copyright (c) 2021-2024 tteck
+# Author: MickLesk (Canbiz)
+# License: MIT
+# https://github.com/tteck/Proxmox/raw/main/LICENSE
+
+function header_info {
+clear
+cat <<"EOF"     
+  ___ _   ____________
+ / _ \ | / / ___/ ___/
+/  __/ |/ / /__/ /__  
+\___/|___/\___/\___/  
+
+EOF
+}
+header_info
+echo -e "Loading..."
+APP="evcc"
+var_disk="4"
+var_cpu="1"
+var_ram="1024"
+var_os="debian"
+var_version="12"
+variables
+color
+catch_errors
+
+function default_settings() {
+  CT_TYPE="1"
+  PW=""
+  CT_ID=$NEXTID
+  HN=$NSAPP
+  DISK_SIZE="$var_disk"
+  CORE_COUNT="$var_cpu"
+  RAM_SIZE="$var_ram"
+  BRG="vmbr0"
+  NET="dhcp"
+  GATE=""
+  APT_CACHER=""
+  APT_CACHER_IP=""
+  DISABLEIP6="no"
+  MTU=""
+  SD=""
+  NS=""
+  MAC=""
+  VLAN=""
+  SSH="no"
+  VERB="no"
+  echo_default
+}
+
+function update_script() {
+header_info
+if [[ ! -f /etc/apt/sources.list.d/evcc-stable.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
+msg_info "Updating evcc LXC"
+apt update &>/dev/null
+apt install -y evcc &>/dev/null
+msg_ok "Updated Successfully"
+exit
+}
+
+start
+build_container
+description
+
+msg_ok "Completed Successfully!\n"
+echo -e "${APP} Setup should be reachable by going to the following URL.
+         ${BL}http://${IP}:7070${CL} \n"
diff --git a/install/evcc-install.sh b/install/evcc-install.sh
new file mode 100644
index 000000000..bd544ea5f
--- /dev/null
+++ b/install/evcc-install.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2021-2024 tteck
+# Author: tteck
+# Co-Author: MickLesk (Canbiz)
+# License: MIT
+# https://github.com/tteck/Proxmox/raw/main/LICENSE
+# Source: https://github.com/evcc-io/evcc
+
+source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
+color
+verb_ip6
+catch_errors
+setting_up_container
+network_check
+update_os
+
+msg_info "Installing Dependencies"
+$STD apt-get install -y \
+  curl \
+  sudo \
+  mc \
+  lsb-release \
+  gpg 
+msg_ok "Installed Dependencies"
+
+msg_info "Setting up evcc Repository"
+curl -fsSL https://dl.evcc.io/public/evcc/stable/gpg.EAD5D0E07B0EC0FD.key | gpg --dearmor -o /etc/apt/keyrings/evcc-stable.gpg 
+echo "deb [signed-by=/etc/apt/keyrings/evcc-stable.gpg] https://dl.evcc.io/public/evcc/stable/deb/debian $(lsb_release -cs) main" >/etc/apt/sources.list.d/evcc-stable.list 
+$STD apt update
+msg_ok "evcc Repository setup sucessfully"
+
+msg_info "Installing evcc"
+$STD apt install -y evcc
+systemctl enable -q --now evcc.service
+msg_ok "Installed evcc"
+
+motd_ssh
+customize
+
+msg_info "Cleaning up"
+$STD apt-get -y autoremove
+$STD apt-get -y autoclean
+msg_ok "Cleaned"