2023-03-23 00:48:20 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-03-23 04:09:04 +00:00
|
|
|
source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
|
2024-01-01 17:13:05 +00:00
|
|
|
# Copyright (c) 2021-2024 tteck
|
2023-03-23 00:48:20 +00:00
|
|
|
# Author: tteck (tteckster)
|
|
|
|
# License: MIT
|
|
|
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
|
|
|
|
|
|
|
function header_info {
|
|
|
|
clear
|
|
|
|
cat <<"EOF"
|
|
|
|
_ _ _ _ ___
|
|
|
|
/\ /\___ _ __ ___ ___ /_\ ___ ___(_)___| |_ __ _ _ __ | |_ / __\___ _ __ ___
|
|
|
|
/ /_/ / _ \| '_ ` _ \ / _ \ //_\\/ __/ __| / __| __/ _` | '_ \| __| / / / _ \| '__/ _ \
|
|
|
|
/ __ / (_) | | | | | | __/ / _ \__ \__ \ \__ \ || (_| | | | | |_ / /__| (_) | | | __/
|
|
|
|
\/ /_/ \___/|_| |_| |_|\___| \_/ \_/___/___/_|___/\__\__,_|_| |_|\__| \____/\___/|_| \___|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
header_info
|
|
|
|
echo -e "Loading..."
|
|
|
|
APP="Home Assistant-Core"
|
|
|
|
var_disk="8"
|
2024-03-13 00:36:08 +00:00
|
|
|
var_cpu="2"
|
|
|
|
var_ram="1024"
|
2023-03-23 00:48:20 +00:00
|
|
|
var_os="debian"
|
2023-06-24 20:44:10 +00:00
|
|
|
var_version="12"
|
2023-03-23 00:48:20 +00:00
|
|
|
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"
|
2023-05-14 01:22:09 +00:00
|
|
|
NET="dhcp"
|
2023-03-23 00:48:20 +00:00
|
|
|
GATE=""
|
2024-01-12 20:00:42 +00:00
|
|
|
APT_CACHER=""
|
|
|
|
APT_CACHER_IP=""
|
2023-03-23 00:48:20 +00:00
|
|
|
DISABLEIP6="no"
|
|
|
|
MTU=""
|
|
|
|
SD=""
|
|
|
|
NS=""
|
|
|
|
MAC=""
|
|
|
|
VLAN=""
|
|
|
|
SSH="no"
|
|
|
|
VERB="no"
|
|
|
|
echo_default
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_script() {
|
|
|
|
if [[ ! -d /srv/homeassistant ]]; then
|
|
|
|
msg_error "No ${APP} Installation Found!"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
PY=$(ls /srv/homeassistant/lib/)
|
|
|
|
IP=$(hostname -I | awk '{print $1}')
|
2023-09-09 09:13:17 +00:00
|
|
|
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \
|
2023-03-23 00:48:20 +00:00
|
|
|
"1" "Update Core" ON \
|
|
|
|
"2" "Install HACS" OFF \
|
|
|
|
"3" "Install FileBrowser" OFF \
|
|
|
|
3>&1 1>&2 2>&3)
|
|
|
|
header_info
|
|
|
|
if [ "$UPD" == "1" ]; then
|
2023-09-09 09:13:17 +00:00
|
|
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then
|
2023-03-23 00:48:20 +00:00
|
|
|
clear
|
|
|
|
header_info
|
2023-03-23 09:14:02 +00:00
|
|
|
echo -e "${GN}Updating to Beta Version${CL}"
|
2023-03-23 00:48:20 +00:00
|
|
|
BR="--pre "
|
|
|
|
else
|
|
|
|
clear
|
|
|
|
header_info
|
2023-03-24 17:34:25 +00:00
|
|
|
echo -e "${GN}Updating to Stable Version${CL}"
|
2023-03-23 00:48:20 +00:00
|
|
|
BR=""
|
|
|
|
fi
|
2024-02-10 01:37:41 +00:00
|
|
|
if [[ "$PY" == "python3.11" ]]; then echo -e "⚠️ Home Assistant will soon require Python 3.12."; fi
|
2023-03-23 00:48:20 +00:00
|
|
|
|
|
|
|
msg_info "Stopping Home Assistant"
|
|
|
|
systemctl stop homeassistant
|
|
|
|
msg_ok "Stopped Home Assistant"
|
|
|
|
|
|
|
|
msg_info "Updating Home Assistant"
|
|
|
|
source /srv/homeassistant/bin/activate
|
|
|
|
pip install ${BR}--upgrade homeassistant &>/dev/null
|
|
|
|
msg_ok "Updated Home Assistant"
|
|
|
|
|
|
|
|
msg_info "Starting Home Assistant"
|
|
|
|
systemctl start homeassistant
|
|
|
|
sleep 2
|
|
|
|
msg_ok "Started Home Assistant"
|
|
|
|
msg_ok "Update Successful"
|
|
|
|
echo -e "\n Go to http://${IP}:8123 \n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ "$UPD" == "2" ]; then
|
2023-11-05 21:52:56 +00:00
|
|
|
msg_info "Installing Home Assistant Community Store (HACS)"
|
2023-03-23 00:48:20 +00:00
|
|
|
apt update &>/dev/null
|
|
|
|
apt install unzip &>/dev/null
|
|
|
|
cd .homeassistant
|
|
|
|
bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null
|
2023-11-05 21:52:56 +00:00
|
|
|
msg_ok "Installed Home Assistant Community Store (HACS)"
|
2023-03-23 00:48:20 +00:00
|
|
|
echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ "$UPD" == "3" ]; then
|
2024-02-15 13:04:47 +00:00
|
|
|
set +Eeuo pipefail
|
2024-02-15 12:32:28 +00:00
|
|
|
read -r -p "Would you like to use No Authentication? <y/N> " prompt
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_info "Installing FileBrowser"
|
2023-08-03 00:11:58 +00:00
|
|
|
RELEASE=$(curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g')
|
2024-02-15 12:32:28 +00:00
|
|
|
curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/$RELEASE/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null
|
|
|
|
|
|
|
|
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
|
|
|
filebrowser config init -a '0.0.0.0' &>/dev/null
|
|
|
|
filebrowser config set -a '0.0.0.0' &>/dev/null
|
|
|
|
filebrowser config set --auth.method=noauth &>/dev/null
|
|
|
|
filebrowser users add ID 1 --perm.admin &>/dev/null
|
|
|
|
else
|
|
|
|
filebrowser config init -a '0.0.0.0' &>/dev/null
|
|
|
|
filebrowser config set -a '0.0.0.0' &>/dev/null
|
|
|
|
filebrowser users add admin changeme --perm.admin &>/dev/null
|
2024-02-15 12:37:00 +00:00
|
|
|
fi
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Installed FileBrowser"
|
|
|
|
|
|
|
|
msg_info "Creating Service"
|
|
|
|
service_path="/etc/systemd/system/filebrowser.service"
|
|
|
|
echo "[Unit]
|
|
|
|
Description=Filebrowser
|
|
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
|
|
User=root
|
|
|
|
WorkingDirectory=/root/
|
|
|
|
ExecStart=/usr/local/bin/filebrowser -r /root/.homeassistant
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target" >$service_path
|
|
|
|
|
2023-03-23 09:14:02 +00:00
|
|
|
systemctl enable --now -q filebrowser.service
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Created Service"
|
|
|
|
|
|
|
|
msg_ok "Completed Successfully!\n"
|
|
|
|
echo -e "FileBrowser should be reachable by going to the following URL.
|
|
|
|
${BL}http://$IP:8080${CL} admin|changeme\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-03-13 00:33:47 +00:00
|
|
|
start
|
|
|
|
build_container
|
|
|
|
description
|
|
|
|
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Completed Successfully!\n"
|
|
|
|
echo -e "${APP} should be reachable by going to the following URL.
|
|
|
|
${BL}http://${IP}:8123${CL}"
|