matterbridge - run as dedicated user

This commit is contained in:
2022-12-22 11:51:29 +01:00
parent 5863cccc86
commit 4bfb47f490

View File

@@ -3,31 +3,28 @@
# #
## Installation of chat bridge matterbridge ## Installation of chat bridge matterbridge
toolName="matterbridge" readonly toolName="matterbridge"
repoName="42wim" readonly repoName="42wim"
toolLatestUrl="https://api.github.com/repos/${repoName}/${toolName}/releases/latest" readonly toolLatestUrl="https://api.github.com/repos/${repoName}/${toolName}/releases/latest"
toolVersion=$(curl --silent "$toolLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")') readonly toolVersion=$(curl --silent "$toolLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
toolDownload="https://github.com/${repoName}/${toolName}/releases/download/v${toolVersion}/${toolName}-${toolVersion}-linux-armv6" readonly toolDownload="https://github.com/${repoName}/${toolName}/releases/download/v${toolVersion}/${toolName}-${toolVersion}-linux-armv6"
toolDir="/usr/local/bin" readonly toolDir="/usr/local/bin"
toolLoc="${toolDir}/${toolName}" readonly toolLoc="${toolDir}/${toolName}"
toolWdir="/opt/${toolName}" readonly toolWdir="/etc/${toolName}"
toolConfig="${toolName}.toml" readonly toolConfig="${toolName}.toml"
toolConfigLoc="${toolWdir}/${toolConfig}" readonly toolConfigLoc="${toolWdir}/${toolConfig}"
toolService="[Unit] readonly toolUser='matterbridge'
readonly toolService="[Unit]
Description=${toolName} Description=${toolName}
After=network.target matrix-synapse.service After=network-online.target matrix-synapse.service
[Service] [Service]
Type=simple Type=simple
ExecStart=${toolLoc} -conf ${toolWdir}/matterbridge.toml ExecStart=${toolLoc} -conf ${toolWdir}/matterbridge.toml
Restart=always Restart=always
RestartSec=30 RestartSec=5s
WorkingDirectory=${toolWdir} WorkingDirectory=${toolWdir}
User=root User=${toolUser}
Group=root
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=${toolName}
[Install] [Install]
WantedBy=multi-user.target" WantedBy=multi-user.target"
@@ -60,22 +57,27 @@ step_2() {
exe chmod +x ${toolLoc} exe chmod +x ${toolLoc}
} }
step_3_info() { echo "Creating systemd service"; } step_3_info() { echo "Creating system user ${toolUser}"; }
step_3() { step_3() {
exe adduser --system --group --home "${toolWdir}" "${toolUser}"
}
step_4_info() { echo "Creating systemd service"; }
step_4() {
addConf -s "$toolService" "$toolServiceLoc" addConf -s "$toolService" "$toolServiceLoc"
endReturn -o $? "Creating service failed" endReturn -o $? "Creating service failed"
} }
step_4_info() { echo "Enable $toolName service"; } step_5_info() { echo "Enable $toolName service"; }
step_4() { step_5() {
exe systemctl enable ${toolName} exe systemctl enable ${toolName}
echo " [I] Before proceeding to run ${toolName} you need to modify ${toolConfigLoc} first" echo " [I] Before proceeding to run ${toolName} you need to modify ${toolConfigLoc} first"
echo echo
} }
step_5_info() { echo "Show configuration notes"; } step_6_info() { echo "Show configuration notes"; }
step_5_alias() { echo "notes"; } step_6_alias() { echo "notes"; }
step_5() { step_6() {
color green color green
cat <<NOTES_END cat <<NOTES_END
@@ -190,12 +192,12 @@ whatsappmulti"
} }
step_32_info() { echo "Clean temporary files"; } step_32_info() { echo "Clean temporary files"; }
step_32_alias() { echo "clean"; }
step_32() { step_32() {
exe rm -f "${goDownLoc}" exe rm -f "${goDownLoc}"
} }
# Sequence Revision # shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16 readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
# Path to sequencer
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh