|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# +----------------------------------------------------------+ |
| 4 | +# | BASH : Modifying Shell Behaviour |
| 5 | +# | (https://www.gnu.org/software/bash/manual) |
| 6 | +# +----------------------------------------------------------+ |
| 7 | +# Treat unset variables and parameters other than the special |
| 8 | +# parameters ‘@’ or ‘*’ as an error when performing parameter |
| 9 | +# expansion. An error message will be written to the standard |
| 10 | +# error, and a non-interactive shell will exit. |
| 11 | +set -o nounset |
| 12 | + |
| 13 | +# Exit immediately if a pipeline returns a non-zero status. |
| 14 | +set -o errexit |
| 15 | + |
| 16 | +# If set, the return value of a pipeline is the value of the |
| 17 | +# last (rightmost) command to exit with a non-zero status, or |
| 18 | +# zero if all commands in the pipeline exit successfully. |
| 19 | +set -o pipefail |
| 20 | + |
| 21 | +if [[ $# -ne 1 ]]; then |
| 22 | + BUILD_TYPE="Debug" |
| 23 | +else |
| 24 | + BUILD_TYPE=$1 |
| 25 | +fi |
| 26 | + |
| 27 | +if [[ "$BUILD_TYPE" != "Release" && "$BUILD_TYPE" != "Debug" ]]; then |
| 28 | + echo "Invalid argument: $BUILD_TYPE" |
| 29 | + echo "Usage: $0 {Release|Debug}" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +if [[ -L /usr/local/bin/ocvsmd ]]; then |
| 34 | + unlink /usr/local/bin/ocvsmd |
| 35 | +fi |
| 36 | + |
| 37 | +if [[ -L /usr/local/bin/ocvsmd-cli ]]; then |
| 38 | + unlink /usr/local/bin/ocvsmd-cli |
| 39 | +fi |
| 40 | + |
| 41 | +if [[ -L /etc/init.d/ocvsmd ]]; then |
| 42 | + /etc/init.d/ocvsmd stop |
| 43 | + unlink /etc/init.d/ocvsmd |
| 44 | +fi |
| 45 | + |
| 46 | +if [[ -L /etc/ocvsmd/ocvsmd.toml ]]; then |
| 47 | + unlink /etc/ocvsmd/ocvsmd.toml |
| 48 | +fi |
| 49 | + |
| 50 | +ln -s /repo/build/bin/$BUILD_TYPE/ocvsmd /usr/local/bin/ocvsmd |
| 51 | +ln -s /repo/build/bin/$BUILD_TYPE/ocvsmd-cli /usr/local/bin/ocvsmd-cli |
| 52 | + |
| 53 | +ln -s /repo/init.d/ocvsmd /etc/init.d/ocvsmd |
| 54 | +chmod +x /etc/init.d/ocvsmd |
| 55 | +mkdir -p /etc/ocvsmd |
| 56 | +ln -s /repo/init.d/ocvsmd.toml /etc/ocvsmd/ocvsmd.toml |
| 57 | + |
| 58 | +/etc/init.d/ocvsmd start SPDLOG_LEVEL=trace SPDLOG_FLUSH_LEVEL=trace |
| 59 | + |
| 60 | +echo "Linked $BUILD_TYPE build artifacts to container's system. Use /etc/init.d/ocvsmd [start|stop|status|restart] to control daemon" |
| 61 | +echo "Starting log tail of /var/log/ocvsmd.log... " |
| 62 | + |
| 63 | +tail -f /var/log/ocvsmd.log |
0 commit comments