0

I have an init script as you see below

#!/bin/bash
# description: connect start | stop | restart | install
# processname: tomcat
# chkconfig: 234 99 01
JAVA_HOME=/
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/
ulimit -v unlimited -m..
LOG_COPY_FOLDER=$(date +"%Y-%m-%d_%H%M")

case $1 in
start)
JAVA_OPTS='-Xms160g -Xmx160g -XX:+ResetSignal_MaskAtLaunch -Xloggc:/tom....'
    export JAVA_OPTS
    echo "Using JAVA_OPTS:       $JAVA_OPTS"
find $CATALINA_HOME/logs_prev/* -type d -ctime +180 | xargs rm -rf
mv $CATALINA_HOME/logs $CATALINA_HOME/logs_prev/$LOG_COPY_FOLDER
    mkdir $CATALINA_HOME/logs
    nohup sh $CATALINA_HOME/bin/startup.sh
  less $CATALINA_HOME/logs/catalina.out
;;
stop)
    sh $CATALINA_HOME/bin/shutdown.sh
;;
install)
MySQLConfirmation() {
    while :
    do
        read -p 'Have you run MySQL commands? (y/n): ' answer
            case "${answer}" in
                    y|Y|yes|Yes) exit 0 ;;
                    n|N|no|No) exit 1 ;;
            esac
    done
}

if $( MySQLConfirmation ); then
        JAVA_OPTS='-Xms160g -Xmx160g -XX:+ResetSignalMaskAtLaunch -Xloggc:/tom...
        export JAVA_OPTS
        echo "Using JAVA_OPTS:       $JAVA_OPTS"
    find $CATALINA_HOME/logs_prev/* -type d -ctime +30 | xargs rm -rf
    mv $CATALINA_HOME/logs $CATALINA_HOME/logs_prev/$LOG_COPY_FOLDER
        **rm -R $CATALINA_HOME/website.com/ROOT**
        mkdir $CATALINA_HOME/logs
        **mv -f /root/website.war $CATALINA_HOME/websitcom/ROOT.war**
        nohup sh $CATALINA_HOME/bin/startup.sh
        less $CATALINA_HOME/logs/catalina.out
else
            echo "See you when you're done with MySQL updates!"
    fi
;;
esac
exit 0

As you see i have start stop restart and install processes. And install process is requires remove and mkdir commands which i don't know how to implement on systemd process because i cannot see a way to add a process to be able to run like 'systemctl qinstall service' Is there a way to add Execinstall and ExecinstallPre arguments to systemd? Thanks

1 Answers1

2

systemd does not support custom action names like install, it focuses on process management.

Mark Stosberg
  • 3,771
  • 23
  • 27