Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
#!/bin/bash

export NUCLOS_URL=${1:-'http://localhost:80/nuclos'}
export NUCLOS_USER='nuclos'
export NUCLOS_PASSWORD=''

# directory where this script is stored
export DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# import all nuclets inside 'testnuclets'
NUCLETDIR="$DIR/nuclet"


echo "\n\nImporting nuclet ${NUCLETDIR}"

# Login
curl --fail --cookie-jar $DIR/cookies.txt $NUCLOS_URL/rest -X POST -H "Accept:application/json" -H "Content-Type: application/json" -d '{"username":"'$NUCLOS_USER'", "password":"'$NUCLOS_PASSWORD'"}'

# exit if curl was not successful
if [ $? -ne 0 ]; then
	echo "[ERROR] Login failed"
	exit 1
fi 

    
# zip nuclet
rm -f "nucletimport.nuclet"
cd ${NUCLETDIR}
zip -r ../nucletimport.nuclet .
cd ..

# send zipped nuclet to server
curl --fail --cookie $DIR/cookies.txt -F "file=@nucletimport.nuclet" -F "filename=nucletimport.nuclet" "$NUCLOS_URL/rest/maintenance/nucletimport"

# test if curl was successful
if [ $? == "0" ]
then
	echo "Import successful"
else
	echo "[ERROR] Import failed"
fi 

# Logout
curl -s --cookie cookies.txt -X DELETE $NUCLOS_URL/rest

...