#!/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= # Get script working directory WDIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" SEQUENCER_DIR="$1" # Installation directory was not set by argument -d if [ -z "$SEQUENCER_DIR" ]; then [ -w "$(dirname "$DEFAULT_DIR")" ] && SEQUENCER_DIR="$DEFAULT_DIR" # Fallback to working directory [ -z "$SEQUENCER_DIR" ] && SEQUENCER_DIR="${WDIR}/sequencer" fi # Check if already installed if [ -d "$SEQUENCER_DIR" ]; then echo " [E] Sequencer seems to be already installed at:" 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")" exit 2 fi # Install git if neccessary if ! which git >>/dev/null 2>&1; then echo " [W] Git not found and will be installed" if ! apt update; then echo " [W] Cannot update apt repositories" fi if ! apt install git -y; then echo " [E] Cannot install git via apt" exit 3 fi fi # Clone sequncer to target directory 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 # Set to default if not configured [ -z "$SEQUENCER_USER_SEQS" ] && SEQUENCER_USER_SEQS="$DEFAULT_USER_SEQS" # 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}" fi echo " [I] Successfully installed shell sequencer" echo " to: $SEQUENCER_DIR"