Commit c9688e6c authored by PENGUEN Julien's avatar PENGUEN Julien
Browse files

Initial commit

parents
Pipeline #868 failed with stages
#config file
#########################
# PHOTOS_MONTAGE_ALADIN #
#########################
CONF_REPO_PHOTOS_MONTAGE_ALADIN=conf-montage
IMAGE_PHOTOS_MONTAGE_ALADIN=image_photos_montage_aladin
CONTAINER_NAME_PHOTOS_MONTAGE_ALADIN=photos_montage_aladin
ALADIN_VERSION=?
###########
# VARIOUS #
###########
ALADIN_URL='https://aladin.u-strasbg.fr/java'
OUTPUT_DIRECTORY=./.temp
SCRIPT_VERSION=0.1
photos_montage_aladin
======================
# Authors
CeSAM (Centre de donnéeS Astrophysique de Marseille) at LAM (Laboratoire d'Astrophysique de Marseille)
# About photos_montage_aladin:
# Requirements
# Installation
# How to use photos_montage_aladin
FROM ubuntu:16.04
FROM java:8
ARG uidval
ARG username
ARG home
ARG aladin_version
RUN mkdir /var/aladin
RUN useradd -r -u ${uidval} -d $home ${username}
USER ${username}
WORKDIR ${home}
ADD Aladin-${aladin_version}.jar /var/aladin/
#!/bin/sh
. ./.env
#---------------------------#
#-------- functions --------#
#---------------------------#
fonction_get_rtrn()
{
# fonction_get_rtrn: get return result part
# params:
# $1 - return result string
# $2 - number of part to be returned
# returns:
# return result part
echo `echo $1|cut --delimiter=, -f $2`
}
function_jar_updated_search()
{
# function_jar_updated_search: get the last jar version
# returns:
# return number_version
version=$(curl -s ${ALADIN_URL}"/nph-aladin.pl?frame=downloading" | sed '/Official version/!d' | cut -d">" -f3)
number_version=$(echo ${version:1})
echo "$number_version"
}
function_build_image()
{
# function_build_image: build the photos_montage_aladin image
version=$1
curl -s ${ALADIN_URL}"/nph-aladin.pl?frame=downloading" | sed '/Official version/!d' | cut -d">" -f3 | sed 's/v//' > .temp
curl -s ${ALADIN_URL}"/nph-aladin.pl?frame=downloading" | sed '/<!--/d'| sed '/last/!d' | cut -d">" -f3 | cut -d"<" -f1 | sed 's/\.jar//' | sed 's/Aladin//' >> .temp
list_jar=$(sort -r .temp | awk '{print $1}')
rm .temp
present=$(echo $list_jar| grep $version)
if [ $? -eq 1 ]; then
echo ''
echo '------------------------------------'
echo ''
echo "You must select an existing version"
echo " available on "
echo " https://aladin.u-strasbg.fr "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
exit 0
else
echo ''
echo "- Searching for the current photos_montage_aladin-${version} docker image ..."
id_image=$(sudo docker inspect --format="{{.Id}}" ${IMAGE_PHOTOS_MONTAGE_ALADIN}-${version})
if [ ${id_image} ]; then
echo "=> The photos_montage_aladin-${version} docker image already exist"
echo ''
else
#echo "valeur aladin_last_number_version=${aladin_last_number_version}"
#----------------------------------------#
if [ ${aladin_last_number_version} == ${version} ]; then
wget -o .logfile -P ${CONF_REPO_PHOTOS_MONTAGE_ALADIN} ${ALADIN_URL}/Aladin.jar
mv ${CONF_REPO_PHOTOS_MONTAGE_ALADIN}/Aladin.jar ${CONF_REPO_PHOTOS_MONTAGE_ALADIN}/Aladin-${version}.jar
else
wget -o .logfile -P ${CONF_REPO_PHOTOS_MONTAGE_ALADIN} ${ALADIN_URL}/Aladin-${version}.jar
fi
#-----------------#
#build
echo "- Creating the photos_montage_aladin-${version} docker image in progress ..."
echo '------------------------------------------------------------------'
sudo docker build --build-arg username=$USER --build-arg uidval=$UID --build-arg home=$HOME --build-arg aladin_version=${version} -t ${IMAGE_PHOTOS_MONTAGE_ALADIN}-${version} ${CONF_REPO_PHOTOS_MONTAGE_ALADIN}
echo "=> creating the photos_montage_aladin-${version} docker image successfully"
echo '------------------------------------------------------------------'
echo ''
#-----------------#
rm ${CONF_REPO_PHOTOS_MONTAGE_ALADIN}/Aladin-${version}.jar
rm .logfile
fi
fi
}
function_create_ajs_file()
{
# function_create_ajs_file : create ajs surveys file
# while read line
# do
# echo -e "$line"
# done < surveys.dat
inputfile=$1
outputfile=$2
list_survey=$(awk '{print $1}' $inputfile)
echo -e "reset" > ${outputfile}
number=0;
for survey in ${list_survey}
do
i=0;
((number++));
echo -e "$survey"
echo -e "#" >> ${outputfile}
echo -e "rm @1" >> ${outputfile}
echo -e "get HiPS($survey) \$2 10'" >> ${outputfile}
echo -e "cm BB localcut" >> ${outputfile}
for val in `echo $survey | tr "/" " "`;
do
((i++));
tab[$i]=${val}
#echo "tab[$i]=${tab[$i]}"
done
# if [ ${number} -eq 0 ]; then
# old_val_tab3=${tab[3]}
# ((number++));
# fi
#
# if [ ${tab[3]} != ${old_val_tab3} ]; then
# ((number++));
# old_val_tab3=${tab[3]}
# fi
echo "Nb element :${i}"
chaine="${number}_\$1-${tab[$i-1]}_${tab[$i]}.jpg"
echo $chaine
echo -e "save 200x200 ./\$1/$chaine" >> ${outputfile}
done
}
#-----------------------------------------#
#----------- main program ----------------#
#-----------------------------------------#
# function_create_ajs_file "surveys.dat" "test.ajs"
#function_jar_updated_search
case $1 in
""|"--select")
###################################
# use: ./photos_montage_aladin.sh #
###################################
# ------------------------------------------ #
version_init=$(cat .env | grep ALADIN_VERSION)
if [ ${version_init} == "ALADIN_VERSION=?" ]; then
init='TRUE'
echo "INITIALISATION VERSION"
#------------------------------------------#
#call function function_jar_updated_search
aladin_last_number_version=`function_jar_updated_search`
echo "aladin_last_number_version=$aladin_last_number_version"
#----------------------------------------#
sed -i "s/ALADIN_VERSION=?/ALADIN_VERSION=${aladin_last_number_version}/" .env
else
init='FALSE'
fi
# ---------------------------------------- #
if [ ${init} == TRUE ]; then
version=${aladin_last_number_version}
else
if [ "$1" == "--select" ]; then
# --------------- #
curl -s ${ALADIN_URL}"/nph-aladin.pl?frame=downloading" | sed '/Official version/!d' | cut -d">" -f3 | sed 's/v//' > .temp
curl -s ${ALADIN_URL}"/nph-aladin.pl?frame=downloading" | sed '/<!--/d'| sed '/last/!d' | cut -d">" -f3 | cut -d"<" -f1 | sed 's/\.jar//' | sed 's/Aladin//' >> .temp
list_jar=$(sort -r .temp | awk '{print $1}')
rm .temp
present=$(echo $list_jar| grep $2)
if [ $? -eq 1 ]; then
echo ''
echo '------------------------------------'
echo ''
echo "You must select an existing version"
echo " available on "
echo " https://aladin.u-strasbg.fr "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
exit 0
else
version=$2
fi
# --------------- #
else
version=${ALADIN_VERSION}
fi
fi
echo ''
echo '------------------------------------'
echo ' Photos Montage Aladin '
echo ''
echo '- aladin version: ' ${version}
#----------------------------------------#
#call function function_jar_updated_search
aladin_last_number_version=`function_jar_updated_search`
#----------------------------------------#
if [ ${aladin_last_number_version} != ${version} ]; then
echo ''
echo '========================================'
echo ' YOU ARE NOT USING THE LAST '
echo ' ALADIN VERSION '
echo '========================================'
echo ''
echo '=> A new ALADIN version is available:' ${aladin_last_number_version}
echo ''
echo 'COMMAND TO UPDATE ALADIN VERSION:'
echo ''
echo '=> ./photos_montage_aladin.sh -u OR --update'
echo '------------------------------------'
echo ''
echo ''
sleep 5
else
#case no update
echo ''
echo '------------------------------------'
echo ''
fi
#----------------------------------------#
#call function function_build_image
# function_build_image
if [ ${version} == ${ALADIN_VERSION} ]; then
echo "ICI ALADIN_VERSION=${ALADIN_VERSION}"
function_build_image ${ALADIN_VERSION}
else
echo "ICI2 ALADIN_VERSION=$version"
function_build_image $version
fi
#------------------------#
echo "- Container construction and launch of ${CONTAINER_NAME_PHOTOS_MONTAGE_ALADIN} in progress ... "
xhost +
sudo docker run --name ${CONTAINER_NAME_PHOTOS_MONTAGE_ALADIN} --rm -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME:$HOME --network host -e DISPLAY=$DISPLAY -e USER=$USER -e HOME=$HOME ${IMAGE_PHOTOS_MONTAGE_ALADIN}-${version} java -jar /var/aladin/Aladin-${version}.jar
xhost -
#------------------------#
echo "=> End of photos_montage_aladin program"
echo ""
;;
"-b"|"--build")
#################################
# use: ./photos_montage_aladin.sh -b OR --build #
#################################
;;
"-u"|"--update")
###################################
# use: ./photos_montage_aladin.sh -u OR --update #
###################################
;;
"-i"|"--infos")
#################################
# use: ./photos_montage_aladin.sh -i OR --infos #
#################################
;;
"-v"|"--version")
#####################################
# use: ./photos_montage_aladin.sh -v OR --version #
#####################################
echo '- photos_montage_aladin.sh version: ' ${SCRIPT_VERSION}
#---------------------------------#
;;
"-rm"|"--remove=")
###################################
# use: ./photos_montage_aladin.sh -rm OR --remove #
###################################
;;
"-h"|"--help")
#################################
# use: ./photos_montage_aladin.sh -h OR --help #
#################################
echo ""
echo "========"
echo "= HELP ="
echo "========"
echo ""
echo "use : ./photos_montage_aladin.sh [options]"
echo ""
echo ""
echo "OPTIONS:"
echo ""
echo "-i, --infos give informations about versions available on cesam server"
echo " and give informations about photos_montage_aladin image present on localhost"
echo "-b version, --build version build photos_montage_aladin image with selected version"
echo "--select version run photos_montage_aladin with selected version number"
echo "-u, --update update photos_montage_aladin image version"
echo "-rm version, --remove version remove photos_montage_aladin image with selected version"
echo "-h, --help show this help message and exit"
echo "-v, --version give photos_montage_aladin.sh current version number"
echo ""
echo "====================="
echo ""
;;
*)
##################################
# use: ./photos_montage_aladin.sh OTHER COMMAND #
##################################
echo ""
echo "==============================="
echo " error: unrecognized arguments "
echo "==============================="
echo ""
echo "use : ./photos_montage_aladin.sh [options]"
echo ""
echo ""
echo "OPTIONS:"
echo ""
echo "-i, --infos give informations about versions available on cesam server"
echo " and give informations about photos_montage_aladin image present on localhost"
echo "-b version, --build version build photos_montage_aladin image with selected version"
echo "--select version run photos_montage_aladin with selected version number"
echo "-u, --update update photos_montage_aladin image version"
echo "-rm version, --remove version remove photos_montage_aladin image with selected version"
echo "-h, --help show this help message and exit"
echo "-v, --version give photos_montage_aladin.sh current version number"
echo ""
echo "====================="
echo ""
;;
esac
#-----------------------------------------#
#-----------------------------------------#
#-----------------------------------------#
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