#!/bin/bash

help_info(){
  echo "notify.sh -n {master|backup|fault}"
}

stop_service(){
  echo "stop service"
  systemctl stop nginx
  systemctl stop lico-confluent-proxy
  systemctl stop lico-file-manager
  systemctl stop lico-async-task
  systemctl stop lico
  systemctl stop telegraf
  systemctl stop confluent
  systemctl stop redis
  systemctl stop influxdb
  systemctl stop mariadb
  systemctl stop slapd
}

start_service(){
  echo "start service"
  sleep 120
  systemctl restart slapd
  systemctl restart mariadb
  systemctl restart influxdb
  systemctl restart redis
  systemctl restart confluent
  systemctl restart telegraf
  systemctl restart lico
  systemctl restart lico-async-task
  systemctl restart lico-file-manager
  systemctl restart lico-confluent-proxy
  systemctl restart nginx
}

if [ $# -lt 2 ]
then
  help_info
  exit 0
fi



if [ $2 == "master" ]; then
    start_service
    exit 0
elif [ $2 == "backup" ]; then
    stop_service
    exit 0
elif [ $2 == "fault" ]; then
    stop_service
    exit 0
else
    help_info
fi

