Skip to content

packaging: add pre-check.sh #11135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packaging/systemd/cloudstack-agent.service
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ After=libvirtd.service
[Service]
Type=simple
EnvironmentFile=/etc/default/cloudstack-agent
ExecStartPre=/usr/share/cloudstack-common/scripts/installer/pre-check.sh
ExecStart=/usr/bin/java $JAVA_OPTS $JAVA_DEBUG -cp $CLASSPATH $JAVA_CLASS
Restart=always
RestartSec=10s
Expand Down
1 change: 1 addition & 0 deletions packaging/systemd/cloudstack-management.service
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ User=cloud
EnvironmentFile=/etc/default/cloudstack-management
WorkingDirectory=/var/log/cloudstack/management
PIDFile=/var/run/cloudstack-management.pid
ExecStartPre=/usr/share/cloudstack-common/scripts/installer/pre-check.sh
ExecStart=/usr/bin/java $JAVA_DEBUG $JAVA_OPTS -cp $CLASSPATH $BOOTSTRAP_CLASS
StandardOutput=append:/var/log/cloudstack/management/management-server.out
StandardError=append:/var/log/cloudstack/management/management-server.err
Expand Down
1 change: 1 addition & 0 deletions packaging/systemd/cloudstack-usage.service
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ After=network.target network-online.target mariadb.service mysqld.service mysql.
Type=simple
EnvironmentFile=/etc/default/cloudstack-usage
Environment=JAVA_PID=$$
ExecStartPre=/usr/share/cloudstack-common/scripts/installer/pre-check.sh
ExecStart=/bin/sh -ec '/usr/bin/java -Dpid=${JAVA_PID} $JAVA_OPTS $JAVA_DEBUG -cp $CLASSPATH $JAVA_CLASS'
Restart=always
RestartSec=10s
Expand Down
38 changes: 38 additions & 0 deletions scripts/installer/pre-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

if [ ! -f "/usr/bin/java" ];then
echo "ERROR: /usr/bin/java does not exist"
exit 1
fi

JAVA_MAJOR_VERSION=$(/usr/bin/java --version | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1 |cut -d "." -f1)

if [ -z $JAVA_MAJOR_VERSION ];then
echo "WARNING: Cannot determine the JAVA version"
exit 0
fi

if [ "$JAVA_MAJOR_VERSION" != "17" ] && [ "$JAVA_MAJOR_VERSION" != "11" ];then
echo "ERROR: JAVA $JAVA_MAJOR_VERSION is not supported. Currently only JAVA 17 and JAVA 11 are supported."
exit 1
fi

if [ "$JAVA_MAJOR_VERSION" != "17" ];then
echo "WARNING: JAVA version is $JAVA_MAJOR_VERSION. JAVA 17 is recommended."
fi
Loading