2021-08-21 12:08:36 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
|
|
|
DIR="${0%/*}"
|
|
|
|
|
2021-09-15 14:48:52 +00:00
|
|
|
# replace containers
|
|
|
|
podman rm -if synapse
|
|
|
|
podman rm -if nextcloud
|
|
|
|
|
|
|
|
podman run -d --name=nextcloud -p 8080:80 -v "$DIR:/var/www/html/custom_apps/upschooling" docker.io/nextcloud
|
2021-08-21 12:41:50 +00:00
|
|
|
podman exec nextcloud chown -R 33 /var/www/html/custom_apps
|
|
|
|
"$DIR/podman-reown.sh"
|
2021-08-21 14:25:23 +00:00
|
|
|
podman exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make composer'
|
2021-08-21 13:20:15 +00:00
|
|
|
podman exec --user 33 nextcloud php occ maintenance:install --database sqlite --admin-user admin --admin-pass admin
|
2021-08-21 12:59:18 +00:00
|
|
|
podman exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug
|
2021-08-21 13:20:15 +00:00
|
|
|
podman exec --user 33 nextcloud php occ app:enable --force upschooling
|
2021-09-15 12:30:15 +00:00
|
|
|
|
|
|
|
if podman volume exists synapse-data; then
|
|
|
|
echo "Found existing synapse-data volume"
|
|
|
|
else
|
2021-09-18 08:33:54 +00:00
|
|
|
podman run --rm \
|
2021-09-15 12:30:15 +00:00
|
|
|
--name=synapse \
|
|
|
|
--hostname synapse \
|
|
|
|
"--mount=type=volume,src=synapse-data,dst=/data" \
|
|
|
|
-e SYNAPSE_SERVER_NAME=synapse \
|
|
|
|
-e SYNAPSE_REPORT_STATS=no \
|
|
|
|
docker.io/matrixdotorg/synapse \
|
|
|
|
generate
|
|
|
|
echo "Generated fresh synapse-data volume"
|
|
|
|
fi
|
|
|
|
|
|
|
|
podman run -d \
|
|
|
|
--name=synapse \
|
|
|
|
"--mount=type=volume,src=synapse-data,dst=/data" \
|
|
|
|
"--network=container:$(podman inspect --format "{{.Id}}" nextcloud)" \
|
|
|
|
--hostname synapse \
|
|
|
|
docker.io/matrixdotorg/synapse
|
|
|
|
|
2021-09-15 14:48:52 +00:00
|
|
|
# wait for synapse to start
|
|
|
|
MAX_TRIES=15
|
|
|
|
for ((i = 0 ; i < $MAX_TRIES ; i++)); do
|
|
|
|
if podman logs synapse 2>&1 | grep -q "Synapse now listening on TCP port 8008"; then
|
|
|
|
echo -e "Synapse has started. \e[1;38;5;2mOK\033[0m"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $i -ge $MAX_TRIES ]]; then
|
|
|
|
echo "Synapse did not start in time! Use \`podman logs synapse\` to investigate"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set +e
|
2021-09-15 12:30:15 +00:00
|
|
|
REGISTER_USER_OUTPUT="$(podman exec synapse register_new_matrix_user -u upschooling -p secret -a -c /data/homeserver.yaml http://localhost:8008)"
|
|
|
|
REGISTER_USER_SUCCESS=$?
|
2021-09-15 14:48:52 +00:00
|
|
|
set -e
|
2021-09-15 12:30:15 +00:00
|
|
|
|
|
|
|
if [[ "$REGISTER_USER_SUCCESS" != "0" ]]; then
|
|
|
|
if echo $REGISTER_USER_OUTPUT | grep -q "User ID already taken."; then
|
2021-09-15 14:48:52 +00:00
|
|
|
echo -e "User @upschooling:synapse already exists. \e[1;38;5;2mOK\033[0m"
|
2021-09-15 12:30:15 +00:00
|
|
|
else
|
|
|
|
echo "Could not create user @upschooling:synapse"
|
|
|
|
echo $REGISTER_USER_OUTPUT
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2021-09-15 14:48:52 +00:00
|
|
|
echo -e "Matrix user @upschooling:synapse created. \e[1;38;5;2mOK\033[0m"
|
2021-09-15 12:30:15 +00:00
|
|
|
fi
|