#!/bin/bash # ------- # File: llxcfg-backend-server # Description: LliureX llxcfg-backend daemon script # Author: Luis Garcia Gisbert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- # load libs LIB_SOCKET1="/usr/share/lliurex/llxcfg-backend/llxcfg-backend-common.sh" [ -f "$LIB_SOCKET1" ] || exit 1 . $LIB_SOCKET1 LIB_SOCKET2="/usr/share/lliurex/llxcfg-backend/llxcfg-unix-sockets.sh" [ -f "$LIB_SOCKET2" ] || exit 1 . $LIB_SOCKET2 LLX_COMMONLIB="/usr/share/lliurex/llxcfg-common/llxcfg-common.sh" [ -f "${LLX_COMMONLIB}" ] || exit 1 . ${LLX_COMMONLIB} # server specific functions run_cmd(){ rc=0 if [ -x "${LBACK_CMD_DIR}/${GLOBAL_CMD}" ] ; then send_client_cmd "$CMD_ERROR" "(Backend: Command received. Running ... \"$GLOBAL_CMD\"" srv_run_external_cmd "${LBACK_CMD_DIR}/${GLOBAL_CMD}" "${GLOBAL_DATA[@]}" || rc=$? else send_client_cmd "$CMD_ERROR" "Server Error: Invalid command \"$GLOBAL_CMD\"" rc=${LBACK_INVALID_COMMAND} fi exit_cmd $rc return 0 } # generic superserver code ;-) # main read_client_LINE split_LINE || true run_cmd || rc=$? exit $rc