Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #130 from EUDAT-B2SAFE/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
michec81 authored Jul 16, 2019
2 parents 783e3b1 + f16d805 commit 015e216
Show file tree
Hide file tree
Showing 11 changed files with 1,763 additions and 1,212 deletions.
116 changes: 116 additions & 0 deletions packaging/convert_b2safe_conf_to_json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#
# procedure to convert the B2SAFE parameters to json using a bash script
#
# set tabstop=4
# set expandtab
#
#set -x
#
#
#
# set default parameters for installation
INSTALL_CONFIG=./install.conf

# start default parameters for setup
#===================================
IRODS_CONF_DIR=/etc/irods
#
IRODS_DIR=/var/lib/irods
#
B2SAFE_PACKAGE_DIR=/opt/eudat/b2safe
#
# the default iRODS resource to use
DEFAULT_RESOURCE=eudat
#
# credentials type and location
CRED_STORE_TYPE=os
CRED_FILE_PATH=$B2SAFE_PACKAGE_DIR/conf
SERVER_ID=
SERVERAPIREG=
SERVERAPIPUB=

#
# credentials for epicclient2
HANDLE_SERVER_URL=
PRIVATE_KEY=
CERTIFICATE_ONLY=
PREFIX=
HANDLEOWNER=
REVERSELOOKUP_USERNAME=
HTTPS_VERIFY=
#
USERS=
LOG_LEVEL=
LOG_DIR=
SHARED_SPACE=
#
# EUDAT iRODS rules behavioral parameters. Because these are later added
# sensible defaults are chosen. They can be overridden by adding them to
# the configuration in install.conf
AUTHZ_ENABLED=true
MSG_QUEUE_ENABLED=false


if [ -e $INSTALL_CONFIG ]
then
source $INSTALL_CONFIG
else
echo "ERROR: $INSTALL_CONFIG not present!"
STATUS=1
fi

string=$(echo "$HTTPS_VERIFY" | tr '[:upper:]' '[:lower:]')
if [[ $string =~ .*true.* ]]
then
HTTPS_VERIFY_STRING=true
elif [[ $string =~ .*false.* ]]
then
HTTPS_VERIFY_STRING=false
else
HTTPS_VERIFY_STRING="\"${HTTPS_VERIFY}\""
fi

let count=0
handle_users_array=(`echo ${USERS} | sed 's/[\t ]+/\n/g'`)
handle_users_string=
for each in ${handle_users_array[@]}
do
if [ $count -eq 0 ]
then
handle_users_string=$(echo -n "\"$each\"")
else
handle_users_string=$handle_users_string$(echo -n ", \"$each\"")
fi
let count=$count+1
done


cat > install.json << EOT
{
"b2safe_package_dir": "${B2SAFE_PACKAGE_DIR}",
"irods_conf_dir": "${IRODS_CONF_DIR}",
"irods_dir": "${IRODS_DIR}",
"irods_default_resource": "${DEFAULT_RESOURCE}",
"cred_store_type": "${CRED_STORE_TYPE}",
"cred_file_path": "${CRED_FILE_PATH}",
"server_id": "${SERVER_ID}",
"server_api_reg": "${SERVERAPIREG}",
"server_api_pub": "${SERVERAPIPUB}",
"handle_server_url": "${HANDLE_SERVER_URL}",
"handle_private_key": "${PRIVATE_KEY}",
"handle_certificate_only": "${CERTIFICATE_ONLY}",
"handle_prefix": "${PREFIX}",
"handle_owner": "${HANDLEOWNER}",
"handle_reverse_lookup_name": "${REVERSELOOKUP_USERNAME}",
"handle_https_verify": ${HTTPS_VERIFY_STRING},
"handle_users": [ ${handle_users_string} ],
"handle_groups": [ ],
"log_level": "${LOG_LEVEL}",
"log_directory": "${LOG_DIR}",
"shared_space": "${SHARED_SPACE}",
"authz_enabled": ${AUTHZ_ENABLED},
"msg_queue_enabled": ${MSG_QUEUE_ENABLED}
}
EOT

