diff --git a/build.sh b/build.sh index 0f5a919..3675955 100755 --- a/build.sh +++ b/build.sh @@ -101,17 +101,13 @@ if [ $AUTO_INSTALL = true ]; then exit 1 fi else - read -p "Do you want to install the program? (y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - print_status "Installing dropshell..." - sudo make install - if [ $? -eq 0 ]; then - print_status "Installation successful!" - else - print_error "Installation failed!" - exit 1 - fi + print_status "Installing dropshell..." + sudo make install + if [ $? -eq 0 ]; then + print_status "Installation successful!" + else + print_error "Installation failed!" + exit 1 fi fi diff --git a/src/service_runner.cpp b/src/service_runner.cpp index 8229443..8346a35 100644 --- a/src/service_runner.cpp +++ b/src/service_runner.cpp @@ -63,7 +63,7 @@ bool service_runner::install(bool silent) { } // Check if rsync is installed on remote host - std::string check_rsync_cmd = "which rsync > /dev/null 2>&1"; + std::string check_rsync_cmd = "which rsync"; if (!execute_ssh_command(mServerEnv.get_SSH_INFO(), sCommand(check_rsync_cmd), cMode::Silent)) { std::cerr << "rsync is not installed on the remote host" << std::endl; diff --git a/src/utils/execute.cpp b/src/utils/execute.cpp index 8648695..5314517 100644 --- a/src/utils/execute.cpp +++ b/src/utils/execute.cpp @@ -127,7 +127,8 @@ bool execute_ssh_command(const sSSHInfo &ssh_info, const sCommand &command, cMod cmdstr = "bash -c " + halfquote(cmdstr); sCommand ssh_command(ssh_cmd.str() + " " + cmdstr); - bool rval = execute_local_command(ssh_command, mode, output); + cMode localmode = mode - cMode::Silent + cMode::RawCommand; + bool rval = execute_local_command(ssh_command, localmode, output); if (!rval) { std::cerr <&1 - else - # Run silently and return exit code - bash "${service_path}/template/${command}.sh" > /dev/null 2>&1 - fi - ) - CURRENT_EXIT_CODE=$? -} - -function command_exists() { - local service_path=$1 - local command=$2 - if [ ! -f "${service_path}/template/${command}.sh" ]; then - return 1 - fi - return 0 -} - -# Get all services on the server -SERVICES_PATH=$(realpath "${SCRIPT_DIR}/../../") - -# Get all service names -SERVICE_NAMES=$(ls "${SERVICES_PATH}") - -# Iterate over all service names -for SERVICE_NAME in ${SERVICE_NAMES}; do - - SERVICE_PATH=$(realpath "${SERVICES_PATH}/${SERVICE_NAME}") - - #-------------------------------- - # Get the service health - if ! command_exists "${SERVICE_PATH}" "status"; then - SERVICE_HEALTH="unknown" - else - run_command "${SERVICE_PATH}" "status" "false" - if [ "${CURRENT_EXIT_CODE}" -eq 0 ]; then - SERVICE_HEALTH="healthy" - else - SERVICE_HEALTH="unhealthy" - fi - fi - - #-------------------------------- - # Get the service ports - if ! command_exists "${SERVICE_PATH}" "ports"; then - SERVICE_PORTS="" - else - run_command "${SERVICE_PATH}" "ports" "true" - SERVICE_PORTS="${CURRENT_OUTPUT}" - fi - - #-------------------------------- - # return the health and ports - echo "${SERVICE_NAME}_HEALTH=${SERVICE_HEALTH}" - echo "${SERVICE_NAME}_PORTS=${SERVICE_PORTS}" -done