Support installation to different directoy
Introduce configuration file to set a custom seqs collection
This commit is contained in:
27
README.md
27
README.md
@@ -32,12 +32,16 @@ ln -s /opt/sequencer/seqs /opt
|
|||||||
```
|
```
|
||||||
or
|
or
|
||||||
|
|
||||||
use the simple bash installation script in the repository:
|
use the simple bash installation script in the repository which installs git and performs the steps above:
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -L https://winklerfamilie.eu/git/efelon/shell_sequencer/raw/branch/master/install.sh | bash
|
curl -L https://winklerfamilie.eu/git/efelon/shell_sequencer/raw/branch/master/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You may override the default installation path `/opt/sequencer` by appending `-s /custom/path` to the command above:
|
||||||
|
|
||||||
|
e.g. `curl -L https://winklerfamilie.eu/git/efelon/shell_sequencer/raw/branch/master/install.sh | bash -s /usr/lib/sequencer`
|
||||||
|
|
||||||
## Bash-completion
|
## Bash-completion
|
||||||
|
|
||||||
The included optional bash-completion script `sqnall-completion.bash` provides aliases to all available sequences as well as completion for sequencer.sh options and steps (including aliases) individually for each sequence. The aliases have the prefix `sqn_` which stands for _sequence name_.
|
The included optional bash-completion script `sqnall-completion.bash` provides aliases to all available sequences as well as completion for sequencer.sh options and steps (including aliases) individually for each sequence. The aliases have the prefix `sqn_` which stands for _sequence name_.
|
||||||
@@ -50,6 +54,19 @@ source /opt/sequencer/sqnall-completion.bash
|
|||||||
|
|
||||||
e.g. `/opt/sequencer/seqs/kodi.sh` can be started anyhere with `sqn_kodi`
|
e.g. `/opt/sequencer/seqs/kodi.sh` can be started anyhere with `sqn_kodi`
|
||||||
|
|
||||||
|
### Custom sequence directory
|
||||||
|
|
||||||
|
To control which seqs are available for bash-completion, copy `sequencer.cfg.dist` to `sequencer.cfg` and adjust the value of the variable `SEQUENCER_USER_SEQS`.
|
||||||
|
|
||||||
|
To make these changes active run the following commands. You don't need the last step if you already used `installCompletion.sh`.
|
||||||
|
|
||||||
|
```
|
||||||
|
unalias -a
|
||||||
|
source ~/.bashrc
|
||||||
|
source /opt/sequencer/sqnall-completion.bash
|
||||||
|
```
|
||||||
|
|
||||||
|
or simply logout from the current session and login again.
|
||||||
|
|
||||||
### Automatic setup after login
|
### Automatic setup after login
|
||||||
|
|
||||||
@@ -60,3 +77,11 @@ source /opt/sequencer/installCompletion.sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
This sources the bash-completion script in the users .bashrc file.
|
This sources the bash-completion script in the users .bashrc file.
|
||||||
|
|
||||||
|
## Default text editor
|
||||||
|
|
||||||
|
Sequencer uses the Debian alternatives system to the select which editor to use. To change the default editor, which by default is most likely _nano_:
|
||||||
|
|
||||||
|
```
|
||||||
|
update-alternatives --config editor
|
||||||
|
```
|
||||||
|
53
install.sh
53
install.sh
@@ -1,19 +1,42 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SEQLOC="/opt"
|
|
||||||
SEQHOME="${SEQLOC}/sequencer"
|
|
||||||
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
|
SEQGITURL="https://winklerfamilie.eu/git/efelon/shell_sequencer.git"
|
||||||
|
SEQUENCER_DIR=
|
||||||
|
|
||||||
if [ -d "$SEQHOME" ]; then
|
# Get script working directory
|
||||||
echo " [E] Sequencer seems to be installed already at:"
|
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||||
echo " $SEQHOME"
|
|
||||||
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -w "$SEQLOC" ]; then
|
if [ ! -w "$(dirname $SEQUENCER_DIR)" ]; then
|
||||||
echo " [E] Your user has no permission to write to $SEQLOC"
|
echo " [E] Your user has no permission to write to $(dirname $SEQUENCER_DIR)"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Install git if neccessary
|
||||||
which git >>/dev/null 2>&1
|
which git >>/dev/null 2>&1
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo " [W] Git not found and will be installed"
|
echo " [W] Git not found and will be installed"
|
||||||
@@ -24,19 +47,23 @@ if [ $? != 0 ]; then
|
|||||||
apt install git -y
|
apt install git -y
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo " [E] Cannot install git via apt"
|
echo " [E] Cannot install git via apt"
|
||||||
exit 4
|
exit 3
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clone $SEQGITURL "$SEQHOME"
|
# Clone sequncer to target directory
|
||||||
if [ $? != 0 ]; then
|
git clone $SEQGITURL "$SEQUENCER_DIR"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
echo " [E] Error cloning git repository:"
|
echo " [E] Error cloning git repository:"
|
||||||
echo " $SEQGITURL"
|
echo " $SEQGITURL"
|
||||||
exit 6
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -s "${SEQHOME}/sequencer/sequencer.sh" "/usr/local/bin"
|
# Install sequncer script
|
||||||
ln -s "${SEQHOME}/seqs" "/opt"
|
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 " [I] Successfully installed shell sequencer"
|
||||||
echo " Don't forget to set git user variables:"
|
echo " Don't forget to set git user variables:"
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get script working directory
|
||||||
|
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||||
|
|
||||||
_sequencerCompletion() {
|
_sequencerCompletion() {
|
||||||
local SEQBASE="/opt/sequencer"
|
local SEQCOMP_LOC="${WDIR}/sqnall-completion.bash"
|
||||||
local SEQCOMP_LOC="$SEQBASE/sqnall-completion.bash"
|
local SEQCOMP_LOADER="$HOME/.bashrc)"
|
||||||
local SEQCOMP_LOADER="$(realpath ~/.bashrc)"
|
|
||||||
local SEQCOMP_SOURCE="source \"$SEQCOMP_LOC\""
|
local SEQCOMP_SOURCE="source \"$SEQCOMP_LOC\""
|
||||||
|
|
||||||
grep "$SEQCOMP_SOURCE" "$SEQCOMP_LOADER" >>/dev/null 2>&1
|
grep "$SEQCOMP_SOURCE" "$SEQCOMP_LOADER" >>/dev/null 2>&1
|
||||||
|
5
sequencer.cfg.dist
Normal file
5
sequencer.cfg.dist
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## Bash completion ##
|
||||||
|
# Where uses store own seqs or selected distribution selected seqs
|
||||||
|
SEQUENCER_USER_SEQS="/opt/seqs"
|
@@ -36,9 +36,19 @@ _sqnall_completions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
installCompletion() {
|
installCompletion() {
|
||||||
local SEQBASE="/opt/sequencer/seqs"
|
# Get script working directory
|
||||||
|
# (when called from a different directory)
|
||||||
|
local WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||||
|
|
||||||
|
. ${WDIR}/sequencer.cfg &>/dev/null
|
||||||
|
|
||||||
|
local SEQBASE="${WDIR}/seqs"
|
||||||
local SEQPREFIX="sqn_"
|
local SEQPREFIX="sqn_"
|
||||||
local SEQSHORT=()
|
local SEQSHORT=()
|
||||||
|
|
||||||
|
# Check for user selected sequences
|
||||||
|
[ -e "$SEQUENCER_USER_SEQS" ] && SEQBASE="$SEQUENCER_USER_SEQS"
|
||||||
|
|
||||||
# Create aliases and command (alias) list for "complete" command"
|
# Create aliases and command (alias) list for "complete" command"
|
||||||
SEQLIST=($(ls "$SEQBASE/$cur"*.sh))
|
SEQLIST=($(ls "$SEQBASE/$cur"*.sh))
|
||||||
for i in "${!SEQLIST[@]}"; do
|
for i in "${!SEQLIST[@]}"; do
|
||||||
|
Reference in New Issue
Block a user