refactoring changes from sequpgrade (endReturn, ...) and some modernizations
This commit is contained in:
@@ -59,7 +59,7 @@ step_1_info() { echo "Installing $toolName dependencies"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
step_1() {
|
||||
exe apt update
|
||||
endReturn -o $? "Updating apt repositories failed"
|
||||
endReturn "Updating apt repositories failed"
|
||||
|
||||
if [ "$osName" != "Raspbian" ] ; then
|
||||
toolDepsRaspi=""
|
||||
@@ -72,7 +72,7 @@ step_2_alias() { echo "createdb"; }
|
||||
step_2() {
|
||||
readDatabaseInfos
|
||||
|
||||
exe cd ~postgres
|
||||
exe cd ~postgres
|
||||
exe su -c "psql -c \"CREATE USER ${postgresUser} WITH ENCRYPTED password '${postgresPass}';\"" - postgres
|
||||
exe su -c "psql -c \"CREATE DATABASE ${postgresDb} ENCODING \"UTF8\" LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ${postgresUser};\"" - postgres
|
||||
exe su -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"${postgresDb}\" to ${postgresUser};\"" - postgres
|
||||
@@ -151,7 +151,7 @@ SyslogIdentifier=synapse
|
||||
[Install]
|
||||
WantedBy=multi-user.target"
|
||||
|
||||
step_10_info() {
|
||||
step_10_info() {
|
||||
echo -n "Upgrade $toolName installation"
|
||||
if ! contextHelp ; then
|
||||
echo " at $MATRIX_HOME"
|
||||
@@ -188,7 +188,7 @@ step_12() {
|
||||
exe service ${toolServiceName} restart
|
||||
}
|
||||
|
||||
step_14_info() {
|
||||
step_14_info() {
|
||||
echo "Show $toolName version"
|
||||
}
|
||||
step_14_options() { echo "[IP]:8008"; }
|
||||
@@ -212,7 +212,7 @@ step_16_options() { echo "[OPTION] [IP]:8008"; }
|
||||
step_16_alias() { echo "listuser"; }
|
||||
step_16() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local synapseIP=localhost
|
||||
@@ -242,7 +242,7 @@ step_18() {
|
||||
exe /opt/synapse/venv/bin/register_new_matrix_user -c "$MATRIX_HOME/homeserver.yaml" $toolUrlLocal
|
||||
}
|
||||
|
||||
step_20_info() {
|
||||
step_20_info() {
|
||||
shift
|
||||
echo -n "Reset user password"
|
||||
contextExe && echoinfo " for ${1:-}" || echo
|
||||
@@ -270,7 +270,7 @@ step_20() {
|
||||
exep "echo \"$string\" | su postgres -c 'psql -d synapse -f -'"
|
||||
}
|
||||
|
||||
step_22_info() {
|
||||
step_22_info() {
|
||||
echo "List all rooms"
|
||||
echoinfo "[OPTION]"
|
||||
echoinfo " -r : Raw json output"
|
||||
@@ -279,7 +279,7 @@ step_22_options() { echo "[OPTION] [IP]:8008"; }
|
||||
step_22_alias() { echo "listrooms"; }
|
||||
step_22() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local arg
|
||||
@@ -304,7 +304,7 @@ step_22() {
|
||||
exep "curl -sS --header \"Authorization: Bearer $MATRIX_ACCESS\" \"$apiCall\" | python -m json.tool $grepOut"
|
||||
}
|
||||
|
||||
step_24_info() {
|
||||
step_24_info() {
|
||||
echo "List all room members"
|
||||
echoinfo "[OPTION]"
|
||||
echoinfo " -r : Raw json output"
|
||||
@@ -313,7 +313,7 @@ step_24_options() { echo "[OPTION] [ROOM ID] [IP]:8008"; }
|
||||
step_24_alias() { echo "listmember"; }
|
||||
step_24() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local roomId=""
|
||||
@@ -343,7 +343,7 @@ step_24() {
|
||||
exep "curl -sS --header \"Authorization: Bearer $MATRIX_ACCESS\" \"$apiCall\" | python -m json.tool $grepOut"
|
||||
}
|
||||
|
||||
step_26_info() {
|
||||
step_26_info() {
|
||||
echo "Delete rooms without local users"
|
||||
echoinfo " [IP] : default is localhost"
|
||||
}
|
||||
@@ -351,7 +351,7 @@ step_26_options() { echo "[IP]:8008"; }
|
||||
step_26_alias() { echo "purge"; }
|
||||
step_26() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local i
|
||||
@@ -378,7 +378,7 @@ step_28_options() { echo "<ROOM ID> [IP]:8008"; }
|
||||
step_28_alias() { echo "deleteroom"; }
|
||||
step_28() {
|
||||
adminTokenCheck
|
||||
endReturn -o $? "Admin token needed. Check $seq_configFile"
|
||||
endReturn "Admin token needed. Check $seq_configFile"
|
||||
|
||||
shift
|
||||
local roomId=""
|
||||
@@ -393,7 +393,7 @@ step_28() {
|
||||
|
||||
[ -n "${1:-}" ] && synapseIP="$1"
|
||||
|
||||
echo " [I] Deleting room with ID: $roomId"
|
||||
info "Deleting room with ID: $roomId"
|
||||
|
||||
local apiCall="http://${synapseIP}:8008/_synapse/admin/v2/rooms/$roomId"
|
||||
exep "curl -sS --header \"Authorization: Bearer $MATRIX_ACCESS\" \
|
||||
@@ -437,11 +437,11 @@ step_30() {
|
||||
postgresDb="$1"
|
||||
fi
|
||||
|
||||
echo " [I] Stopping ${toolServiceName}"
|
||||
info "Stopping ${toolServiceName}"
|
||||
exe service ${toolServiceName} stop
|
||||
endReturn -o $? "Couldn't stop ${toolServiceName}. Stopping debloat."
|
||||
endReturn "Couldn't stop ${toolServiceName}. Stopping debloat."
|
||||
|
||||
exe cd ~postgres
|
||||
exe cd ~postgres
|
||||
exe su -c "psql -d ${postgresDb} -c \"REINDEX${pgVerboseReId}DATABASE ${postgresDb};\"" - postgres
|
||||
exe su -c "psql -c \"VACUUM FULL${pgVerboseVac};\"" - postgres
|
||||
|
||||
@@ -454,7 +454,7 @@ step_50_alias() { echo "dropdb"; }
|
||||
step_50() {
|
||||
readDatabaseInfos
|
||||
|
||||
exe cd ~postgres
|
||||
exe cd ~postgres
|
||||
exe su -c "psql -c \"DROP DATABASE ${postgresDb};\"" - postgres
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user