From 1f946cd9a257add988d430d1f60bda91bca8a40d Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Fri, 31 Dec 2021 11:27:57 +0100 Subject: [PATCH] New seq with basic functionality to install OliveTin from github --- seqs/olivetin.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 seqs/olivetin.sh diff --git a/seqs/olivetin.sh b/seqs/olivetin.sh new file mode 100755 index 0000000..d62e86c --- /dev/null +++ b/seqs/olivetin.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +toolName=olivetin +latestUrl="https://api.github.com/repos/OliveTin/OliveTin/releases/latest" +latestVersion= +tempExtract= +tempInstall= + +# Get script working directory +# (when called from a different directory) +WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" +APTOPT= +CONFIG=0 +SCRIPT_FILE=$(basename -- $0) +SCRIPT_NAME=${SCRIPT_FILE%%.*} +CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg" +CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" + +step_config() { + ## or to use sequencer api with global config file: + #initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" + + ## or to use sequencer api with profile config file support: + #initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE" + #if [ $? -eq 0 ] ; then + # CONFIG=1 + #else + # # End if no configuration file exists + # [ $DRY -eq 0 ] && return -1 + #fi + + ## Apt cmdline option to suppress user interaction + [ $QUIET -ne 0 ] && APTOPT="-y" + + ## Return of non zero value will abort the sequence + return 0 +} + +step_1_info() { echo "Install $toolName"; } +step_1_alias() { ALIAS="install"; } +step_1() { + downloadLatest + + if [ -e "$tempInstall" ]; then + exe dpkg -i "$tempInstall" + exe systemctl --now enable OliveTin + fi +} + +fetchLatestVersion() { + if [ ! -z $latestVersion ] ; then + return 0 + fi + + latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*(?=")') +} + +downloadLatest() { + fetchLatestVersion + + local downUrl="https://github.com/OliveTin/OliveTin/releases/download/${latestVersion}/OliveTin_${latestVersion}_linux_armv7.deb" + + if [ ! -e "$tempInstall" ] ; then + exe mkdir -p "$tempDown" + exe wget -O "$tempInstall" $downUrl + endReturn -o $? "Download failed: $downUrl" + else + echo " [I] Found existing download: $tempInstall" + fi +} +tempDown="/tmp/olivetin" +tempInstall="$tempDown/olivetin.deb" + + +VERSION_SEQREV=13 +. /usr/local/bin/sequencer.sh