Commit 9481689f authored by Petter Goksøyr Åsen's avatar Petter Goksøyr Åsen
Browse files

services: setup Koha rest API user before startup

parent 5be53752
......@@ -281,8 +281,12 @@ services:
volumes:
- /vagrant/redef/services/build:/services/build
environment:
KOHA_USER: "${KOHA_ADMINUSER}"
KOHA_PASSWORD: "${KOHA_ADMINPASS}"
KOHA_MYSQL_USER: "${KOHA_ADMINUSER}"
KOHA_MYSQL_PASS: "${KOHA_ADMINPASS}"
KOHA_MYSQL_DB: "koha_${KOHA_INSTANCE}"
KOHA_API_USER: "${KOHA_API_USER}"
KOHA_API_PASS: "${KOHA_API_PASS}"
KOHA_API_PASS_ENCRYPTED: "${KOHA_API_PASS_ENCRYPTED}"
KOHA_PORT: "http://koha:8081"
TRIPLESTORE_PORT: "http://fuseki:3030"
ELASTICSEARCH_URL: "http://elasticsearch:9200"
......
......@@ -19,4 +19,7 @@ export BS_PORT=replaceme
export BS_DB=replaceme
export BS_USER=replaceme
export BS_PASS=replacene
export GITREF=$(git rev-parse HEAD)
\ No newline at end of file
export GITREF=$(git rev-parse HEAD)
export KOHA_API_USER=api
export KOHA_API_PASS=secret
export KOHA_API_PASS_ENCRYPTED="$$2a$$08$$7WnfE3Fyh5W0C28Xp2SWH.NfgqLEZzw9oZI4qZ3MHf.lQS8yvv6hC"
\ No newline at end of file
FROM java:8
ADD javarunner.sh /javarunner.sh
RUN apt-get update && apt-get install -y \
mysql-client \
&& rm -rf /var/lib/apt/lists/*
ADD build/libs/services-1.0-SNAPSHOT-standalone.jar /services-1.0-SNAPSHOT-standalone.jar
CMD /javarunner.sh \
ADD entrypoint.sh /entrypoint.sh
CMD /entrypoint.sh \
-DKOHA_PORT="$KOHA_PORT" \
-DKOHA_USER="$KOHA_USER" \
-DKOHA_PASSWORD="$KOHA_PASSWORD" \
-DKOHA_API_USER="$KOHA_API_USER" \
-DKOHA_API_PASS="$KOHA_API_PASS" \
-DTRIPLESTORE_PORT="$TRIPLESTORE_PORT" \
-DDATA_BASEURI="$DATA_BASEURI" \
-DELASTICSEARCH_URL="$ELASTICSEARCH_URL" \
......
#!/usr/bin/env bash
set -e
# Setup Koha REST api user
# ------------------------
# Add patron category for API user
mysql --protocol=tcp -h koha_mysql -u"$KOHA_MYSQL_USER" -p"$KOHA_MYSQL_PASS" "$KOHA_MYSQL_DB" -e "INSERT IGNORE INTO categories(categorycode, description) VALUES ('API', 'API-user')"
# Add branch for API user
mysql --protocol=tcp -h koha_mysql -u"$KOHA_MYSQL_USER" -p"$KOHA_MYSQL_PASS" "$KOHA_MYSQL_DB" -e "INSERT IGNORE INTO branches(branchcode, branchname) VALUES ('api', 'Intern API avdeling')"
# Add user with permissions needed for API use
mysql --protocol=tcp -h koha_mysql -u"$KOHA_MYSQL_USER" -p"$KOHA_MYSQL_PASS" "$KOHA_MYSQL_DB" -e "INSERT IGNORE INTO borrowers(surname,branchcode,cardnumber,userid,password,flags,categorycode,privacy,dateexpiry) VALUES ('$KOHA_API_USER', 'api', '$KOHA_API_USER','$KOHA_API_USER','$KOHA_API_PASS_ENCRYPTED',1,'API',1,'2199-12-31')"
# Javarunner
# ----------
pid=0
term_handler() {
if [ $pid -ne 0 ]; then
kill -SIGTERM "$pid"
wait "$pid"
fi
exit 143; # 128 + 15 -- SIGTERM
}
trap 'kill ${!}; term_handler' SIGTERM
java $* &
pid="$!"
while true
do
tail -f /dev/null & wait ${!}
done
#!/usr/bin/env bash
pid=0
term_handler() {
if [ $pid -ne 0 ]; then
kill -SIGTERM "$pid"
wait "$pid"
fi
exit 143; # 128 + 15 -- SIGTERM
}
trap 'kill ${!}; term_handler' SIGTERM
java $* &
pid="$!"
while true
do
tail -f /dev/null & wait ${!}
done
......@@ -29,13 +29,13 @@ import static javax.ws.rs.core.Response.Status.FORBIDDEN;
import static javax.ws.rs.core.Response.Status.OK;
/**
* Responsibility: TODO.
* Responsibility: Handle creating and updating bibliographic records and items in Koha.
*/
public final class KohaAdapterImpl implements KohaAdapter {
private static final String DEFAULT_KOHA_PORT = "http://192.168.50.12:8081";
private static final String KOHA_USER = System.getProperty("KOHA_USER", "admin");
private static final String KOHA_PASSWORD = System.getProperty("KOHA_PASSWORD", "secret");
private static final String KOHA_USER = System.getProperty("KOHA_API_USER", "api");
private static final String KOHA_PASSWORD = System.getProperty("KOHA_API_PASS", "secret");
static final String SESSION_COOKIE_KEY = "CGISESSID";
private final Logger log = LoggerFactory.getLogger(this.getClass());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment