Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 1 | #! /bin/sh -e |
| 2 | |
| 3 | # ------------------------------------------------------------------------------ |
| 4 | # Copyright (c) 2021, Arm Limited, All Rights Reserved |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | # not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # ------------------------------------------------------------------------------ |
| 19 | |
| 20 | # Parsec Service SysV init script |
| 21 | |
| 22 | test -x /usr/libexec/parsec/parsec || exit 0 |
| 23 | |
| 24 | case "$1" in |
| 25 | start) |
| 26 | echo -n "Starting Parsec daemon: " |
| 27 | if [ ! -f /etc/parsec/config.toml ]; then |
| 28 | echo "There is no Parsec service configuration file." |
| 29 | else |
| 30 | if [ ! -d /run/parsec ]; then |
| 31 | mkdir /run/parsec |
| 32 | chown parsec:parsec /run/parsec |
| 33 | chmod 755 /run/parsec |
| 34 | fi |
| 35 | # start-stop-daemon used in poky busybox doesn't support |
| 36 | # '--chdir' parameter. So, let's do it manually |
| 37 | cd /var/lib/parsec |
| 38 | RUST_LOG=info start-stop-daemon --oknodo --start --background \ |
| 39 | --chuid parsec:parsec --exec /usr/libexec/parsec/parsec \ |
| 40 | -- --config /etc/parsec/config.toml |
| 41 | echo "parsec." |
| 42 | fi |
| 43 | ;; |
| 44 | stop) |
| 45 | echo -n "Stopping Parsec daemon: " |
| 46 | start-stop-daemon --oknodo --stop --exec /usr/libexec/parsec/parsec |
| 47 | echo "parsec." |
| 48 | ;; |
| 49 | reload) |
| 50 | echo -n "Reloading Parsec daemon: " |
| 51 | start-stop-daemon --stop --signal SIGHUP --exec /usr/libexec/parsec/parsec |
| 52 | echo "parsec." |
| 53 | ;; |
| 54 | restart|force-reload) |
| 55 | $0 stop |
| 56 | $0 start |
| 57 | ;; |
| 58 | *) |
| 59 | echo "Usage: /etc/init.d/parsec {start|stop|restart|reload|force-reload}" |
| 60 | exit 1 |
| 61 | esac |
| 62 | |
| 63 | exit 0 |