Skip to content

Instantly share code, notes, and snippets.

@dant3
Last active April 27, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dant3/887e00b3c26d0f49c1af to your computer and use it in GitHub Desktop.
Save dant3/887e00b3c26d0f49c1af to your computer and use it in GitHub Desktop.
Nexus
#!/bin/bash
# prerequisites
apt-get install openjdk-7-jdk
NEXUS_DIR=/opt/nexus
mkdir -p $NEXUS_DIR
curl -L http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz | tar -xzv --strip 1 -C $NEXUS_DIR
# profile settings
FILE=/etc/profile.d/nexus.sh
echo "export NEXUS_HOME=$NEXUS_DIR" > $FILE
. $FILE
# tune a linux service
USERNAME=nexus
useradd -r $USERNAME
usermod -L $USERNAME
usermod -d $NEXUS_DIR $USERNAME
mkdir -p $NEXUS_DIR/pid
mkdir -p $NEXUS_DIR/workspace
chown -R nexus:nexus $NEXUS_DIR
chmod -R ug+rx $NEXUS_DIR
chmod -R ug+w $NEXUS_DIR/pid
chmod -R ug+w $NEXUS_DIR/workspace
chmod -R ug+w $NEXUS_DIR/tmp
chmod -R ug+w $NEXUS_DIR/logs
mv $NEXUS_DIR/bin/nexus /etc/init.d/nexus
patch /etc/init.d/nexus nexus.patch
patch $NEXUS_DIR/conf/nexus.properties nexus.properties.patch
update-rc.d /etc/init.d/nexus defaults
service nexus start
# install nginx to listen to port 80
apt-get install nginx
cp nexus.host /etc/nginx/sites-available/nexus
ln -s /etc/nginx/sites-available/nexus /etc/nginx/sites-enabled/nexus
service nginx start
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
--- /opt/nexus/bin/nexus 2014-12-17 00:35:46.000000000 +0000
+++ /etc/init.d/nexus 2015-02-04 10:48:06.476918339 +0000
@@ -11,7 +11,7 @@
# These settings can be modified to fit the needs of your application
# Set this to the root of the Nexus installation
-NEXUS_HOME=".."
+NEXUS_HOME="/opt/nexus"
# If specified, the Wrapper will be run as the specified user.
@@ -20,7 +20,7 @@
# NOTE - This will set the user which is used to run the Wrapper as well as
# the JVM and is not useful in situations where a privileged resource or
# port needs to be allocated prior to the user being changed.
-#RUN_AS_USER=
+RUN_AS_USER="nexus"
# Application
APP_NAME="nexus"
@@ -31,7 +31,7 @@
PRIORITY=
# Location of the pid file.
-#PIDDIR="."
+PIDDIR="$NEXUS_HOME/pid"
# If uncommented, causes the Wrapper to be shutdown using an anchor file.
# When launched with the 'start' command, it will also ignore all INT and
@@ -549,4 +549,4 @@
;;
esac
-exit 0
\ No newline at end of file
+exit 0
--- /opt/nexus/conf/nexus.properties.orig 2015-02-04 14:20:02.149478002 +0000
+++ /opt/nexus/conf/nexus.properties 2015-02-04 14:48:50.161649939 +0000
@@ -19,8 +19,8 @@
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
-nexus-webapp-context-path=/nexus
+nexus-webapp-context-path=/
# Nexus section
-nexus-work=${bundleBasedir}/../sonatype-work/nexus
+nexus-work=${bundleBasedir}/workspace/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment