Support installation to different directoy

Introduce configuration file to set a custom seqs collection
This commit is contained in:
2022-03-07 00:15:27 +01:00
parent 56765a0884
commit b894a756ea
5 changed files with 87 additions and 18 deletions

View File

@@ -1,19 +1,42 @@
#!/bin/bash
SEQLOC="/opt"
SEQHOME="${SEQLOC}/sequencer"
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
SEQUENCER_DIR=
if [ -d "$SEQHOME" ]; then
echo " [E] Sequencer seems to be installed already at:"
echo " $SEQHOME"
# 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 "$SEQLOC" ]; then
echo " [E] Your user has no permission to write to $SEQLOC"
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"
@@ -24,19 +47,23 @@ if [ $? != 0 ]; then
apt install git -y
if [ $? != 0 ]; then
echo " [E] Cannot install git via apt"
exit 4
exit 3
fi
fi
git clone $SEQGITURL "$SEQHOME"
if [ $? != 0 ]; then
# Clone sequncer to target directory
git clone $SEQGITURL "$SEQUENCER_DIR"
if [ $? -ne 0 ]; then
echo " [E] Error cloning git repository:"
echo " $SEQGITURL"
exit 6
exit 4
fi
ln -s "${SEQHOME}/sequencer/sequencer.sh" "/usr/local/bin"
ln -s "${SEQHOME}/seqs" "/opt"
# 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:"