chmod 600 install.json
83 changes: 31 additions & 52 deletions packaging/create_deb_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ cp $RPM_SOURCE_DIR/*.txt $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}
cp $RPM_SOURCE_DIR/LICENSE $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}
cp $RPM_SOURCE_DIR/cmd/* $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/cmd
cp $RPM_SOURCE_DIR/conf/* $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/conf
cp $RPM_SOURCE_DIR/packaging/install.sh $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/packaging
cp $RPM_SOURCE_DIR/packaging/install.py $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/packaging
cp $RPM_SOURCE_DIR/packaging/convert_b2safe_conf_to_json.sh $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/packaging
cp $RPM_SOURCE_DIR/rulebase/* $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/rulebase
cp $RPM_SOURCE_DIR/rules/* $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/testRules
mkdir -p $RPM_BUILD_ROOT${PACKAGE}/var/log/irods
Expand All @@ -60,6 +61,7 @@ chmod 700 $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/cmd/*.py
chmod 600 $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/conf/*.json
chmod 600 $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/conf/*.conf
chmod 700 $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/packaging/*.sh
chmod 700 $RPM_BUILD_ROOT${PACKAGE}${IRODS_PACKAGE_DIR}/packaging/*.py

# create packaging directory
mkdir -p $RPM_BUILD_ROOT${PACKAGE}/DEBIAN
Expand Down Expand Up @@ -96,60 +98,37 @@ cat > $RPM_BUILD_ROOT${PACKAGE}/DEBIAN/postinst << EOF
# script for postinstall actions
# create configuration file if it does not exist yet
INSTALL_CONF=${IRODS_PACKAGE_DIR}/packaging/install.conf
INSTALL_CONF=${IRODS_PACKAGE_DIR}/packaging/install.json
if [ ! -e \$INSTALL_CONF ]
then
cat > \$INSTALL_CONF << EOF2
#
# parameters for installation of irods module B2SAFE
#
# the absolute directory where the irods config is installed
IRODS_CONF_DIR=/etc/irods
#
# the absolute directory where irods is installed
IRODS_DIR=/var/lib/irods
#
# the directory where B2SAFE is installed as a package
B2SAFE_PACKAGE_DIR=${IRODS_PACKAGE_DIR}
#
# the default iRODS resource to use. Will be set in core.re
DEFAULT_RESOURCE=demoResc
#
# epic credentials type and location
CRED_STORE_TYPE=os
CRED_FILE_PATH=\\\$B2SAFE_PACKAGE_DIR/conf/credentials
SERVER_ID="irods://<fully_qualified_hostname>:1247"
#
# epic credentials file usage parameters
#
# epicclient2 parameters
HANDLE_SERVER_URL=<https://epic3.storage.surfsara.nl:8001>
PRIVATE_KEY=</path/prefix_suffix_index_privkey.pem>
CERTIFICATE_ONLY=</path/prefix_suffix_index_certificate_only.pem>
PREFIX=<ZZZ>
HANDLEOWNER="200:0.NA/\\\$PREFIX"
REVERSELOOKUP_USERNAME=<ZZZ>
HTTPS_VERIFY="True"
#
# users for msiexec command
USERS="user0#Zone0 user1#Zone1"
#
# loglevel and log directory
# possible log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_LEVEL=DEBUG
LOG_DIR=/var/log/irods
#
#
# iRODS behavioral parameters
#
# check if user is authorized to perform several functions
AUTHZ_ENABLED=true
#
# check if message queue is enabled
MSG_QUEUE_ENABLED=false
#
{
"b2safe_package_dir": "${IRODS_PACKAGE_DIR}",
"irods_conf_dir": "/etc/irods",
"irods_dir": "/var/lib/irods/iRODS",
"irods_default_resource": "demoResc",
"cred_store_type": "os",
"cred_file_path": "${IRODS_PACKAGE_DIR}/conf/credentials",
"server_id": "irods://<fully_qualified_hostname>:1247",
"server_api_reg": "irods://<fully_qualified_hostname>:1247",
"server_api_pub": "irods://<fully_qualified_hostname>:1247",
"handle_server_url": "https://epic6.storage.surfsara.nl:8003",
"handle_private_key": "</path/prefix_suffix_index_privkey.pem>",
"handle_certificate_only": "</path/prefix_suffix_index_certificate_only.pem>",
"handle_prefix": "<ZZZ>",
"handle_owner": "200:0.NA/<ZZZ>",
"handle_reverse_lookup_name": "<ZZZ>",
"handle_reverse_lookup_password": "<reverse_lookup_password>",
"handle_https_verify": True,
"handle_users": [ "user0#Zone0", "user1#Zone1" ],
"log_level": "INFO",
"log_directory": "/var/log/irods",
"shared_space": "",
"authz_enabled": true,
"msg_queue_enabled": false
}
EOF2
fi
Expand All @@ -162,11 +141,11 @@ The package b2safe has been installed in ${IRODS_PACKAGE_DIR}.
To install/configure it in iRODS do following as the user who runs iRODS :
# update install.conf with correct parameters with your favorite editor
sudo vi ${IRODS_PACKAGE_DIR}/packaging/install.conf
sudo vi ${IRODS_PACKAGE_DIR}/packaging/install.json
# install/configure it as the user who runs iRODS
source /etc/irods/service_account.config
sudo su - \\\$IRODS_SERVICE_ACCOUNT_NAME -s "/bin/bash" -c "cd ${IRODS_PACKAGE_DIR}/packaging/ ; ./install.sh"
sudo su - \\\$IRODS_SERVICE_ACCOUNT_NAME -s "/bin/bash" -c "cd ${IRODS_PACKAGE_DIR}/packaging/ ; ./install.py"
EOF1
Expand Down
Loading

0 comments on commit 015e216

Please sign in to comment.