matrix-commander - additional step for first run and sending a message

More notes about verifiying matrix-commander in element
This commit is contained in:
2022-03-10 13:46:01 +01:00
parent efac859fac
commit 86509453cc
2 changed files with 67 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/bash
MACO_USER="matrixcommander"
MACO_USER="matrix-commander"
MACO_BASE_DIR="/opt/matrix-commander"
MACO_DIR="$MACO_BASE_DIR/matrix-commander"
MACO_SERVICE="[Unit]

View File

@@ -3,7 +3,9 @@
toolName=matrix-commander
toolCloneUrl='https://github.com/8go/matrix-commander.git'
toolDeps="python3-pip python3-venv libolm-dev"
toolVenvDir=
toolCredentialDir=
toolEncStoreDir=
# Get script working directory
# (when called from a different directory)
@@ -26,7 +28,8 @@ step_config() {
[ $DRY -eq 0 ] && return -1
fi
toolVenvDir="$MACO_BASE_DIR"
toolCredentialDir="$MACO_BASE_DIR/.config/matrix-commander"
toolEncStoreDir="$MACO_BASE_DIR/.local/share/matrix-commander"
## Apt cmdline option to suppress user interaction
[ $QUIET -ne 0 ] && APTOPT="-y"
@@ -44,19 +47,22 @@ step_1() {
step_2_info() { echo "Add system user $MACO_USER"; }
step_2() {
id $MACO_USER >/dev/null 2>&1
[ $? -eq 0 ] && endReturn -o 1 "User $MACO_USER already exists"
exe adduser --system $MACO_USER --group --home "${MACO_BASE_DIR}"
}
step_3_info() { echo "Create venv and install $toolName"; }
step_3() {
local macommanderDir="${MACO_DIR}"
[ -e "$MACO_BASE_DIR" ] && endReturn -o 1 "$toolName already installed"
exe python3 -m venv "$toolVenvDir"
exe python3 -m venv "$MACO_BASE_DIR"
endReturn -o $? "Creating virtual environment failed"
exe git clone $toolCloneUrl "$MACO_DIR"
exe chown -R $MACO_USER: "$toolVenvDir"
exe sudo -u $MACO_USER ${toolVenvDir}/bin/pip install --upgrade pip
exe chown -R $MACO_USER: "$MACO_BASE_DIR"
exe sudo -u $MACO_USER ${MACO_BASE_DIR}/bin/pip install --upgrade pip
}
step_4_info() { echo "Install python requirements"; }
@@ -69,11 +75,14 @@ notify2
NOTES_END
exe read -p "Enter to continue..."
exe "$DEFAULT_EDITOR_SYSTEM" "$MACO_DIR/requirements.txt"
exe sudo -u $MACO_USER ${toolVenvDir}/bin/pip install -r ${MACO_DIR}/requirements.txt
exe sudo -u $MACO_USER ${MACO_BASE_DIR}/bin/pip install -r ${MACO_DIR}/requirements.txt
}
step_6_info() { echo "Create systemd service for $toolName"; }
step_6_info() {
echo "Create systemd service for $toolName"
echoinfo "(Make sure to modify the service content in the step configuration)"
}
step_6_alias() { ALIAS="service"; }
step_6() {
local macommanderServiceLoc="/etc/systemd/system/matrix-commander.service"
@@ -81,11 +90,57 @@ step_6() {
exe systemctl daemon-reload
}
step_10_info() { echo "Run $toolName"; }
step_10_alias() { ALIAS="run"; }
step_10_info() { echo "First run to create credential file and encryption store"; }
step_10_alias() { ALIAS="firstrun"; }
step_10() {
exe sudo -u "$MACO_USER" mkdir -p "$toolCredentialDir" "$toolEncStoreDir"
exe cd "$toolCredentialDir"
step run
[ -e ./store ] && exe mv store "$toolEncStoreDir"
echoseq " [I] use \"$SEQ_NAME run --verify\" to verify against an existing session (like Element)"
}
step_20_info() { echo "Run $toolName"; }
step_20_alias() { ALIAS="run"; }
step_20() {
shift
exe sudo -u $MACO_USER "$toolVenvDir/bin/python3" "$MACO_DIR/matrix-commander.py" "$@"
exe sudo -u $MACO_USER "$MACO_BASE_DIR/bin/python3" "$MACO_DIR/matrix-commander.py" "$@"
}
step_22_info() {
echoinfoArgs "[MESSAGE] [MESSAGE] ..."
echo "Send message"
echoinfo "Each string ([MESSAGE]) is send as separate message"
}
step_22_alias() { ALIAS="message"; }
step_22() {
shift
step run -m "$@"
}
step_42_info() { echo "Notes"; }
step_42_alias() { ALIAS="notes"; }
step_42() {
outColor green
cat <<NOTES_EOF
# 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
* Room Info -> People -> select matrix commander user -> Security -> sessions -> matrix-commander session
* verify with emojis
## Credential information location
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
store - $MACO_BASE_DIR/.local/share/matrix-commander/store
NOTES_EOF
}
VERSION_SEQREV=15