WIP matterbridge - steps to build matterbridge from source incl. installing go

This commit is contained in:
2022-04-08 21:23:04 +02:00
parent b7e798eeca
commit 57ac4acf79

View File

@@ -33,6 +33,9 @@ SyslogIdentifier=${toolName}
WantedBy=multi-user.target"
toolServiceLoc="/etc/systemd/system/${toolName}.service"
readonly goDir="/usr/local/go"
readonly goDownLoc="/tmp/go.tar.gz"
step_config() {
if [ -z $toolVersion ] ; then
echoerr " [E] Couldn't determine latest version of $toolName"
@@ -83,21 +86,9 @@ https://raw.githubusercontent.com/${repoName}/${toolName}/v${toolVersion}/matter
NOTES_END
}
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() {
step_10_info() { echo "Backup existing executable"; }
step_10_alias() { ALIAS="backup"; }
step_10() {
if [ -f "$toolLoc" ] ; then
local toolBackup=
if [ ! -z ${versionNow} ] ; then
@@ -106,18 +97,37 @@ step_12() {
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"
echoseq -n " [I] Backing up existing executable to ${toolBackup}..."
exe cp -ar "$toolLoc" "$toolBackup" && echoseq "ok"
fi
}
versionNow=$([ ! -z $(which ${toolName}) ] && ${toolName} --version | sed 's/.*version: \([0-9.]\+\).*/\1/')
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 $toolDir"
echoinfo " - installed version: $versionNow -"
fi
else
echo "Download new version $toolVersion to $toolDir"
fi
echo
}
step_12_alias() { ALIAS="upgrade"; }
step_12() {
step backup
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/')
step_30_info() { echo "(TODO) Build from source"; }
step_30_info() { echo "Download go"; }
step_30_alias() { ALIAS="build"; }
step_30() {
local goVer="$(curl --silent -L https://go.dev/doc/devel/release | \
@@ -125,6 +135,19 @@ step_30() {
sed 's/.*go\([[:digit:]\.]\+\).*/\1/g')"
local goArch="armv6l" #arm64"
local goDownUrl="https://go.dev/dl/go${goVer}.linux-${goArch}.tar.gz"
# Download latest go
if [ ! -e "${goDir}" ] ; then
echoseq "Download go${goVer}: ${goDownUrl}"
exe wget -O "${goDownLoc}" ${goDownUrl}
endReturn -o $? "Download ${goVer} failed"
exe tar -C "$(dirname -- "${goDir}")" -xzf "${goDownLoc}"
endReturn -o $? "Extraction ${goVer} failed"
fi
}
step_31_info() { echo "Compile matterbridge"; }
step_31() {
local mabrTags="\
noapi,\
nodiscord,\
@@ -145,10 +168,15 @@ novk,\
nozulip,\
whatsappmulti"
echoseq "Download go${goVer}: ${goDownUrl}"
echoseq "go install -tags ${mabrTags} github.com/42wim/matterbridge@master"
echoseq "step backup"
echoseq "cp -ar ${HOME}/go/bin/matterbridge /usr/local/bin"
# Compile matterbridge
exe "${goDir}/bin/go" install -tags ${mabrTags} github.com/42wim/matterbridge@master
step backup
exe cp -ar "${HOME}/go/bin/matterbridge" "${toolDir}"
}
step_32_info() { echo "Clean temporary files"; }
step_32() {
exe rm -f "${goDownLoc}"
}
# Sequence Revision