#!/bin/bash

### BEGIN INIT INFO
# Provides:             update-server
# Required-Start:
# Required-Stop:
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    update-server
# Description:          waiting to bind or unbind usb
#
### END INIT INFO

PATH="$PATH:/usr/bin:/bin"

. /lib/lsb/init-functions

case "$1" in
        start)
                log_action_begin_msg "Starting update-server"
                su root -c "export HOME=${HOME}; cd /opt/apps/kylincloud-remoteappclient; /usr/bin/python3 update_client.py &"
        ;;

        stop)
                log_action_begin_msg "Stopping update-server"
                /bin/kill -9 `ps aux |grep sever.py |grep -v grep |awk '{print $2}'`
        ;;

        restart)
                $0 stop
                $0 start
        ;;

        *)
                echo "Usage: /etc/init.d/update-server (start|stop|restart)"
                exit 1
        ;;
esac

exit 0
