Skip to content

Instantly share code, notes, and snippets.

@mlabouardy
Created January 5, 2019 13:34
Show Gist options
  • Save mlabouardy/c4edff9687cde1491e34a1bbc8d29b59 to your computer and use it in GitHub Desktop.
Save mlabouardy/c4edff9687cde1491e34a1bbc8d29b59 to your computer and use it in GitHub Desktop.
Install Nexus on Centos
#!/bin/bash
NEXUS_USERNAME="admin"
NEXUS_PASSWORD="admin123"
echo "Install Java JDK 8"
yum update -y
yum install -y java-1.8.0-openjdk wget
echo "Install Nexus OSS"
mkdir /opt/nexus
cd /opt/nexus
wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
tar -xvf latest-unix.tar.gz
rm latest-unix.tar.gz
mv nexus-3.14.0-04 nexus
useradd nexus
chown -R nexus:nexus /opt/nexus/
ln -s /opt/nexus/nexus/bin/nexus /etc/init.d/nexus
cd /etc/init.d
chkconfig --add nexus
chkconfig --levels 345 nexus on
mv /tmp/nexus.rc /opt/nexus/nexus/bin/nexus.rc
service nexus restart
until $(curl --output /dev/null --silent --head --fail http://localhost:8081); do
printf '.'
sleep 2
done
echo "Upload Groovy Script"
curl -v -X POST -u $NEXUS_USERNAME:$NEXUS_PASSWORD --header "Content-Type: application/json" 'http://localhost:8081/service/rest/v1/script' -d @/tmp/repository.json
echo "Execute it"
curl -v -X POST -u $NEXUS_USERNAME:$NEXUS_PASSWORD --header "Content-Type: text/plain" 'http://localhost:8081/service/rest/v1/script/docker-repository/run'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment