Update matterbridge.sh

This commit is contained in:
CanbiZ 2024-06-12 12:30:49 +02:00 committed by GitHub
parent afc747a335
commit fbed1c1c09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,7 +18,7 @@ EOF
} }
header_info header_info
echo -e "Loading..." echo -e "Loading..."
APP="matterbridge" APP="Matterbridge"
var_disk="4" var_disk="4"
var_cpu="1" var_cpu="1"
var_ram="1024" var_ram="1024"
@ -53,41 +53,39 @@ function default_settings() {
} }
function update_script() { 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 header_info
if [[ "${RELEASE}" != "${LATEST_VERSION}" ]]; then if [[ ! -d /opt/matterbridge ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
msg_info "Stopping Matterbridge Service"
systemctl stop matterbridge
msg_ok "Stopped Matterbridge Service"
msg_info "Updating ${APP} LXC" RELEASE=$(curl -s https://api.github.com/repos/Luligu/matterbridge/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
cd /opt/matterbridge if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
wget -q "https://github.com/Luligu/matterbridge/archive/refs/tags/${RELEASE}.zip" >/dev/null 2>&1 msg_info "Stopping ${APP} Service"
unzip -q ${RELEASE}.zip systemctl stop matterbridge
mv matterbridge-${RELEASE} /opt/matterbridge msg_ok "Stopped ${APP} Service"
cd /opt/matterbridge
npm ci >/dev/null 2>&1
npm run build >/dev/null 2>&1
msg_info "Cleaning up" msg_info "Updating ${APP} to ${RELEASE}"
rm /opt/${RELEASE}.zip cd /opt/matterbridge
msg_ok "Cleaned" 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 "Starting Matterbridge Service" msg_info "Cleaning up"
systemctl start matterbridge rm /opt/${RELEASE}.zip
sleep 1 msg_ok "Cleaned"
msg_ok "Started Matterbridge Service"
msg_info "Starting ${APP} Service"
systemctl start matterbridge
sleep 1
msg_ok "Started ${APP} Service"
msg_ok "Updated Successfully!\n" msg_ok "Updated Successfully!\n"
else else
msg_ok "No update required. ${APP} is already at ${RELEASE}" msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi fi
exit
} }
start start