#!/bin/bash SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git" 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 # Fallback to working directory if [ $? -ne 0 ]; then SEQUENCER_DIR="${WDIR}" fi fi echo $SEQUENCER_DIR exit 0 # If available use configuration . ${WDIR}/sequencer.cfg &>/dev/null # Set to default if not configured [ -z "$SEQUENCER_USER_SEQS" ] && SEQUENCER_USER_SEQS="/opt/seqs" # 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 which git >>/dev/null 2>&1 if [ $? != 0 ]; then echo " [W] Git not found and will be installed" apt update if [ $? != 0 ]; then echo " [W] Cannot update apt repositories" fi apt install git -y if [ $? != 0 ]; 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 echo " [E] Error cloning git repository:" echo " $SEQGITURL" exit 4 fi # Install sequncer script ln -s "${SEQUENCER_DIR}/sequencer/sequencer.sh" "/usr/local/bin" if [ "$SEQUENCER_USER_SEQS" != "$SEQUENCER_DIR/seqs" ]; then ln -s "${SEQUENCER_DIR}/seqs" "${SEQUENCER_USER_SEQS}" fi echo " [I] Successfully installed shell sequencer" echo " Don't forget to set git user variables:" echo " git config user.name \"Your Name\"" echo " git config user.email \"Your.Name@example.com\""