Debian Codegraph @

entrypoint-dev.sh

raw
1 #!/bin/bash
2 # Copyright 2023 The Archivista Contributors
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 env
16 if [[ -z $ARCHIVISTA_SQL_STORE_BACKEND ]]; then
17 SQL_TYPE="MYSQL"
18 else
19 SQL_TYPE=$(echo "$ARCHIVISTA_SQL_STORE_BACKEND" | tr '[:lower:]' '[:upper:]')
20 fi
21
22 case $SQL_TYPE in
23 MYSQL)
24 if [[ -z $ARCHIVISTA_SQL_STORE_CONNECTION_STRING ]]; then
25 ARCHIVISTA_SQL_STORE_CONNECTION_STRING="root:example@db/testify"
26 fi
27 echo "Running migrations for MySQL"
28 atlas migrate apply --dir "file:///src/ent/migrate/migrations/mysql" --url "mysql://$ARCHIVISTA_SQL_STORE_CONNECTION_STRING"
29 atlas_rc=$?
30 ;;
31 PSQL)
32 echo "Running migrations for Postgres"
33 atlas migrate apply --dir "file:///src/ent/migrate/migrations/pgsql" --url "$ARCHIVISTA_SQL_STORE_CONNECTION_STRING"
34 atlas_rc=$?
35 ;;
36 *)
37 echo "Unknown SQL backend: $ARCHIVISTA_SQL_STORE_BACKEND"
38 exit 1
39 ;;
40 esac
41
42 if [[ $atlas_rc -ne 0 ]]; then
43 echo "Failed to apply migrations"
44 exit 1
45 fi
46
47 CompileDaemon -log-prefix=false -build="go build -buildvcs=false -o /out/archivista ./cmd/archivista" -command="/out/archivista"