| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) SAS Institute Inc. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | PATH=/usr/local/bin:$PATH |
| 19 | cfg=/etc/relic/relic.yml |
| 20 | sock=/run/relic/einhorn.sock |
| 21 | check() { |
| 22 | /usr/bin/relic -c $cfg serve --test || exit $? |
| 23 | } |
| 24 | case "$1" in |
| 25 | start) |
| 26 | check |
| 27 | exec einhorn \ |
| 28 | -c relic \ |
| 29 | -d $sock \ |
| 30 | -e /run/relic/einhorn.pid \ |
| 31 | -f /run/relic/einhorn.lock \ |
| 32 | -m manual \ |
| 33 | -q \ |
| 34 | -b 0.0.0.0:6300,r \ |
| 35 | -b 0.0.0.0:6301,r \ |
| 36 | -- \ |
| 37 | /usr/bin/relic -c $cfg serve |
| 38 | ;; |
| 39 | stop) |
| 40 | [ -e $sock ] || exit 0 |
| 41 | exec einhornsh -d $sock -e die |
| 42 | ;; |
| 43 | reload) |
| 44 | check |
| 45 | exec einhornsh -d $sock -e upgrade |
| 46 | ;; |
| 47 | reopenlogs) |
| 48 | [ -e $sock ] || exit 0 |
| 49 | exec einhornsh -d $sock -e "signal USR1" |
| 50 | ;; |
| 51 | *) |
| 52 | echo invalid command |
| 53 | exit 1 |
| 54 | esac |