Skip to content

Commit

Permalink
Add system wide alert when converting to dev site
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgomez committed May 17, 2024
1 parent 4240955 commit 9499ade
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions utility-scripts/dspace-convert-to-dev.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,53 @@
#! /bin/bash

sed -i 's/biblioteca.sistedes.es/bdsistedes.dsic.upv.es/g' /opt/dspace.ui/config/config.prod.yml
sed -i 's/biblioteca.sistedes.es/bdsistedes.dsic.upv.es/g' /opt/dspace.server/config/local.cfg
prodsite=biblioteca.sistedes.es
devsite=bdsistedes.dsic.upv.es
cookies=/tmp/bdcookies.tmp
headers=/tmp/bdheaders.tmp
user=USER_EMAIL
password=USER_PASSWORD

sed -i "s/$prodsite/$devsite/g" /opt/dspace.ui/config/config.prod.yml
sed -i "s/$prodsite/$devsite/g" /opt/dspace.server/config/local.cfg

function get_header() {
cat /tmp/bdheaders.tmp | grep $1 | cut -d ':' -f2 | xargs
}

curl --silent \
--output /dev/null \
--cookie-jar $cookies \
--dump-header $headers \
'http://localhost:8080/dspace.server/api/'

token=$(csfr_token DSPACE-XSRF-TOKEN)

curl --silent \
--output /dev/null \
--cookie $cookies \
--cookie-jar $cookies \
--dump-header $headers \
'http://localhost:8080/dspace.server/api/authn/login' \
-H "X-XSRF-TOKEN: $token" \
--data-urlencode "user=$user" \
--data-urlencode "password=$password"

token=$(get_header DSPACE-XSRF-TOKEN)
auth=$(get_header Authorization)

curl --silent \
--output /dev/null \
--cookie $cookies \
--cookie-jar $cookies \
--dump-header $headers \
-X PUT \
'http://localhost:8080/dspace.server/api/system/systemwidealerts/1' \
-H "Content-Type: application/json" \
-H "X-XSRF-TOKEN: $token" \
-H "Authorization: $auth" \
--data '{ "message": "<b>Este es un sitio de desarrollo y pruebas</b>", "countdownTo": null, "allowSessions": "all", "active": true }'

rm -rf $cookies $headers

systemctl restart tomcat9.service
pm2 restart all

0 comments on commit 9499ade

Please sign in to comment.