Merge branch 'ryzom/rites' into main/gingo-test
[ryzomcore.git] / ryzom / server / tools / notify.sh
blob1279eb742031da4cd2f135fd2fa54a0fd6b2f573
1 #!/bin/bash
2 # ______ _____ _ _ _____ _
3 # | ___ \ / ___| | | | |_ _| | |
4 # | |_/ / _ _______ _ __ ___ \ `--.| |__ __ _ _ __ __| | | | ___ ___ | |___
5 # | / | | |_ / _ \| '_ ` _ \ `--. \ '_ \ / _` | '__/ _` | | |/ _ \ / _ \| / __|
6 # | |\ \ |_| |/ / (_) | | | | | | /\__/ / | | | (_| | | | (_| | | | (_) | (_) | \__ \
7 # \_| \_\__, /___\___/|_| |_| |_| \____/|_| |_|\__,_|_| \__,_| \_/\___/ \___/|_|___/
8 # __/ |
9 # |___/
11 # Ryzom - MMORPG Framework <https://ryzom.com/dev/>
12 # Copyright (C) 2019 Winch Gate Property Limited
13 # This program is free software: read https://ryzom.com/dev/copying.html for more details
15 # This script will notify external services like RocketChat or Web Apps
18 COMMAND=$1
20 CWD=$(dirname "$0")
21 . "$CWD/config.sh"
23 echo $COMMAND
24 if [[ "$COMMAND" == "ServiceStarted" ]]
25 then
26 if [[ ! -z "$NOTIFY_URL_SERVICE_RESTARTED" ]]
27 then
28 echo "Nofitiy $(hostname -s):$2 started"
29 curl "$NOTIFY_URL_SERVICE_RESTARTED?command=started&shard=$(hostname -s)&apikey=$NOTIFY_URL_KEY&service=$2" & 2> /dev/null
30 echo $COMMAND > $SHARD_PATH/states/$2.txt
32 elif [[ "$COMMAND" == "ServiceStarting" ]]
33 then
34 if [[ ! -z "$NOTIFY_URL_SERVICE_RESTARTED" ]]
35 then
36 echo "Nofitiy $(hostname -s):$2 starting"
37 curl "$NOTIFY_URL_SERVICE_RESTARTED?command=starting&shard=$(hostname -s)&apikey=$NOTIFY_URL_KEY&service=$2" & 2> /dev/null
38 echo $COMMAND > $SHARD_PATH/states/$2.txt
40 elif [[ "$COMMAND" == "ServiceStopped" ]]
41 then
42 if [[ ! -z "$NOTIFY_URL_SERVICE_RESTARTED" ]]
43 then
44 echo "Nofitiy $(hostname -s):$2 stopped"
45 curl "$NOTIFY_URL_SERVICE_RESTARTED?command=stopped&shard=$(hostname -s)&apikey=$NOTIFY_URL_KEY&service=$2" & 2> /dev/null
46 echo $COMMAND > $SHARD_PATH/states/$2.txt
48 elif [[ "$COMMAND" == "ShardStopped" ]]
49 then
50 if [[ ! -z "$NOTIFY_URL_SERVICE_RESTARTED" ]]
51 then
52 echo "Nofitiy $(hostname -s):$2 shard stopped"
53 curl "$NOTIFY_URL_SERVICE_RESTARTED?command=shard_stopped&shard=$(hostname -s)&apikey=$NOTIFY_URL_KEY" & 2> /dev/null
54 echo $COMMAND > $SHARD_PATH/states/shard.txt
56 elif [[ "$COMMAND" == "ShardStarted" ]]
57 then
58 if [[ ! -z "$NOTIFY_URL_SERVICE_RESTARTED" ]]
59 then
60 echo "Nofitiy $(hostname -s):$2 shard started"
61 curl "$NOTIFY_URL_SERVICE_RESTARTED?command=shard_started&shard=$(hostname -s)&apikey=$NOTIFY_URL_KEY" & 2> /dev/null
62 echo $COMMAND > $SHARD_PATH/states/shard.txt
64 elif [[ "$COMMAND" == "ShardStarting" ]]
65 then
66 if [[ ! -z "$NOTIFY_URL_SERVICE_RESTARTED" ]]
67 then
68 echo "Nofitiy $(hostname -s):$2 shard starting"
69 curl "$NOTIFY_URL_SERVICE_RESTARTED?command=shard_starting&shard=$(hostname -s)&apikey=$NOTIFY_URL_KEY" & 2> /dev/null
70 echo $COMMAND > $SHARD_PATH/states/shard.txt
74 sleep 1