refactoring changes from sequpgrade (endReturn, ...) and some modernizations
This commit is contained in:
@@ -1,29 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=matrix-commander
|
||||
toolCloneUrl='https://github.com/8go/matrix-commander.git'
|
||||
toolDeps="python3-pip python3-venv libolm-dev"
|
||||
readonly toolName=matrix-commander
|
||||
readonly toolCloneUrl='https://github.com/8go/matrix-commander.git'
|
||||
readonly toolDeps="python3-pip python3-venv libolm-dev"
|
||||
|
||||
toolCredentialDir=
|
||||
toolEncStoreDir=
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||
APTOPT=
|
||||
CONFIG=0
|
||||
SCRIPT_FILE=$(basename -- $0)
|
||||
SCRIPT_NAME=${SCRIPT_FILE%%.*}
|
||||
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
sq_aptOpt=
|
||||
|
||||
seq_config() {
|
||||
## or to use sequencer api with global config file:
|
||||
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
else
|
||||
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
# End if no configuration file exists
|
||||
dry || return -1
|
||||
fi
|
||||
@@ -32,7 +20,7 @@ seq_config() {
|
||||
toolEncStoreDir="$MACO_BASE_DIR/.local/share/matrix-commander"
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
quiet && APTOPT="-y"
|
||||
quiet && sq_aptOpt="-y"
|
||||
|
||||
## Return of non zero value will abort the sequence
|
||||
return 0
|
||||
@@ -45,7 +33,7 @@ step_1() {
|
||||
exe "$MACO_BASE_DIR/bin/python3" "$MACO_DIR/matrix_commander/matrix_commander.py" "$@"
|
||||
}
|
||||
|
||||
step_3_info() {
|
||||
step_3_info() {
|
||||
echo "Send message"
|
||||
echoinfo "Each string ([MESSAGE]) is send as separate message"
|
||||
}
|
||||
@@ -53,13 +41,13 @@ step_3_options() { echo "[MESSAGE] [MESSAGE] ..."; }
|
||||
step_3_alias() { echo "message"; }
|
||||
step_3() {
|
||||
shift
|
||||
step run -m "$@"
|
||||
step run -m "$@"
|
||||
}
|
||||
|
||||
step_50_info() { echo "Install $toolName dependencies"; }
|
||||
step_50_alias() { echo "install"; }
|
||||
step_50() {
|
||||
apt install $toolDeps $APTOPT
|
||||
apt install $toolDeps $sq_aptOpt
|
||||
}
|
||||
|
||||
step_51_info() { echo "Add system user ${MACO_USER:-}"; }
|
||||
@@ -75,7 +63,7 @@ step_52() {
|
||||
[ -e "$MACO_BASE_DIR" ] && endReturn -o 1 "$toolName already installed"
|
||||
|
||||
exe python3 -m venv "$MACO_BASE_DIR"
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
endReturn "Creating virtual environment failed"
|
||||
|
||||
exe git clone $toolCloneUrl "$MACO_DIR"
|
||||
exe chown -R $MACO_USER: "$MACO_BASE_DIR"
|
||||
@@ -95,7 +83,7 @@ NOTES_END
|
||||
exe sudo -u $MACO_USER ${MACO_BASE_DIR}/bin/pip install -r ${MACO_DIR}/requirements.txt
|
||||
}
|
||||
|
||||
step_55_info() {
|
||||
step_55_info() {
|
||||
echo "Create systemd service for $toolName"
|
||||
echoinfo "(Make sure to modify the service content in the step configuration)"
|
||||
}
|
||||
@@ -114,7 +102,7 @@ step_57() {
|
||||
step run
|
||||
[ -e ./store ] && exe mv store "$toolEncStoreDir"
|
||||
|
||||
info "use \"$SEQ_NAME run --verify\" to verify against an existing session (like Element)"
|
||||
info "use \"$SEQ_NAME run --verify\" to verify against an existing session (like Element)"
|
||||
}
|
||||
|
||||
step_60_alias() { echo "notes"; }
|
||||
@@ -124,7 +112,7 @@ step_60() {
|
||||
# Verify matrix-commander "device"
|
||||
|
||||
For emoji verification to work, the matrix-commander user needs to be at least in one room.
|
||||
Enter the room on Element and goto
|
||||
Enter the room on Element and goto
|
||||
|
||||
* Room Info -> People -> select matrix commander user -> Security -> sessions -> matrix-commander session
|
||||
* verify with emojis
|
||||
@@ -134,11 +122,13 @@ Enter the room on Element and goto
|
||||
matrix-commander expects the following files to be in place for the user to be able to
|
||||
send/receive messages
|
||||
|
||||
credentials.json - $MACO_BASE_DIR/.config/matrix-commander/credentials.json
|
||||
credentials.json - $MACO_BASE_DIR/.config/matrix-commander/credentials.json
|
||||
store - $MACO_BASE_DIR/.local/share/matrix-commander/store
|
||||
|
||||
NOTES_EOF
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
Reference in New Issue
Block a user