Compare commits

...

8 Commits

4 changed files with 52 additions and 18 deletions

64
abra.sh
View File

@ -1,4 +1,4 @@
export APP_ENTRYPOINT_VERSION=v5
export APP_ENTRYPOINT_VERSION=v6
migrate() {
export DATABASE_PASSWORD=$(cat /run/secrets/db_password)
@ -6,24 +6,14 @@ migrate() {
yarn db:migrate --env=production-ssl-disabled
}
delete_user() {
delete_user_by_id() {
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ... delete_user <user-to-delete> <user-to-replace>"
echo "Usage: ... delete_user_by_id <userid-to-delete> <userid-to-replace>"
exit 1
fi
USERID_REMOVE=$(echo "SELECT id FROM users WHERE username = '$1'" | psql -t -A -U outline outline)
USERID_REPLACE=$(echo "SELECT id FROM users WHERE username = '$2'" | psql -t -A -U outline outline)
if [ -z "$USERID_REMOVE" ]; then
echo "Can't find ID of '$1'"
exit 1
fi
if [ -z "$USERID_REPLACE" ]; then
echo "Can't find ID of '$2'"
exit 1
fi
USERID_REPLACE="$2"
USERID_REMOVE="$1"
psql -U outline outline <<- SQL
UPDATE documents SET "userId" = '$USERID_REPLACE' WHERE "userId" = '$USERID_REMOVE';
@ -41,6 +31,48 @@ delete_user() {
DELETE FROM notification_settings WHERE "userId" = '$USERID_REMOVE';
DELETE FROM events WHERE "actorId" = '$USERID_REMOVE';
DELETE FROM events WHERE "userId" = '$USERID_REMOVE';
DELETE FROM users WHERE username = '$1';
DELETE FROM users WHERE "id" = '$USERID_REMOVE';
SQL
}
delete_user() {
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ... delete_user <userid-to-delete> <userid-to-replace>"
exit 1
fi
USERID_REMOVE=$(echo "SELECT id FROM users WHERE username = '$1'" | psql -t -A -U outline outline)
USERID_REPLACE=$(echo "SELECT id FROM users WHERE username = '$2'" | psql -t -A -U outline outline)
if [ -z "$USERID_REMOVE" ]; then
echo "Can't find ID of '$1'"
exit 1
fi
if [ -z "$USERID_REPLACE" ]; then
echo "Can't find ID of '$2'"
exit 1
fi
delete_user_by_id "$USERID_REMOVE" "$USERID_REPLACE"
}
delete_duplicate_users() {
if [ -z "$1" ]; then
echo "Usage: ... delete_duplicate_users <username>"
exit 1
fi
USERIDS=$(echo "SELECT id FROM users WHERE username = '$1' ORDER BY users.\"createdAt\" DESC" | psql -t -A -U outline outline)
if [ ! "$(echo "$USERIDS" | wc -l)" -gt 1 ]; then
echo "Only one user exists, bailing"
exit 1
fi
USERID_NEW=$(echo "$USERIDS" | head -n1)
for USERID_OLD in $(echo "$USERIDS" | tail -n+2); do
delete_user_by_id "$USERID_OLD" "$USERID_NEW"
done
}

View File

@ -8,6 +8,7 @@ services:
environment:
- GOOGLE_CLIENT_ID
- GOOGLE_ENABLED
- ALLOWED_DOMAINS
secrets:
google_client_secret:

View File

@ -6,7 +6,7 @@ services:
networks:
- backend
- proxy
image: outlinewiki/outline:0.64.3
image: outlinewiki/outline:0.67.2
secrets:
- aws_secret_key
- db_password
@ -43,7 +43,7 @@ services:
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
- "coop-cloud.${STACK_NAME}.version=0.4.0+0.64.3"
- "coop-cloud.${STACK_NAME}.version=0.5.0+0.67.2"
## Redirect from EXTRA_DOMAINS to DOMAIN
#- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"

View File

@ -15,4 +15,5 @@ export SECRET_KEY=$(cat /run/secrets/secret_key)
export DATABASE_PASSWORD=$(cat /run/secrets/db_password)
export DATABASE_URL="postgres://outline:${DATABASE_PASSWORD}@${STACK_NAME}_db:5432/outline"
/usr/local/bin/yarn db:migrate --env=production-ssl-disabled
/usr/local/bin/yarn start "$@"