Last active
September 27, 2023 04:09
-
-
Save krishnaglodha/cac737e05f3959348331cb4b0baf98b3 to your computer and use it in GitHub Desktop.
Install Geoserver and make service with single File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update system packages | |
sudo apt-get update | |
# Install Java Runtime Environment (JRE) | |
sudo apt-get install -y openjdk-11-jre | |
# Install Unzip | |
sudo apt install -y unzip | |
# Download and install GeoServer (adjust the version as needed) | |
GEOSERVER_VERSION="2.23.2" | |
INSTALLATION_PATH="/opt/geoserver" | |
wget -c https://sourceforge.net/projects/geoserver/files/GeoServer/$GEOSERVER_VERSION/geoserver-$GEOSERVER_VERSION-bin.zip | |
mkdir -p $INSTALLATION_PATH | |
unzip geoserver-$GEOSERVER_VERSION-bin.zip -d $INSTALLATION_PATH | |
rm geoserver-$GEOSERVER_VERSION-bin.zip | |
# Create GeoServer systemd service | |
cat <<EOF | sudo tee /etc/systemd/system/geoserver.service | |
[Unit] | |
Description=GeoServer Service | |
After=network.target | |
[Service] | |
Type=simple | |
User=root | |
Group=root | |
Environment="GEOSERVER_HOME=$INSTALLATION_PATH" | |
ExecStart=$INSTALLATION_PATH/bin/startup.sh | |
ExecStop=$INSTALLATION_PATH/bin/shutdown.sh | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
# Reload systemd to recognize the new service unit | |
sudo systemctl daemon-reload | |
# Enable and start the GeoServer service | |
sudo systemctl enable geoserver | |
sudo systemctl start geoserver | |
# Check GeoServer status | |
sudo systemctl status geoserver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment