liuxunorg commented on a change in pull request #3313: [ZEPPELIN-4004] add a 
systemd unit file to launch the Zeppelin daemon via systemd commands
URL: https://github.com/apache/zeppelin/pull/3313#discussion_r265008164
 
 

 ##########
 File path: bin/zeppelin-systemd-service.sh
 ##########
 @@ -0,0 +1,101 @@
+#!/usr/bin/env 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.
+#
+# description: Enable/disable the Zeppelin systemd service.
+#
+
+# Directory in which the systemd unit files sit.
+SYSTEMD_DIR=/etc/systemd/system
+
+function enable_systemd_service()
+{
+    # Where are we in the fs?
+    OLD_PWD=$(pwd)
+
+    # Work out where the script is run from and cd into said directory.
+    cd "$(dirname "${BASH_SOURCE[0]}")"
+
+    # Work out the current directory.
+    MY_PWD=$(readlink -f .)
+
+    # Work out the Zeppelin source directory (go up a directory actually).
+    ZEPPELIN_DIR=$(dirname "${MY_PWD}")
+
+    # Copy the unit file.
+    cp "${ZEPPELIN_DIR}"/scripts/systemd/zeppelin.systemd "${SYSTEMD_DIR}"
+
+    # Swap the template variable with the right directory path.
+    sed -i -e "s#%ZEPPELIN_DIR%#${ZEPPELIN_DIR}#g;" \
+        "${SYSTEMD_DIR}"/zeppelin.systemd
+
+    # Set up the unit file.
+    systemctl daemon-reload
+    systemctl enable zeppelin.service
+
+    # Display a help message.
+    echo "To start Zeppelin using systemd, simply type:
+# systemctl start zeppelin
+
+To check the service health:
+# systemctl status zeppelin"
+
+    # Go back where we came from.
+    cd "${OLD_PWD}"
+}
+
+function disable_systemd_service()
+{
+    # Let's mop up.
+    systemctl stop zeppelin.service
+    systemctl disable zeppelin.service
+    rm "${SYSMTED_DIR}"/zeppelin.systemd
+    systemctl daemon-reload
+    systemctl reset-failed
+
+    # We're done. Explain what's just happened.
+    echo "Zeppelin systemd service has been disabled and removed from your 
system."
+}
+
+function check_user()
+{
+    # Are we root?
+    if [[ $(id -u) -ne 0 ]]; then
+        echo "Please run this script as root!"
+        exit -1
+    fi
+}
+
+USAGE="usage: zeppelin-systemd-service.sh {enable|disable}
+
+  enable:    enable Zeppelin systemd service.
+  disable:   disable Zeppelin systemd service.
+"
+
+# Main method starts from here downwards.
+check_user
+
 
 Review comment:
   check_operationSystem

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to