Refactor variables names

This commit is contained in:
2022-05-25 18:22:35 +02:00
parent 8bd247759b
commit 373cc8e8b6
3 changed files with 46 additions and 45 deletions

View File

@@ -1,66 +1,66 @@
#!/bin/bash
# shellcheck disable=SC1090 # dynamically sourced file
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
DEFAULT_DIR="/opt/sequencer"
DEFAULT_USER_SEQS="/opt/seqs"
SEQUENCER_DIR=
sequencer_gitUrl="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
defaultDir="/opt/sequencer"
defaultUserSeqs="/opt/seqs"
sequencerDir=
# Get script working directory
WDIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
SEQUENCER_DIR="$1"
sequencerDir="${1:-}"
# Installation directory was not set by argument -d
if [ -z "$SEQUENCER_DIR" ]; then
[ -w "$(dirname "$DEFAULT_DIR")" ] && SEQUENCER_DIR="$DEFAULT_DIR"
if [ -z "${sequencerDir}" ]; then
[ -w "$(dirname -- "${defaultDir}")" ] && sequencerDir="${defaultDir}"
# Fallback to working directory
[ -z "$SEQUENCER_DIR" ] && SEQUENCER_DIR="${WDIR}/sequencer"
[ -z "${sequencerDir}" ] && sequencerDir="${WDIR}/sequencer"
fi
# Check if already installed
if [ -d "$SEQUENCER_DIR" ]; then
echo " [E] Sequencer seems to be already installed at:"
echo " $SEQUENCER_DIR"
if [ -d "${sequencerDir}" ]; then
echo " [e] Sequencer seems to be already installed at:"
echo " ${sequencerDir}"
exit 1
fi
if [ ! -w "$(dirname "$SEQUENCER_DIR")" ]; then
echo " [E] Your user has no permission to write to $(dirname "$SEQUENCER_DIR")"
if [ ! -w "$(dirname -- "${sequencerDir}")" ]; then
echo " [e] Your user has no permission to write to $(dirname -- "${sequencerDir}")"
exit 2
fi
# Install git if neccessary
if ! which git >>/dev/null 2>&1; then
echo " [W] Git not found and will be installed"
echo " [w] Git not found and will be installed"
if ! apt update; then
echo " [W] Cannot update apt repositories"
echo " [w] Cannot update apt repositories"
fi
if ! apt install git -y; then
echo " [E] Cannot install git via apt"
echo " [e] Cannot install git via apt"
exit 3
fi
fi
# Clone sequncer to target directory
if ! git clone $SEQGITURL "$SEQUENCER_DIR"; then
if ! git clone "${sequencer_gitUrl}" "$sequencerDir"; then
echo " [E] Error cloning git repository:"
echo " $SEQGITURL"
echo " ${sequencer_gitUrl}"
exit 4
fi
# If available use configuration
. "${SEQUENCER_DIR}/sequencer.cfg" >/dev/null 2>&1
. "${sequencerDir}/sequencer.cfg" >/dev/null 2>&1
# Set to default if not configured
[ -z "$SEQUENCER_USER_SEQS" ] && SEQUENCER_USER_SEQS="$DEFAULT_USER_SEQS"
[ -z "${SEQUENCER_USER_SEQS}" ] && SEQUENCER_USER_SEQS="${defaultUserSeqs}"
# Install sequncer script
ln -s "${SEQUENCER_DIR}/sequencer/sequencer.sh" "/usr/local/bin"
if [ "$SEQUENCER_USER_SEQS" != "$SEQUENCER_DIR/seqs" ]; then
ln -sT "${SEQUENCER_DIR}/seqs" "${SEQUENCER_USER_SEQS}"
ln -s "${sequencerDir}/sequencer/sequencer.sh" "/usr/local/bin"
if [ "${SEQUENCER_USER_SEQS}" != "${sequencerDir}/seqs" ]; then
ln -sT "${sequencerDir}/seqs" "${SEQUENCER_USER_SEQS}"
fi
echo " [I] Successfully installed shell sequencer"
echo " to: $SEQUENCER_DIR"
echo " to: ${sequencerDir}"