shellchecked
This commit is contained in:
23
install.sh
23
install.sh
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# shellcheck disable=SC1090 # dynamically sourced file
|
||||||
|
|
||||||
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
|
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
|
||||||
DEFAULT_DIR="/opt/sequencer"
|
DEFAULT_DIR="/opt/sequencer"
|
||||||
@@ -14,7 +15,7 @@ SEQUENCER_DIR="$1"
|
|||||||
if [ -z "$SEQUENCER_DIR" ]; then
|
if [ -z "$SEQUENCER_DIR" ]; then
|
||||||
[ -w "$(dirname "$DEFAULT_DIR")" ] && SEQUENCER_DIR="$DEFAULT_DIR"
|
[ -w "$(dirname "$DEFAULT_DIR")" ] && SEQUENCER_DIR="$DEFAULT_DIR"
|
||||||
# Fallback to working directory
|
# Fallback to working directory
|
||||||
[ -z "$SEQUENCER_DIR" ] && $SEQUENCER_DIR="${WDIR}/sequencer"
|
[ -z "$SEQUENCER_DIR" ] && SEQUENCER_DIR="${WDIR}/sequencer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if already installed
|
# Check if already installed
|
||||||
@@ -23,36 +24,34 @@ if [ -d "$SEQUENCER_DIR" ]; then
|
|||||||
echo " $SEQUENCER_DIR"
|
echo " $SEQUENCER_DIR"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -w "$(dirname $SEQUENCER_DIR)" ]; then
|
if [ ! -w "$(dirname "$SEQUENCER_DIR")" ]; then
|
||||||
echo " [E] Your user has no permission to write to $(dirname $SEQUENCER_DIR)"
|
echo " [E] Your user has no permission to write to $(dirname "$SEQUENCER_DIR")"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install git if neccessary
|
# Install git if neccessary
|
||||||
which git >>/dev/null 2>&1
|
if ! which git >>/dev/null 2>&1; then
|
||||||
if [ $? != 0 ]; then
|
|
||||||
echo " [W] Git not found and will be installed"
|
echo " [W] Git not found and will be installed"
|
||||||
apt update
|
|
||||||
if [ $? != 0 ]; then
|
if ! apt update; then
|
||||||
echo " [W] Cannot update apt repositories"
|
echo " [W] Cannot update apt repositories"
|
||||||
fi
|
fi
|
||||||
apt install git -y
|
|
||||||
if [ $? != 0 ]; then
|
if ! apt install git -y; then
|
||||||
echo " [E] Cannot install git via apt"
|
echo " [E] Cannot install git via apt"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clone sequncer to target directory
|
# Clone sequncer to target directory
|
||||||
git clone $SEQGITURL "$SEQUENCER_DIR"
|
if ! git clone $SEQGITURL "$SEQUENCER_DIR"; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo " [E] Error cloning git repository:"
|
echo " [E] Error cloning git repository:"
|
||||||
echo " $SEQGITURL"
|
echo " $SEQGITURL"
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If available use configuration
|
# 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
|
# Set to default if not configured
|
||||||
[ -z "$SEQUENCER_USER_SEQS" ] && SEQUENCER_USER_SEQS="$DEFAULT_USER_SEQS"
|
[ -z "$SEQUENCER_USER_SEQS" ] && SEQUENCER_USER_SEQS="$DEFAULT_USER_SEQS"
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Get script working directory
|
# Get script working directory
|
||||||
sq_dir="$(cd "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")" >>/dev/null 2>&1 && pwd)"
|
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_LOADER="$HOME/.bashrc"
|
||||||
local SEQCOMP_SOURCE=". \"$SEQCOMP_LOC\""
|
local SEQCOMP_SOURCE=". \"$SEQCOMP_LOC\""
|
||||||
|
|
||||||
grep "$SEQCOMP_SOURCE" "$SEQCOMP_LOADER" >>/dev/null 2>&1
|
if grep "$SEQCOMP_SOURCE" "$SEQCOMP_LOADER" >>/dev/null 2>&1; then
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo " [I] Completion already installed ($SEQCOMP_LOADER)"
|
echo " [I] Completion already installed ($SEQCOMP_LOADER)"
|
||||||
else
|
else
|
||||||
echo "$SEQCOMP_SOURCE" >>"$SEQCOMP_LOADER"
|
echo "$SEQCOMP_SOURCE" >>"$SEQCOMP_LOADER"
|
||||||
[ $? -eq 0 ] && echo " [I] Sequence bash-completion installed"
|
echo " [I] Sequence bash-completion installed"
|
||||||
fi
|
fi
|
||||||
source "$SEQCOMP_LOC"
|
# shellcheck source=sqn-completion.bash
|
||||||
|
. "$SEQCOMP_LOC"
|
||||||
}
|
}
|
||||||
|
|
||||||
_sequencerCompletion
|
_sequencerCompletion
|
||||||
|
Reference in New Issue
Block a user