shellchecked

This commit is contained in:
2022-03-16 01:06:35 +01:00
parent 739a4b1e7c
commit d57d7b2c0b
2 changed files with 16 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
#!/bin/bash
# shellcheck disable=SC1090 # dynamically sourced file
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
DEFAULT_DIR="/opt/sequencer"
@@ -14,7 +15,7 @@ SEQUENCER_DIR="$1"
if [ -z "$SEQUENCER_DIR" ]; then
[ -w "$(dirname "$DEFAULT_DIR")" ] && SEQUENCER_DIR="$DEFAULT_DIR"
# Fallback to working directory
[ -z "$SEQUENCER_DIR" ] && $SEQUENCER_DIR="${WDIR}/sequencer"
[ -z "$SEQUENCER_DIR" ] && SEQUENCER_DIR="${WDIR}/sequencer"
fi
# Check if already installed
@@ -23,36 +24,34 @@ if [ -d "$SEQUENCER_DIR" ]; then
echo " $SEQUENCER_DIR"
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 "$SEQUENCER_DIR")" ]; then
echo " [E] Your user has no permission to write to $(dirname "$SEQUENCER_DIR")"
exit 2
fi
# Install git if neccessary
which git >>/dev/null 2>&1
if [ $? != 0 ]; then
if ! which git >>/dev/null 2>&1; then
echo " [W] Git not found and will be installed"
apt update
if [ $? != 0 ]; then
if ! apt update; then
echo " [W] Cannot update apt repositories"
fi
apt install git -y
if [ $? != 0 ]; then
if ! apt install git -y; then
echo " [E] Cannot install git via apt"
exit 3
fi
fi
# Clone sequncer to target directory
git clone $SEQGITURL "$SEQUENCER_DIR"
if [ $? -ne 0 ]; then
if ! git clone $SEQGITURL "$SEQUENCER_DIR"; then
echo " [E] Error cloning git repository:"
echo " $SEQGITURL"
exit 4
fi
# If available use configuration
. ${SEQUENCER_DIR}/sequencer.cfg >/dev/null 2>&1
. "${SEQUENCER_DIR}/sequencer.cfg" >/dev/null 2>&1
# Set to default if not configured
[ -z "$SEQUENCER_USER_SEQS" ] && SEQUENCER_USER_SEQS="$DEFAULT_USER_SEQS"

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Get script working directory
sq_dir="$(cd "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")" >>/dev/null 2>&1 && pwd)"
@@ -8,14 +8,14 @@ _sequencerCompletion() {
local SEQCOMP_LOADER="$HOME/.bashrc"
local SEQCOMP_SOURCE=". \"$SEQCOMP_LOC\""
grep "$SEQCOMP_SOURCE" "$SEQCOMP_LOADER" >>/dev/null 2>&1
if [ $? -eq 0 ]; then
if grep "$SEQCOMP_SOURCE" "$SEQCOMP_LOADER" >>/dev/null 2>&1; then
echo " [I] Completion already installed ($SEQCOMP_LOADER)"
else
echo "$SEQCOMP_SOURCE" >>"$SEQCOMP_LOADER"
[ $? -eq 0 ] && echo " [I] Sequence bash-completion installed"
echo " [I] Sequence bash-completion installed"
fi
source "$SEQCOMP_LOC"
# shellcheck source=sqn-completion.bash
. "$SEQCOMP_LOC"
}
_sequencerCompletion