#!/usr/bin/env bash readonly toolName=synapse-admin readonly versionUrl="https://api.github.com/repos/Awesome-Technologies/synapse-admin/releases/latest" downUrl= versionNew= versionNow= sq_aptOpt= sq_config=0 seq_config() { ## or to use sequencer api with global config file: if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then sq_config=1 else # End if no configuration file exists dry || return 1 fi ## Apt cmdline option to suppress user interaction interactive || sq_aptOpt="-y" ## Disable error checks if external scripts are used ## e.g. error on unbound variables #disableErrorCheck ## Return of non zero value will abort the sequence return 0 } getVersions() { versionNew=${versionNew:-$(curl --silent "$versionUrl" | grep -Po '"tag_name": "\K.*?(?=")')} downUrl=${downUrl:-$(curl --silent "$versionUrl" | grep -Po '"browser_download_url": "\K.*?(?=")')} versionNow=${versionNow:-$(grep -Po 'REACT_APP_VERSION:"\K.*?(?=")' 2>/dev/null < "${sc_synadmLoc}/static/js/"main.*.js | head -1)} } step_1_info() { echo "Status"; } step_1_alias() { echo "status"; } step_1() { getVersions if [[ -z "${versionNow}" ]] ; then info "Version ${versionNew} available to install" elif [[ ${versionNew} == ${versionNow} ]] ; then color green info "Latest version ${versionNew} already installed" else color yellow info "Update to: ${versionNew} available" fi } step_10_info() { echo "Install"; } step_10_alias() { echo "install"; } step_10() { local loBackup="${sc_synadmLoc}.bu" local loTemp="/tmp/${toolName}.tar.gz" # get download URL getVersions if [[ -e "${sc_synadmLoc}" ]]; then exe mv "${sc_synadmLoc}" "${loBackup}" fi if ! exe wget -O "${loTemp}" "${downUrl}" ; then info "Download failed" exe mv "${loBackup}" "${sc_synadmLoc}" 2>/dev/null else exe tar -xf "${loTemp}" -C "$(dirname -- "${sc_synadmLoc}")" endReturn -o $? "Extraction failed" exe mv "$(dirname -- "${sc_synadmLoc}")/${toolName}-${versionNew}" "${sc_synadmLoc}" exe chown -R root: "${sc_synadmLoc}" info "Downloaded to ${sc_synadmLoc}" exe rm -rf "${loBackup}" "${loTemp}" fi } step_20_info() { echo "Notes"; } step_20_alias() { echo "notes"; } step_20() { color green cat <