From afc747a33593f386c4ffaa08fa48028dec5ab872 Mon Sep 17 00:00:00 2001 From: CanbiZ Date: Wed, 12 Jun 2024 11:25:55 +0200 Subject: [PATCH 1/5] Add Matterbridge LXC --- ct/matterbridge.sh | 99 +++++++++++++++++++++++++++++++++ install/matterbridge-install.sh | 84 ++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 ct/matterbridge.sh create mode 100644 install/matterbridge-install.sh diff --git a/ct/matterbridge.sh b/ct/matterbridge.sh new file mode 100644 index 00000000..45a1c2ae --- /dev/null +++ b/ct/matterbridge.sh @@ -0,0 +1,99 @@ +#!/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="matterbridge" +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() { + if [[ ! -d /opt/matterbridge ]]; then + msg_error "No ${APP} Installation Found!"; + exit; +fi + +LATEST_VERSION=$(grep -oP '## \[\d+\.\d+\.\d+\]' /opt/matterbridge/CHANGELOG.md | head -1 | sed 's/## \[\(.*\)\]/\1/') +RELEASE=$(curl -s https://api.github.com/repos/Luligu/matterbridge/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + +header_info +if [[ "${RELEASE}" != "${LATEST_VERSION}" ]]; then + msg_info "Stopping Matterbridge Service" + systemctl stop matterbridge + msg_ok "Stopped Matterbridge Service" + + msg_info "Updating ${APP} LXC" + cd /opt/matterbridge + wget -q "https://github.com/Luligu/matterbridge/archive/refs/tags/${RELEASE}.zip" >/dev/null 2>&1 + unzip -q ${RELEASE}.zip + mv matterbridge-${RELEASE} /opt/matterbridge + cd /opt/matterbridge + npm ci >/dev/null 2>&1 + npm run build >/dev/null 2>&1 + + msg_info "Cleaning up" + rm /opt/${RELEASE}.zip + msg_ok "Cleaned" + + msg_info "Starting Matterbridge Service" + systemctl start matterbridge + sleep 1 + msg_ok "Started Matterbridge Service" + msg_ok "Updated Successfully!\n" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi +} + +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}:8283${CL} \n" diff --git a/install/matterbridge-install.sh b/install/matterbridge-install.sh new file mode 100644 index 00000000..23619303 --- /dev/null +++ b/install/matterbridge-install.sh @@ -0,0 +1,84 @@ +#!/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/Luligu/matterbridge/ + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (Patience)" +$STD apt-get install -y --no-install-recommends \ + unzip \ + build-essential \ + curl \ + sudo \ + git \ + make \ + gnupg \ + ca-certificates \ + mc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Install Matterbridge" +RELEASE=$(curl -s https://api.github.com/repos/Luligu/matterbridge/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +wget -q "https://github.com/Luligu/matterbridge/archive/refs/tags/${RELEASE}.zip" +unzip -q ${RELEASE}.zip +mv matterbridge-${RELEASE} /opt/matterbridge +rm -R ${RELEASE}.zip +cd /opt/matterbridge +$STD npm ci +$STD npm run build +msg_ok "Installed Matterbridge" + +msg_info "Creating Service" +cat </etc/systemd/system/matterbridge.service +[Unit] +Description=matterbridge +After=network-online.target + +[Service] +Type=simple +ExecStart=/usr/bin/npm run start:bridge +WorkingDirectory=/opt/matterbridge +StandardOutput=inherit +StandardError=inherit +Restart=always +RestartSec=10s +TimeoutStopSec=30s +User=root +Environment=PATH=/usr/bin:/usr/local/bin:/opt/matterbridge/bin +Environment=NODE_ENV=production + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now matterbridge.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" From fbed1c1c0960d9725c90eb226975acb896a8d60f Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:30:49 +0200 Subject: [PATCH 2/5] Update matterbridge.sh --- ct/matterbridge.sh | 62 ++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/ct/matterbridge.sh b/ct/matterbridge.sh index 45a1c2ae..e0d04f26 100644 --- a/ct/matterbridge.sh +++ b/ct/matterbridge.sh @@ -18,7 +18,7 @@ EOF } header_info echo -e "Loading..." -APP="matterbridge" +APP="Matterbridge" var_disk="4" var_cpu="1" var_ram="1024" @@ -53,41 +53,39 @@ function default_settings() { } function update_script() { - if [[ ! -d /opt/matterbridge ]]; then - msg_error "No ${APP} Installation Found!"; - exit; -fi - -LATEST_VERSION=$(grep -oP '## \[\d+\.\d+\.\d+\]' /opt/matterbridge/CHANGELOG.md | head -1 | sed 's/## \[\(.*\)\]/\1/') -RELEASE=$(curl -s https://api.github.com/repos/Luligu/matterbridge/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - header_info -if [[ "${RELEASE}" != "${LATEST_VERSION}" ]]; then - msg_info "Stopping Matterbridge Service" - systemctl stop matterbridge - msg_ok "Stopped Matterbridge Service" +if [[ ! -d /opt/matterbridge ]]; then msg_error "No ${APP} Installation Found!"; exit; fi - msg_info "Updating ${APP} LXC" - cd /opt/matterbridge - wget -q "https://github.com/Luligu/matterbridge/archive/refs/tags/${RELEASE}.zip" >/dev/null 2>&1 - unzip -q ${RELEASE}.zip - mv matterbridge-${RELEASE} /opt/matterbridge - cd /opt/matterbridge - npm ci >/dev/null 2>&1 - npm run build >/dev/null 2>&1 - - msg_info "Cleaning up" - rm /opt/${RELEASE}.zip - msg_ok "Cleaned" +RELEASE=$(curl -s https://api.github.com/repos/Luligu/matterbridge/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping ${APP} Service" + systemctl stop matterbridge + msg_ok "Stopped ${APP} Service" - msg_info "Starting Matterbridge Service" - systemctl start matterbridge - sleep 1 - msg_ok "Started Matterbridge Service" + msg_info "Updating ${APP} to ${RELEASE}" + cd /opt/matterbridge + wget -q "https://github.com/Luligu/matterbridge/archive/refs/tags/${RELEASE}.zip" + unzip -q ${RELEASE}.zip + mv matterbridge-${RELEASE} /opt/matterbridge + cd /opt/matterbridge + npm ci >/dev/null 2>&1 + npm run build >/dev/null 2>&1 + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Cleaning up" + rm /opt/${RELEASE}.zip + msg_ok "Cleaned" + + msg_info "Starting ${APP} Service" + systemctl start matterbridge + sleep 1 + msg_ok "Started ${APP} Service" msg_ok "Updated Successfully!\n" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}" - fi +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +exit } start From bb0a7ff98874a5675f2830cc11a7a1088fd49ea8 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:31:26 +0200 Subject: [PATCH 3/5] Update matterbridge-install.sh --- install/matterbridge-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/matterbridge-install.sh b/install/matterbridge-install.sh index 23619303..3fc88c81 100644 --- a/install/matterbridge-install.sh +++ b/install/matterbridge-install.sh @@ -17,7 +17,6 @@ update_os msg_info "Installing Dependencies (Patience)" $STD apt-get install -y --no-install-recommends \ - unzip \ build-essential \ curl \ sudo \ @@ -48,6 +47,7 @@ rm -R ${RELEASE}.zip cd /opt/matterbridge $STD npm ci $STD npm run build +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Installed Matterbridge" msg_info "Creating Service" @@ -79,6 +79,6 @@ motd_ssh customize msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean +$STD apt-get -y autoremove +$STD apt-get -y autoclean msg_ok "Cleaned" From 0c0a502714cc8e818802bacb11aa7a38fef41289 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:45:32 +0200 Subject: [PATCH 4/5] Re-Added unzip Dependency --- install/matterbridge-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/matterbridge-install.sh b/install/matterbridge-install.sh index 3fc88c81..47948471 100644 --- a/install/matterbridge-install.sh +++ b/install/matterbridge-install.sh @@ -18,6 +18,7 @@ update_os msg_info "Installing Dependencies (Patience)" $STD apt-get install -y --no-install-recommends \ build-essential \ + unzip \ curl \ sudo \ git \ From 603b3f020413c439d74a2585ae41183f7dd9adab Mon Sep 17 00:00:00 2001 From: CanbiZ Date: Wed, 12 Jun 2024 14:39:10 +0200 Subject: [PATCH 5/5] Add new LXC: MeTube --- ct/metube.sh | 100 ++++++++++++++++++++++++++++++++++++++ install/metube-install.sh | 92 +++++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 ct/metube.sh create mode 100644 install/metube-install.sh diff --git a/ct/metube.sh b/ct/metube.sh new file mode 100644 index 00000000..57d8b46b --- /dev/null +++ b/ct/metube.sh @@ -0,0 +1,100 @@ +#!/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="MeTube" +var_disk="10" +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 [[ ! -d /opt/metube ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +msg_info "Stopping ${APP} Service" +systemctl stop metube +msg_ok "Stopped ${APP} Service" + +msg_info "Updating ${APP} to latest Git" +cd /opt +if [ -d metube_bak ]; then + rm -rf metube_bak +fi +mv metube metube_bak +git clone https://github.com/alexta69/metube /opt/metube >/dev/null 2>&1 +cd /opt/metube/ui +npm install >/dev/null 2>&1 +node_modules/.bin/ng build >/dev/null 2>&1 +cd /opt/metube +cp /opt/metube_bak/.env /opt/metube/ +pip3 install pipenv >/dev/null 2>&1 +pipenv install >/dev/null 2>&1 + +if [ -d "/opt/metube_bak" ]; then +rm -rf /opt/metube_bak +fi +msg_ok "Updated ${APP} to latest Git" + +msg_info "Starting ${APP} Service" +systemctl start metube +sleep 1 +msg_ok "Started ${APP} Service" +msg_ok "Updated Successfully!\n" +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}:8081${CL} \n" \ No newline at end of file diff --git a/install/metube-install.sh b/install/metube-install.sh new file mode 100644 index 00000000..0c418e5d --- /dev/null +++ b/install/metube-install.sh @@ -0,0 +1,92 @@ +#!/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/alexta69/metube + +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 --no-install-recommends \ + build-essential \ + curl \ + sudo \ + ffmpeg \ + git \ + make \ + gnupg \ + ca-certificates \ + mc +msg_ok "Installed Dependencies" + +msg_info "Installing Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv +msg_ok "Installed Python3" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing MeTube" +$STD git clone https://github.com/alexta69/metube /opt/metube +cd /opt/metube/ui +$STD npm install +$STD node_modules/.bin/ng build +cd /opt/metube +$STD pip3 install pipenv +$STD pipenv install +mkdir -p /opt/metube_downloads /opt/metube_downloads/.metube /opt/metube_downloads/music /opt/metube_downloads/videos +cat </opt/metube/.env +DOWNLOAD_DIR=/opt/metube_downloads +STATE_DIR=/opt/metube_downloads/.metube +TEMP_DIR=/opt/metube_downloads +EOF +msg_ok "Installed MeTube" + +msg_info "Creating Service" +cat </etc/systemd/system/metube.service +[Unit] +Description=Metube - YouTube Downloader +After=network.target + +[Service] +Type=simple +WorkingDirectory=/opt/metube +EnvironmentFile=/opt/metube/.env +ExecStart=/usr/local/bin/pipenv run python3 app/main.py +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now metube.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file