Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,38 +159,31 @@ process_ksm_config() {
# DEVICE SETUP AND AUTHENTICATION FUNCTIONS
# =============================================================================

# Setup device registration and persistent login
# Setup device registration and persistent login.
# All three steps run in a single Commander process so login + vault sync
# only happens once instead of three times.
setup_device() {
local user="$1"
local password="$2"
local server="$3"

# Step 1: Register device
log "Registering device..."
if ! python3 keeper.py --user "${user}" --password "${password}" \
--server "${server}" this-device register; then
log "ERROR: Device registration failed"
exit 1
fi

# Step 2: Enable persistent login
log "Enabling persistent login..."
if ! python3 keeper.py --user "${user}" --password "${password}" \
--server "${server}" this-device persistent-login on; then
log "ERROR: Persistent login setup failed"
exit 1
fi

# Step 3: Set timeout
log "Setting device logout timeout to 30 Days..."
log "Running device setup (register, persistent login, timeout)..."
local setup_script
setup_script=$(mktemp /tmp/keeper_setup_XXXXXX.cmd)
cat > "${setup_script}" <<CMDS
this-device register
this-device persistent-login on
this-device timeout ${DEVICE_TIMEOUT}
CMDS

if ! python3 keeper.py --user "${user}" --password "${password}" \
--server "${server}" this-device timeout "${DEVICE_TIMEOUT}" \
> /dev/null; then
log "ERROR: Timeout setup failed"
--server "${server}" "${setup_script}"; then
log "ERROR: Device setup failed"
rm -f "${setup_script}"
exit 1
fi
log "Device Logout Timeout set successfully"

rm -f "${setup_script}"
log "Device setup completed successfully"
}

Expand Down
5 changes: 4 additions & 1 deletion keepercommander/service/commands/handle_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ def execute(self, params: KeeperParams, **kwargs) -> None:

class ServiceStatus(Command):
"""Command to get service status."""

skip_sync_on_auth = True

@debug_decorator
def get_parser(self):
parser = argparse.ArgumentParser(prog='service-status', parents=[report_output_parser], description='Displays if the Commander API service is running or stopped')
return parser

def execute(self, params: KeeperParams, **kwargs) -> str:
status = ServiceManager.get_status()
print(f"Current status: {status}")
4 changes: 3 additions & 1 deletion keepercommander/service/docker/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Output formatting utilities for Docker setup commands.
"""

import shlex

from ...display import bcolors
from .models import SetupResult

Expand Down Expand Up @@ -68,7 +70,7 @@ def print_common_deployment_steps(port: str, config_path: str = None) -> None:

config_file = config_path if config_path else '~/.keeper/config.json'
print(f"\n{bcolors.BOLD}Step 2: Delete the local config.json file{bcolors.ENDC}")
print(f" {bcolors.OKGREEN}rm {config_file}{bcolors.ENDC}")
print(f" {bcolors.OKGREEN}rm {shlex.quote(config_file)}{bcolors.ENDC}")
print(f" Why? Prevents device token conflicts - Docker will download its own config.")

print(f"\n{bcolors.BOLD}Step 3: Review docker-compose.yml{bcolors.ENDC}")
Expand Down
4 changes: 4 additions & 0 deletions unit-tests/service/test_service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def test_service_status_when_not_running(self):
status_cmd.execute(self.params)
mock_print.assert_called_with("Current status: No Commander Service is running currently")

def test_service_status_skips_sync_on_auth(self):
"""service-status still requires login but must not trigger a full vault sync."""
self.assertTrue(ServiceStatus.skip_sync_on_auth)

def test_process_info_save_load(self):
"""Test ProcessInfo save and load operations"""
test_pid = 12345
Expand Down
Loading