Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VR-demos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nomad-lab
VR-demos
Commits
0c92d9b2
Commit
0c92d9b2
authored
6 years ago
by
Ruben Jesus Garcia Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Fix string comparison
parent
ff82d8ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webserver/cgi-bin/NOMAD/material
+104
-104
104 additions, 104 deletions
webserver/cgi-bin/NOMAD/material
with
104 additions
and
104 deletions
webserver/cgi-bin/NOMAD/material
+
104
−
104
View file @
0c92d9b2
#!/bin/bash
# Copyright 2016-2018 Ruben Jesus Garcia Hernandez
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source ../../pass
if [[ "$QUERY_STRING"
-eq
"" ]]
then
#echo Location: /NOMAD/
echo Location:https://www.nomad-coe.eu/the-project/graphics/VR-prototype
echo ''
else
#rgh: text/plain works in pc but android chrome saves it as .txt, removing the extension
# export TOKEN=`cat t.b64`
export MAT=$QUERY_STRING
export RAND=$RANDOM
#rgh: before end of september 2017, use /var/tmp, after, use /tmp (apache update)
cd /tmp
/usr/bin/mkdir $RAND
cd $RAND
#pre 2018: http://encyclopedia-api.nomad-coe.eu/v1.0/saml/
#post 2018:
SAMLURL=https://encyclopedia.nomad-coe.eu/api/v1.0/saml/
wget --save-cookies cookies.txt \
--keep-session-cookies \
--no-check-certificate $SAMLURL -O login.html >/dev/null 2>
&
1
URL=`grep "form action" login.html |cut -f 2 -d \" |head -n 1`
wget --save-cookies cookies2.txt --keep-session-cookies --load-cookies cookies.txt --no-check-certificate \
"https://idp.nomad-coe.eu$URL
&
j_username=$USER
&
j_password=$PASS
&
_eventId_proceed" -O a.html >/dev/null 2>
&
1
URL=`grep "form action" a.html |cut -f 2 -d \" |head -n 1`
wget --save-cookies cookies3.txt --keep-session-cookies --load-cookies cookies2.txt --no-check-certificate \
"https://idp.nomad-coe.eu$URL
&
_shib_idp_consentOptions=_shib_idp_globalConsent
&
_eventId_proceed" \
-O b.html >/dev/null 2>
&
1
#now continue, as we don't support javascript :o)
URL2=`echo $URL |cut -f 1 -d \?`
DEST=`grep action b.html |cut -f 2 -d \"`
RELAY=`grep RelayState b.html |cut -f6 -d \"`
SAML=`grep SAMLResponse b.html |cut -f6 -d \"`
#rgh: since 25-09-2017, this line gives "invalid url" (possibly curl update)
#RELAY="https%3A%2F%2Fencyclopedia-api.nomad-coe.eu%2Fv1.0%2Fsaml%2F"
#pre-2018
#RELAY="https://encyclopedia-api.nomad-coe.eu/v1.0/saml/"
RELAY=$SAMLURL
#echo relay is $RELAY
MATERIALSURL=https://encyclopedia.nomad-coe.eu/api/v1.0/materials
curl -L -c cookies3.txt -X GET -F "RelayState=$RELAY" -F "SAMLResponse=$SAML" "$SAMLURL?acs" -o resp.json >/dev/null 2>
&
1
TOKEN=`grep data resp.json |cut -f 4 -d \"`
mkdir $MAT
cd $MAT
wget --no-check-certificate --user "$TOKEN" --password "" $MATERIALSURL/$MAT/cells?pagination=off -O material_cells.json >/dev/null 2>
&
1
wget --no-check-certificate --user "$TOKEN" --password "" $MATERIALSURL/$MAT/elements?pagination=off -O material_elements.json >/dev/null 2>
&
1
echo \# Material $QUERY_STRING >> $MAT.ncfg
echo background 0 0 0 >> $MAT.ncfg
echo atomscaling 0.5 >> $MAT.ncfg
echo json material >> $MAT.ncfg
echo displaybonds >> $MAT.ncfg
echo displayunitcell >> $MAT.ncfg
echo showcontrollers >> $MAT.ncfg
cd ..
if grep html $MAT/material_cells.json > /dev/null ; then
echo "CGI backend for NOMAD VR: Encyclopedia API issue. Material $MAT" |
mailx -s 'CGI backend for NOMAD VR: Encyclopedia API issue' $EMAIL
echo "Content-type: text/html"
echo ''
echo "
<html><head><title>
"
echo "VR backend currently being updated"
echo "
</title></head><body>
"
echo "VR backend currently being updated."
echo "Please
<a
href=
\"https://www.nomad-coe.eu/the-project/graphics/contact-2\"
>
contact us
</a>
if the problem persists."
echo "
</body></html>
"
else
zip -r $MAT $MAT >/dev/null 2>
&
1
echo "Content-type: application/octet-stream"
echo "Content-disposition: attachment; filename=${QUERY_STRING}.zip"
echo ''
cat $MAT.zip
fi
cd ..
\rm -r $RAND
fi
#!/bin/bash
# Copyright 2016-2018 Ruben Jesus Garcia Hernandez
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source ../../pass
if [[ "$QUERY_STRING"
=
"" ]]
then
#echo Location: /NOMAD/
echo Location:https://www.nomad-coe.eu/the-project/graphics/VR-prototype
echo ''
else
#rgh: text/plain works in pc but android chrome saves it as .txt, removing the extension
# export TOKEN=`cat t.b64`
export MAT=$QUERY_STRING
export RAND=$RANDOM
#rgh: before end of september 2017, use /var/tmp, after, use /tmp (apache update)
cd /tmp
/usr/bin/mkdir $RAND
cd $RAND
#pre 2018: http://encyclopedia-api.nomad-coe.eu/v1.0/saml/
#post 2018:
SAMLURL=https://encyclopedia.nomad-coe.eu/api/v1.0/saml/
wget --save-cookies cookies.txt \
--keep-session-cookies \
--no-check-certificate $SAMLURL -O login.html >/dev/null 2>
&
1
URL=`grep "form action" login.html |cut -f 2 -d \" |head -n 1`
wget --save-cookies cookies2.txt --keep-session-cookies --load-cookies cookies.txt --no-check-certificate \
"https://idp.nomad-coe.eu$URL
&
j_username=$USER
&
j_password=$PASS
&
_eventId_proceed" -O a.html >/dev/null 2>
&
1
URL=`grep "form action" a.html |cut -f 2 -d \" |head -n 1`
wget --save-cookies cookies3.txt --keep-session-cookies --load-cookies cookies2.txt --no-check-certificate \
"https://idp.nomad-coe.eu$URL
&
_shib_idp_consentOptions=_shib_idp_globalConsent
&
_eventId_proceed" \
-O b.html >/dev/null 2>
&
1
#now continue, as we don't support javascript :o)
URL2=`echo $URL |cut -f 1 -d \?`
DEST=`grep action b.html |cut -f 2 -d \"`
RELAY=`grep RelayState b.html |cut -f6 -d \"`
SAML=`grep SAMLResponse b.html |cut -f6 -d \"`
#rgh: since 25-09-2017, this line gives "invalid url" (possibly curl update)
#RELAY="https%3A%2F%2Fencyclopedia-api.nomad-coe.eu%2Fv1.0%2Fsaml%2F"
#pre-2018
#RELAY="https://encyclopedia-api.nomad-coe.eu/v1.0/saml/"
RELAY=$SAMLURL
#echo relay is $RELAY
MATERIALSURL=https://encyclopedia.nomad-coe.eu/api/v1.0/materials
curl -L -c cookies3.txt -X GET -F "RelayState=$RELAY" -F "SAMLResponse=$SAML" "$SAMLURL?acs" -o resp.json >/dev/null 2>
&
1
TOKEN=`grep data resp.json |cut -f 4 -d \"`
mkdir $MAT
cd $MAT
wget --no-check-certificate --user "$TOKEN" --password "" $MATERIALSURL/$MAT/cells?pagination=off -O material_cells.json >/dev/null 2>
&
1
wget --no-check-certificate --user "$TOKEN" --password "" $MATERIALSURL/$MAT/elements?pagination=off -O material_elements.json >/dev/null 2>
&
1
echo \# Material $QUERY_STRING >> $MAT.ncfg
echo background 0 0 0 >> $MAT.ncfg
echo atomscaling 0.5 >> $MAT.ncfg
echo json material >> $MAT.ncfg
echo displaybonds >> $MAT.ncfg
echo displayunitcell >> $MAT.ncfg
echo showcontrollers >> $MAT.ncfg
cd ..
if grep html $MAT/material_cells.json > /dev/null ; then
echo "CGI backend for NOMAD VR: Encyclopedia API issue. Material $MAT" |
mailx -s 'CGI backend for NOMAD VR: Encyclopedia API issue' $EMAIL
echo "Content-type: text/html"
echo ''
echo "
<html><head><title>
"
echo "VR backend currently being updated"
echo "
</title></head><body>
"
echo "VR backend currently being updated."
echo "Please
<a
href=
\"https://www.nomad-coe.eu/the-project/graphics/contact-2\"
>
contact us
</a>
if the problem persists."
echo "
</body></html>
"
else
zip -r $MAT $MAT >/dev/null 2>
&
1
echo "Content-type: application/octet-stream"
echo "Content-disposition: attachment; filename=${QUERY_STRING}.zip"
echo ''
cat $MAT.zip
fi
cd ..
\rm -r $RAND
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment