matrix-commander - Rearange steps call matrix-commander as first

This commit is contained in:
2022-03-12 15:11:01 +01:00
parent 0911473db6
commit 11198a3b46

View File

@@ -38,23 +38,40 @@ step_config() {
return 0 return 0
} }
step_1_info() { echo "Run $toolName"; }
step_1_info() { echo "Install $toolName dependencies"; } step_1_alias() { ALIAS="run"; }
step_1_alias() { ALIAS="install"; }
step_1() { step_1() {
shift
exe sudo -u $MACO_USER "$MACO_BASE_DIR/bin/python3" "$MACO_DIR/matrix-commander.py" "$@"
}
step_3_info() {
echoinfoArgs "[MESSAGE] [MESSAGE] ..."
echo "Send message"
echoinfo "Each string ([MESSAGE]) is send as separate message"
}
step_3_alias() { ALIAS="message"; }
step_3() {
shift
step run -m "$@"
}
step_50_info() { echo "Install $toolName dependencies"; }
step_50_alias() { ALIAS="install"; }
step_50() {
apt install $toolDeps $APTOPT apt install $toolDeps $APTOPT
} }
step_2_info() { echo "Add system user $MACO_USER"; } step_51_info() { echo "Add system user $MACO_USER"; }
step_2() { step_51() {
id $MACO_USER >/dev/null 2>&1 id $MACO_USER >/dev/null 2>&1
[ $? -eq 0 ] && endReturn -o 1 "User $MACO_USER already exists" [ $? -eq 0 ] && endReturn -o 1 "User $MACO_USER already exists"
exe adduser --system $MACO_USER --group --home "${MACO_BASE_DIR}" exe adduser --system $MACO_USER --group --home "${MACO_BASE_DIR}"
} }
step_3_info() { echo "Create venv and install $toolName"; } step_52_info() { echo "Create venv and install $toolName"; }
step_3() { step_52() {
[ -e "$MACO_BASE_DIR" ] && endReturn -o 1 "$toolName already installed" [ -e "$MACO_BASE_DIR" ] && endReturn -o 1 "$toolName already installed"
exe python3 -m venv "$MACO_BASE_DIR" exe python3 -m venv "$MACO_BASE_DIR"
@@ -65,8 +82,8 @@ step_3() {
exe sudo -u $MACO_USER ${MACO_BASE_DIR}/bin/pip install --upgrade pip exe sudo -u $MACO_USER ${MACO_BASE_DIR}/bin/pip install --upgrade pip
} }
step_4_info() { echo "Install python requirements"; } step_53_info() { echo "Install python requirements"; }
step_4() { step_53() {
cat <<NOTES_END cat <<NOTES_END
# Remove following packages for headless servers # Remove following packages for headless servers
@@ -79,20 +96,20 @@ NOTES_END
} }
step_6_info() { step_55_info() {
echo "Create systemd service for $toolName" echo "Create systemd service for $toolName"
echoinfo "(Make sure to modify the service content in the step configuration)" echoinfo "(Make sure to modify the service content in the step configuration)"
} }
step_6_alias() { ALIAS="service"; } step_55_alias() { ALIAS="service"; }
step_6() { step_55() {
local macommanderServiceLoc="/etc/systemd/system/matrix-commander.service" local macommanderServiceLoc="/etc/systemd/system/matrix-commander.service"
addConf -s "$MACO_SERVICE" "$macommanderServiceLoc" addConf -s "$MACO_SERVICE" "$macommanderServiceLoc"
exe systemctl daemon-reload exe systemctl daemon-reload
} }
step_10_info() { echo "First run to create credential file and encryption store"; } step_57_info() { echo "First run to create credential file and encryption store"; }
step_10_alias() { ALIAS="firstrun"; } step_57_alias() { ALIAS="firstrun"; }
step_10() { step_57() {
exe sudo -u "$MACO_USER" mkdir -p "$toolCredentialDir" "$toolEncStoreDir" exe sudo -u "$MACO_USER" mkdir -p "$toolCredentialDir" "$toolEncStoreDir"
exe cd "$toolCredentialDir" exe cd "$toolCredentialDir"
step run step run
@@ -101,27 +118,11 @@ step_10() {
echoseq " [I] use \"$SEQ_NAME run --verify\" to verify against an existing session (like Element)" 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 "$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_60_info() { echo "Notes"; }
step_42_alias() { ALIAS="notes"; } step_60_alias() { ALIAS="notes"; }
step_42() { step_60() {
outColor green outColor green
cat <<NOTES_EOF cat <<NOTES_EOF
# Verify matrix-commander "device" # Verify matrix-commander "device"