From 01c6041999c2723d30c226de6298dd4cf59af9d6 Mon Sep 17 00:00:00 2001 From: "Hatter Jiang@Pixelbook" Date: Thu, 15 Oct 2020 08:30:46 +0800 Subject: [PATCH] chore: mv services --- install-service.sh | 97 --------------------------------------------- keeprunning-service | 86 ---------------------------------------- keeprunning.service | 11 ----- 3 files changed, 194 deletions(-) delete mode 100644 install-service.sh delete mode 100644 keeprunning-service delete mode 100644 keeprunning.service diff --git a/install-service.sh b/install-service.sh deleted file mode 100644 index b6def5d..0000000 --- a/install-service.sh +++ /dev/null @@ -1,97 +0,0 @@ -#! /bin/bash - -export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin - -install_path=/keeprunning-service/ -service_name='keeprunning-service' - -# Make sure only root can run our script -function rootness(){ - if [[ $EUID -ne 0 ]]; then - echo "Error:This script must be run as root!" 1>&2 - exit 1 - fi -} - -function checkenv(){ - if [[ $OS = "centos" ]]; then - echo "Environment: CentOS" - #yum install -y java - else - echo "Environment: Debian or Ubuntu" - #apt-get install -y openjdk-7-jre - fi -} - -function checkos(){ - if [ -f /etc/redhat-release ];then - OS='centos' - elif [ ! -z "`cat /etc/issue | grep bian`" ];then - OS='debian' - elif [ ! -z "`cat /etc/issue | grep Ubuntu`" ];then - OS='ubuntu' - else - echo "Not support OS, Only supports CentOS, Debian and Ubuntu!" 1>&2 - exit 1 - fi -} - -# Install service -function install_service(){ - rootness - checkos - checkenv - mkdir -p $install_path - cp sample-service-jar.jar $install_path - cp install-service.sh $install_path - cp $service_name /etc/init.d/ - if [ "$OS" == 'centos' ]; then - chmod +x /etc/init.d/$service_name - chkconfig --add $service_name - chkconfig $service_name on - else - chmod +x /etc/init.d/$service_name - update-rc.d -f $service_name defaults - fi - #/etc/init.d/$service_name start -} - -# Uninstall service -function uninstall_service(){ - printf "Are you sure uninstall $service_name? (y/n) " - printf "\n" - read -p "(Default: n):" answer - if [ -z $answer ]; then - answer="n" - fi - if [ "$answer" = "y" ]; then - /etc/init.d/$service_name stop - checkos - if [ "$OS" == 'centos' ]; then - chkconfig --del $service_name - else - update-rc.d -f $service_name remove - fi - rm -f /etc/init.d/$service_name - rm -rf $install_path - echo "$service_name uninstall success!" - else - echo "uninstall cancelled, Nothing to do" - fi -} - -# Initialization step -action=$1 -[ -z $1 ] && action=install -case "$action" in -install) - install_service - ;; -uninstall) - uninstall_service - ;; -*) - echo "Arguments error! [${action} ]" - echo "Usage: `basename $0` {install|uninstall}" - ;; -esac diff --git a/keeprunning-service b/keeprunning-service deleted file mode 100644 index 12ddc4f..0000000 --- a/keeprunning-service +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# chkconfig: 2345 90 10 -# description: start or stop the keeprunning-service server -# -### BEGIN INIT INFO -# Provides: keeprunning-service -# Required-Start: $network $syslog $local_fs $remote_fs -# Required-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Description: Start or stop the keeprunning-service server -### END INIT INFO - -# Author: hatter - -export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin - -name=keeprunning-service -install_path=/keeprunning-service/ -fnname=keeprunningd -logname=${install_path}service.log - -[[ -s "/java-env-init.sh" ]] && source "/java-env-init.sh" -[[ -s "${install_path}env-init.sh" ]] && source "${install_path}env-init.sh" - -start(){ - ulimit -s 65535 - ulimit -n 65535 - $install_path$fnname > $logname 2>&1 & - RETVAL=$? - if [ "$RETVAL" = "0" ]; then - echo "$name start success" - else - echo "$name start failed" - fi -} - -stop(){ - pid=`ps -ef | grep $fnname | grep -v grep | awk '{print $2}'` - if [[ ! -z $pid ]]; then - ps -ef | grep $fnname | grep -v grep | awk '{print $2}' | xargs kill -s 9 - RETVAL=$? - if [ "$RETVAL" = "0" ]; then - echo "$name stop success" - else - echo "$name stop failed" - fi - else - echo "$name is not running" - RETVAL=1 - fi -} - -status(){ - pid=`ps -ef | grep $fnname | grep -v grep | awk '{print $2}'` - if [[ -z $pid ]]; then - echo "$name is not running" - RETVAL=1 - else - echo "$name is running with PID $pid" - RETVAL=0 - fi -} - -case "$1" in -'start') - stop - start - ;; -'stop') - stop - ;; -'status') - status - ;; -'restart') - stop - start - RETVAL=$? - ;; -*) - echo "Usage: $0 { start | stop | restart | status }" - RETVAL=1 - ;; -esac -exit $RETVAL \ No newline at end of file diff --git a/keeprunning.service b/keeprunning.service deleted file mode 100644 index 90f77e1..0000000 --- a/keeprunning.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=keeprunningd -After=network-online.target -[Service] -Type=simple -ExecStart=/usr/sbin/keeprunningd -KillMode=process -Restart=on-failure -RestartSec=1min -[Install] -WantedBy=multi-user.target \ No newline at end of file