224 lines
9.6 KiB
Bash
224 lines
9.6 KiB
Bash
#!/bin/bash
|
|
|
|
GLOBAL_BASE_DIR=ckan-default
|
|
CUSTOM_BASE_DIR=$CKAN_CUSTOMIZATION_THEME
|
|
BASE_DIRECTORY=/srv/ckan_customisations
|
|
GLOBAL_DIR=${BASE_DIRECTORY}/${GLOBAL_BASE_DIR}
|
|
CUSTOM_DIR=${BASE_DIRECTORY}/${CUSTOM_BASE_DIR}
|
|
|
|
GCUBE_LICENSE=gcube-data-catalogue-licenses.json
|
|
GCUBE_LICENSE_DEST=/etc/ckan/default/gcube-data-catalogue-licenses.json
|
|
CKAN_PYTHON_DIR=/usr/lib/ckan/default/lib/python2.7/site-packages
|
|
CKAN_APP_DIR=/usr/lib/ckan/default/src
|
|
|
|
install_gcube_license() {
|
|
echo -e "\n*** Install_gcube_license called"
|
|
if [ -f "${CUSTOM_DIR}/${GCUBE_LICENSE}" ] ; then
|
|
cp -f "${CUSTOM_DIR}/${GCUBE_LICENSE}" "${GCUBE_LICENSE_DEST}"
|
|
else
|
|
cp -f "${GLOBAL_DIR}/${GCUBE_LICENSE}" "${GCUBE_LICENSE_DEST}"
|
|
fi
|
|
}
|
|
|
|
GCUBE_LANG_NAME=en_gcube
|
|
GCUBE_LANG_DEST_DIR=${CKAN_APP_DIR}/ckan/ckan/i18n/${GCUBE_LANG_NAME}/LC_MESSAGES
|
|
GCUBE_I18N_DEST_DIR=${CKAN_APP_DIR}/ckan/ckan/lib
|
|
GCUBE_SOURCE_LANG_DIR=languages/default
|
|
GCUBE_INIT_LANG=1
|
|
|
|
install_gcube_lang() {
|
|
echo -e "\n*** Install_gcube_lang called"
|
|
if [ ! -d ${GCUBE_LANG_DEST_DIR} ] ; then
|
|
mkdir -p ${GCUBE_LANG_DEST_DIR}
|
|
GCUBE_INIT_LANG=0
|
|
fi
|
|
|
|
if [ -d "${CUSTOM_DIR}/${GCUBE_SOURCE_LANG_DIR}" ] ; then
|
|
cp -f "${CUSTOM_DIR}/${GCUBE_SOURCE_LANG_DIR}/${GCUBE_LANG_NAME}/LC_MESSAGES/ckan.po" "${GCUBE_LANG_DEST_DIR}"
|
|
cp -f "${CUSTOM_DIR}/${GCUBE_SOURCE_LANG_DIR}/i18n.py" "${GCUBE_I18N_DEST_DIR}/i18n.py"
|
|
else
|
|
cp -f "${GLOBAL_DIR}/${GCUBE_SOURCE_LANG_DIR}/${GCUBE_LANG_NAME}/LC_MESSAGES/ckan.po" "${GCUBE_LANG_DEST_DIR}"
|
|
cp -f "${GLOBAL_DIR}/${GCUBE_SOURCE_LANG_DIR}/i18n.py" "${GCUBE_I18N_DEST_DIR}/i18n.py"
|
|
fi
|
|
|
|
. /usr/lib/ckan/default/bin/activate
|
|
cd "${CKAN_APP_DIR}/ckan"
|
|
python setup.py compile_catalog --locale ${GCUBE_LANG_NAME}
|
|
|
|
# INSTALL ONLY DURING INIT
|
|
#if [ $GCUBE_INIT_LANG -eq 0 ] ; then
|
|
# . /usr/lib/ckan/default/bin/activate
|
|
# cd "${CKAN_APP_DIR}/ckan"
|
|
# python setup.py compile_catalog --locale ${GCUBE_LANG_NAME}
|
|
#fi
|
|
}
|
|
|
|
# D4Science theme. Many changes
|
|
GCUBE_D4S_THEME_NAME=ckanext-d4science_theme
|
|
GCUBE_D4S_THEME_DIR=${CKAN_APP_DIR}/${GCUBE_D4S_THEME_NAME}
|
|
|
|
checkout_ckan_theme() {
|
|
echo -e "\n*** Checkout_ckan_theme called"
|
|
pushd ${GCUBE_D4S_THEME_DIR}
|
|
svn update --force >/dev/null 2>&1
|
|
}
|
|
|
|
# D4Science theme. rsync from CKAN CUSTOM TEMPLATE to CKAN DEFAULT TEMPLATE
|
|
GCUBE_D4S_CUSTOM_THEME_SRC=${CUSTOM_DIR}/${GCUBE_D4S_THEME_NAME}/ckanext/d4science_theme/
|
|
#GCUBE_D4S_CUSTOM_THEME_SRC=${CUSTOM_DIR}/${GCUBE_D4S_THEME_NAME}/ckanext/d4science_theme/
|
|
GCUBE_D4S_DEFAULT_THEME_DEST=${GCUBE_D4S_THEME_DIR}/ckanext/d4science_theme/
|
|
install_theme_customisations() {
|
|
echo -e "\n*** Install theme customisations called"
|
|
if [ -d "${GCUBE_D4S_CUSTOM_THEME_SRC}" ] ; then
|
|
echo "CUSTOM THEME EXISTS AT: " "${GCUBE_D4S_CUSTOM_THEME_SRC}"
|
|
if [ -d ${GCUBE_D4S_DEFAULT_THEME_DEST} ] ; then
|
|
echo "DEFAULT THEME EXISTS AT: " ${GCUBE_D4S_DEFAULT_THEME_DEST}
|
|
rsync -av "${GCUBE_D4S_CUSTOM_THEME_SRC}" ${GCUBE_D4S_DEFAULT_THEME_DEST}
|
|
else
|
|
echo "DEFAULT THEME DOES NOT EXIST AT: " ${GCUBE_D4S_DEFAULT_THEME_DEST}
|
|
fi
|
|
else
|
|
echo "CUSTOM THEME DOES NOT EXIST AT: " "${GCUBE_D4S_CUSTOM_THEME_SRC}"
|
|
fi
|
|
}
|
|
|
|
# privatedatasets (plugin)
|
|
GCUBE_D4S_SNIPPETS_PKG_DIR=plugins/privatedatasets
|
|
GCUBE_D4S_SNIPPETS_PKG_ITEM=${GCUBE_D4S_SNIPPETS_PKG_DIR}/package_item.html
|
|
SNIPPETS_PKG_ITEM_DEST=${CKAN_PYTHON_DIR}/ckanext/privatedatasets/templates/snippets/package_item.html
|
|
GCUBE_D4S_SNIPPETS_PY_FILES="plugin.py auth.py"
|
|
install_privatedatasets_customisations() {
|
|
echo -e "\n*** Install_privatedatasets_customisations called"
|
|
if [ -z "$1" ] ; then
|
|
GCUBE_D4S_SNIPPETS_PKG_ITEM=${GCUBE_D4S_SNIPPETS_PKG_DIR}/package_item.html
|
|
echo "No package_item file passed as parameter, using default: ${GCUBE_D4S_SNIPPETS_PKG_ITEM}"
|
|
else
|
|
GCUBE_D4S_SNIPPETS_PKG_ITEM=$1
|
|
echo "Target package_item file passed as parameter using it: ${GCUBE_D4S_SNIPPETS_PKG_ITEM}"
|
|
fi
|
|
|
|
if [ -d ${CKAN_PYTHON_DIR}/ckanext/privatedatasets ] ; then
|
|
if [ -f "${CUSTOM_DIR}/${GCUBE_D4S_SNIPPETS_PKG_ITEM}" ] ; then
|
|
cp -f "${CUSTOM_DIR}/${GCUBE_D4S_SNIPPETS_PKG_ITEM}" "${SNIPPETS_PKG_ITEM_DEST}"
|
|
echo "${CUSTOM_DIR}/${GCUBE_D4S_SNIPPETS_PKG_ITEM} copied to: ${SNIPPETS_PKG_ITEM_DEST}"
|
|
else
|
|
cp -f ${GLOBAL_DIR}/${GCUBE_D4S_SNIPPETS_PKG_ITEM} ${SNIPPETS_PKG_ITEM_DEST}
|
|
echo "${GLOBAL_DIR}/${GCUBE_D4S_SNIPPETS_PKG_ITEM} copied to: ${SNIPPETS_PKG_ITEM_DEST}"
|
|
fi
|
|
for pyfile in ${GCUBE_D4S_SNIPPETS_PY_FILES} ; do
|
|
if [ -f "${CUSTOM_DIR}/${GCUBE_D4S_SNIPPETS_PKG_DIR}/${pyfile}" ] ; then
|
|
cp -f "${CUSTOM_DIR}/${GCUBE_D4S_SNIPPETS_PKG_DIR}/${pyfile}" "${CKAN_PYTHON_DIR}/ckanext/privatedatasets/${pyfile}"
|
|
else
|
|
cp -f "${GLOBAL_DIR}/${GCUBE_D4S_SNIPPETS_PKG_DIR}/${pyfile}" "${CKAN_PYTHON_DIR}/ckanext/privatedatasets/${pyfile}"
|
|
fi
|
|
done
|
|
else
|
|
echo "install_privatedatasets_customisations: the directory ${CKAN_PYTHON_DIR}/ckanext/privatedatasets does not exist. Doing nothing"
|
|
fi
|
|
}
|
|
|
|
|
|
# privatedatasets (plugin), see #21867
|
|
# install privatedatasets customisations with open access to resources
|
|
# param $1: the ckan hostname where install
|
|
install_privatedatasets_customisations_with_open_access_to_resources() {
|
|
echo -e "\n*** Install_privatedatasets_customisations_with_open_access_to_resources called"
|
|
hs=`hostname`
|
|
echo "read hostname: ${hs}"
|
|
if [ -z "$1" ] ; then
|
|
echo "WARN: no ckan hostname as input parameters.. Doing nothing"
|
|
else
|
|
if [ "$1" = "$hs" ]; then
|
|
GCUBE_D4S_SNIPPETS_PKG_ITEM=${GCUBE_D4S_SNIPPETS_PKG_DIR}/package_item_open_access_to_resources.html
|
|
echo "The input parameter is matching the ckan hostname $1, going to install ${GCUBE_D4S_SNIPPETS_PKG_ITEM}"
|
|
install_privatedatasets_customisations "${GCUBE_D4S_SNIPPETS_PKG_ITEM}"
|
|
else
|
|
echo "WARN: the ckan hostname $1 does not matching with ${hs}. Doing nothing"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
|
|
# install_plugin_customisations
|
|
install_plugin_customisations() {
|
|
echo -e "\n*** Installing customisations for plugin: $1"
|
|
if [ -d "$1" ] ; then
|
|
if [ -d "$2" ] ; then
|
|
if [ -d "$3" ] ; then
|
|
echo "RSYNC FROM: $2 TO: $3"
|
|
rsync -av "$2" "$3"
|
|
else
|
|
echo "ERROR: the plugin destion directory does not exist at: $3"
|
|
fi
|
|
else
|
|
echo "ERROR: the plugin default directory does not exist at: $2"
|
|
fi
|
|
else
|
|
echo "WARNING: the directory $1 does not exist. Doing nothing"
|
|
fi
|
|
}
|
|
|
|
|
|
# make the input file executable
|
|
make_file_executable() {
|
|
if [ -f "$1" ]; then
|
|
echo "$1 exists making it executable"
|
|
chmod +x "$1"
|
|
fi
|
|
}
|
|
|
|
|
|
|
|
########## Main ##########
|
|
# The gcube license needs root. Do not use for the time being
|
|
#install_gcube_license
|
|
install_gcube_lang
|
|
checkout_ckan_theme
|
|
install_theme_customisations
|
|
install_privatedatasets_customisations
|
|
install_privatedatasets_customisations_with_open_access_to_resources "ckan-d-d4s"
|
|
install_privatedatasets_customisations_with_open_access_to_resources "ckan-openscience.int.d4science.net"
|
|
|
|
# ckanext-geonetwork
|
|
install_plugin_customisations "${CKAN_APP_DIR}/ckanext-geonetwork" "${GLOBAL_DIR}/plugins/ckanext-geonetwork/ckanext/geonetwork/" "${CKAN_APP_DIR}/ckanext-geonetwork/ckanext/geonetwork/"
|
|
|
|
# ckanext-googleanalytics
|
|
#install_plugin_customisations "${CKAN_APP_DIR}/ckanext-googleanalytics" "${GLOBAL_DIR}/plugins/ckanext-googleanalytics/ckanext/googleanalytics/" "${CKAN_APP_DIR}/ckanext-googleanalytics/ckanext/googleanalytics/"
|
|
|
|
# ckanext-harvest
|
|
install_plugin_customisations "${CKAN_APP_DIR}/ckanext-harvest" "${GLOBAL_DIR}/plugins/ckanext-harvest/ckanext/harvest/" "${CKAN_APP_DIR}/ckanext-harvest/ckanext/harvest/"
|
|
|
|
# ckanext-hierarchy
|
|
install_plugin_customisations "${CKAN_APP_DIR}/ckanext-hierarchy" "${GLOBAL_DIR}/plugins/ckanext-hierarchy/ckanext/hierarchy/" "${CKAN_APP_DIR}/ckanext-hierarchy/ckanext/hierarchy/"
|
|
|
|
# ckanext-oaipm
|
|
install_plugin_customisations "${CKAN_APP_DIR}/ckanext-oaipm" "${GLOBAL_DIR}/plugins/ckanext-oaipm/ckanext/oaipmh/" "${CKAN_APP_DIR}/ckanext-oaipm/ckanext/oaipmh/"
|
|
|
|
# ckanext-spatial
|
|
install_plugin_customisations "${CKAN_APP_DIR}/ckanext-spatial" "${GLOBAL_DIR}/plugins/ckanext-spatial/ckanext/spatial/" "${CKAN_APP_DIR}/ckanext-spatial/ckanext/spatial/"
|
|
|
|
# ckanext-dcat
|
|
install_plugin_customisations "${CKAN_APP_DIR}/ckanext-dcat" "${GLOBAL_DIR}/plugins/ckanext-dcat/ckanext/dcat/" "${CKAN_APP_DIR}/ckanext-dcat/ckanext/dcat/"
|
|
|
|
FILE="${CKAN_APP_DIR}/ckanext-dcat/ckanext/dcat/f2ds_harvester.py"
|
|
make_file_executable "$FILE"
|
|
FILE="${CKAN_APP_DIR}/ckanext-dcat/ckanext/dcat/f2ds_harvester_run.sh"
|
|
make_file_executable "$FILE"
|
|
|
|
|
|
|
|
# TESTING
|
|
# ckanext-spatial
|
|
#install_plugin_customisations "${CKAN_APP_DIR}/ckanext-spatial" "${GLOBAL_DIR}/plugins/ckanext-spatial/ckanext/spatial/" "/home/francesco-mangiacrapa/CKAN/ckanext-spatial/ckanext/spatial/"
|
|
# ckanext-hierarchy
|
|
#install_plugin_customisations "${CKAN_APP_DIR}/ckanext-hierarchy" "${GLOBAL_DIR}/plugins/ckanext-hierarchy/ckanext/hierarchy/" "/home/francesco-mangiacrapa/CKAN/ckanext-hierarchy/ckanext/hierarchy/"
|
|
# ckanext-googleanalytics
|
|
#install_plugin_customisations "${CKAN_APP_DIR}/ckanext-googleanalytics" "${GLOBAL_DIR}/plugins/ckanext-googleanalytics/ckanext/googleanalytics/" "/home/francesco-mangiacrapa/CKAN/ckanext-googleanalytics/ckanext/googleanalytics/"
|
|
|
|
#
|
|
echo "Finished installation of plugin customisations"
|
|
|
|
# Esegui il comando passato come argomento
|
|
# es. Avvia supervisord in foreground come: exec /usr/bin/supervisord -n
|
|
echo "\nExecuting the input command: "+$@
|
|
exec "$@" |