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
  • 3
    Deployment doesn't belong in the service startup script anyway. Move it somewhere more sensible. Commented Nov 17, 2016 at 17:09

1 Answer 1

2

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

3
  • thanks. i think i have to look for any other alternative system managers. any suggestion would be appreciated. Commented Nov 18, 2016 at 7:33
  • my suggestion is stick with systemd and use another tool for your install command. Commented Nov 18, 2016 at 15:30
  • I will use 2 systemd service for 2 command. It doesn't feel quite nice to me but will do the job. Thanks again. Commented Nov 22, 2016 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .