Nextcloud-App/podman-run.sh

53 lines
1.8 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DIR="${0%/*}"
podman run -d --name=nextcloud --replace=true -p 8080:80 -v "$DIR:/var/www/html/custom_apps/upschooling" docker.io/nextcloud
podman exec nextcloud chown -R 33 /var/www/html/custom_apps
"$DIR/podman-reown.sh"
podman exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make composer'
podman exec --user 33 nextcloud php occ maintenance:install --database sqlite --admin-user admin --admin-pass admin
podman exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug
podman exec --user 33 nextcloud php occ app:enable --force upschooling
if podman volume exists synapse-data; then
echo "Found existing synapse-data volume"
else
podman run -d --rm \
--name=synapse \
--replace=true \
--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 \
--replace=true \
"--mount=type=volume,src=synapse-data,dst=/data" \
"--network=container:$(podman inspect --format "{{.Id}}" nextcloud)" \
--hostname synapse \
docker.io/matrixdotorg/synapse
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=$?
if [[ "$REGISTER_USER_SUCCESS" != "0" ]]; then
if echo $REGISTER_USER_OUTPUT | grep -q "User ID already taken."; then
echo "User @upschooling:synapse already exists. OK"
else
echo "Could not create user @upschooling:synapse"
echo $REGISTER_USER_OUTPUT
exit 1
fi
else
echo "Matrix user @upschooling:synapse created. OK"
fi