New seq to install and upgrade matterbridge from github on raspberrypi os
This commit is contained in:
122
seqs/matterbridge.sh
Executable file
122
seqs/matterbridge.sh
Executable file
@@ -0,0 +1,122 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
## Installation of chat bridge matterbridge
|
||||||
|
|
||||||
|
toolName="matterbridge"
|
||||||
|
repoName="42wim"
|
||||||
|
toolLatestUrl="https://api.github.com/repos/${repoName}/${toolName}/releases/latest"
|
||||||
|
toolVersion=$(curl --silent "$toolLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
|
||||||
|
toolDownload="https://github.com/${repoName}/${toolName}/releases/download/v${toolVersion}/${toolName}-${toolVersion}-linux-armv6"
|
||||||
|
toolDir="/usr/local/bin"
|
||||||
|
toolLoc="${toolDir}/${toolName}"
|
||||||
|
toolDown="/tmp/${toolName}"
|
||||||
|
toolWdir="/opt/${toolName}"
|
||||||
|
toolConfig="${toolName}.toml"
|
||||||
|
toolConfigLoc="${toolWdir}/${toolConfig}"
|
||||||
|
toolService="[Unit]
|
||||||
|
Description=${toolName}
|
||||||
|
After=network.target matrix-synapse.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=${toolLoc} -conf ${toolWdir}/matterbridge.toml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
WorkingDirectory=${toolWdir}
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
StandardOutput=syslog
|
||||||
|
StandardError=syslog
|
||||||
|
SyslogIdentifier=${toolName}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target"
|
||||||
|
toolServiceLoc="/etc/systemd/system/${toolName}.service"
|
||||||
|
|
||||||
|
step_config() {
|
||||||
|
if [ -z $toolVersion ] ; then
|
||||||
|
echoerr " [E] Couldn't determine latest version of $toolName"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
step_1_info() {
|
||||||
|
echo "Downloading $toolName version ${toolVersion} to ${toolLoc} from:"
|
||||||
|
echoinfo "$toolDownload"
|
||||||
|
}
|
||||||
|
step_1_alias() { ALIAS="install"; }
|
||||||
|
step_1() {
|
||||||
|
step upgrade
|
||||||
|
endReturn -o $? "Download failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
step_2_info() { echo "Create required directory structure"; }
|
||||||
|
step_2() {
|
||||||
|
exe mkdir -p ${toolWdir}
|
||||||
|
exe touch ${toolConfigLoc}
|
||||||
|
exe chmod -R 700 ${toolWdir}
|
||||||
|
exe chmod +x ${toolLoc}
|
||||||
|
}
|
||||||
|
|
||||||
|
step_3_info() { echo "Creating systemd service"; }
|
||||||
|
step_3() {
|
||||||
|
addConf -s "$toolService" "$toolServiceLoc"
|
||||||
|
endReturn -o $? "Creating service failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
step_4_info() { echo "Enable $toolName service"; }
|
||||||
|
step_4() {
|
||||||
|
exe systemctl enable ${toolName}
|
||||||
|
echo " [I] Before proceeding to run ${toolName} you need to modify ${toolConfigLoc} first"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
step_5_info() { echo "Show configuration notes"; }
|
||||||
|
step_5_alias() { ALIAS="config"; }
|
||||||
|
step_5() {
|
||||||
|
echo -e " [I] Final configuration notes ${toolName}:\n\n"
|
||||||
|
echo "$CONFIG_NOTES"
|
||||||
|
}
|
||||||
|
CONFIG_NOTES="# Sample configuration
|
||||||
|
|
||||||
|
https://raw.githubusercontent.com/${repoName}/${toolName}/v${toolVersion}/matterbridge.toml.simple"
|
||||||
|
|
||||||
|
step_12_info() {
|
||||||
|
if [ ! -z $versionNow ] ; then
|
||||||
|
if [ "$toolVersion" == "$versionNow" ] ; then
|
||||||
|
echo "No upgrade available. Already on latest: $versionNow"
|
||||||
|
else
|
||||||
|
echo "Download new version $toolVersion to /usr/local/bin"
|
||||||
|
echoinfo " - installed version: $versionNow -"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Download new version $toolVersion to /usr/local/bin"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
step_12_alias() { ALIAS="upgrade"; }
|
||||||
|
step_12() {
|
||||||
|
if [ -f "$toolLoc" ] ; then
|
||||||
|
local toolBackup=
|
||||||
|
if [ ! -z ${versionNow} ] ; then
|
||||||
|
toolBackup="${toolDir}/${toolName}_${versionNow}"
|
||||||
|
else
|
||||||
|
toolBackup="${toolDir}/${toolName}_bu"
|
||||||
|
fi
|
||||||
|
exe service ${toolName} stop >>/dev/null 2>&1
|
||||||
|
echo -n " [I] Backing up existing executable to ${toolBackup}..."
|
||||||
|
exe cp -ar "$toolLoc" "$toolBackup" && echo "ok"
|
||||||
|
fi
|
||||||
|
exe wget -O "$toolLoc" $toolDownload
|
||||||
|
endReturn -o $? "Download failed"
|
||||||
|
exe chmod +x "$toolLoc"
|
||||||
|
exe service ${toolName} restart >>/dev/null 2>&1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
versionNow=$([ ! -z $(which ${toolName}) ] && ${toolName} --version | sed 's/.*version: \([0-9.]\+\).*/\1/')
|
||||||
|
|
||||||
|
# Sequence Revision
|
||||||
|
VERSION_SEQREV=11
|
||||||
|
|
||||||
|
# Path to sequencer
|
||||||
|
. /usr/local/bin/sequencer.sh
|
Reference in New Issue
Block a user