Skip to content

Commit

Permalink
Updates embargo scripts. (#1164)
Browse files Browse the repository at this point in the history
* Updates embargo scripts.

* Use ENVIRONMENT variable in embargo scripts.

---------

Co-authored-by: Thomas Scherz <[email protected]>
  • Loading branch information
scherztc and Thomas Scherz authored May 21, 2024
1 parent f410c78 commit edc4342
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
29 changes: 29 additions & 0 deletions script/embargo_notify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# Notify editors that a work has been released
# script/embargo_notify.sh [production|development]

ENVIRONMENT=$1

APP_DIRECTORY="$(dirname "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" )"


if [ $# -eq 0 ]; then
echo -e "ERROR: no environment argument [production|development] provided"
exit 1
fi

if [ $ENVIRONMENT != "production" ] && [ $ENVIRONMENT != "development" ]; then
echo -e "ERROR: environment argument must be either [production|development] most likely this will be development for local machines and production otherwise"
exit 1
fi

if [[ $ENVIRONMENT == "production" ]]; then
export PATH=$PATH:/srv/apps/.gem/ruby/2.7.0/bin
fi

banner "Notify Embargoe Editors"

cd $APP_DIRECTORY

RAILS_ENV=$ENVIRONMENT bundle exec rake embargo_notify
27 changes: 23 additions & 4 deletions script/release_embargo.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
#!/bin/bash
#!/bin/sh

# Change and expired embargoed objects to open access
# Runs as a cron job daily just after midnight
# script/release_embargo.sh [production|development]

cd "$(dirname "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" )"
export RELEASE_DATE=`date -v +1d "+%Y-\%m-\%d"`
bundle exec rake embargo_release["$RELEASE_DATE"]
ENVIRONMENT=$1

APP_DIRECTORY="$(dirname "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" )"

if [ $# -eq 0 ]; then
echo -e "ERROR: no environment argument [production|development] provided"
exit 1
fi

if [ $ENVIRONMENT != "production" ] && [ $ENVIRONMENT != "development" ]; then
echo -e "ERROR: environment argument must be either [production|development] most likely this will be development for local machines and production otherwise"
exit 1
fi

if [[ $ENVIRONMENT == "production" ]]; then
export PATH=$PATH:/srv/apps/.gem/ruby/2.7.0/bin
fi

cd $APP_DIRECTORY
export RELEASE_DATE=`date +\%Y-\%m-\%d -d "+1 day"`
RAILS_ENV=$ENVIRONMENT bundle exec rake embargo_release["$RELEASE_DATE"]

0 comments on commit edc4342

Please sign in to comment.