@@ -32,6 +32,7 @@ protected function configure(): void {
3232 $ this ->setName ('app_api:daemon:register ' );
3333 $ this ->setDescription ('Register daemon config for ExApp deployment ' );
3434
35+ // todo: add docs
3536 $ this ->addArgument ('name ' , InputArgument::REQUIRED );
3637 $ this ->addArgument ('display-name ' , InputArgument::REQUIRED );
3738 $ this ->addArgument ('accepts-deploy-id ' , InputArgument::REQUIRED );
@@ -42,13 +43,16 @@ protected function configure(): void {
4243 // daemon-config settings
4344 $ this ->addOption ('net ' , null , InputOption::VALUE_REQUIRED , 'DeployConfig, the name of the docker network to attach App to ' );
4445 $ this ->addOption ('haproxy_password ' , null , InputOption::VALUE_REQUIRED , 'AppAPI Docker Socket Proxy password for HAProxy Basic auth ' );
45-
4646 $ this ->addOption ('compute_device ' , null , InputOption::VALUE_REQUIRED , 'Compute device for GPU support (cpu|cuda|rocm) ' );
47-
4847 $ this ->addOption ('set-default ' , null , InputOption::VALUE_NONE , 'Set DaemonConfig as default ' );
49-
50- $ this ->addUsage ('local_docker "Docker local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud ' );
51- $ this ->addUsage ('local_docker "Docker local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda ' );
48+ $ this ->addOption ('harp ' , null , InputOption::VALUE_NONE , 'Set daemon to use HaRP for all docker and exapp communication ' );
49+ $ this ->addOption ('harp_shared_key ' , null , InputOption::VALUE_REQUIRED , 'HaRP shared key for secure communication between HaRP and AppAPI ' );
50+
51+ $ this ->addUsage ('manual_install "Manual Install" "manual-install" "http" null "http://nextcloud.local" ' );
52+ $ this ->addUsage ('local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud ' );
53+ $ this ->addUsage ('local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda ' );
54+ $ this ->addUsage ('docker_install "Docker Socket Proxy" "docker-install" "http" "nextcloud-appapi-dsp:2375" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda ' );
55+ $ this ->addUsage ('harp_install "Harp Install" "docker-install" "http" "nextcloud-appapi-harp:8780" "http://nextcloud.local" --harp --harp_shared_key "some_very_secure_password" --set-default --compute_device=cuda ' );
5256 }
5357
5458 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
@@ -58,28 +62,43 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5862 $ protocol = $ input ->getArgument ('protocol ' );
5963 $ host = $ input ->getArgument ('host ' );
6064 $ nextcloudUrl = $ input ->getArgument ('nextcloud_url ' );
61-
62- $ deployConfig = [
63- 'net ' => $ input ->getOption ('net ' ) ?? 'host ' ,
64- 'nextcloud_url ' => $ nextcloudUrl ,
65- 'haproxy_password ' => $ input ->getOption ('haproxy_password ' ) ?? '' ,
66- 'computeDevice ' => $ this ->buildComputeDevice ($ input ->getOption ('compute_device ' ) ?? 'cpu ' ),
67- ];
65+ $ isHarp = $ input ->getOption ('harp ' ) !== null ;
6866
6967 if (($ protocol !== 'http ' ) && ($ protocol !== 'https ' )) {
7068 $ output ->writeln ('Value error: The protocol must be `http` or `https`. ' );
7169 return 1 ;
7270 }
73- if (( $ acceptsDeployId === 'manual-install ' ) && ( $ protocol !== 'http ' ) ) {
71+ if ($ acceptsDeployId === 'manual-install ' && $ protocol !== 'http ' ) {
7472 $ output ->writeln ('Value error: Manual-install daemon supports only `http` protocol. ' );
7573 return 1 ;
7674 }
75+ // todo:
76+ if ($ acceptsDeployId === 'manual-install ' && $ isHarp ) {
77+ $ output ->writeln ('Value error: Manual-install daemon does not support HaRP. ' );
78+ return 1 ;
79+ }
80+ if ($ isHarp && !$ input ->getOption ('harp_shared_key ' )) {
81+ $ output ->writeln ('Value error: HaRP enabled daemon requires `harp_shared_key` option. ' );
82+ return 1 ;
83+ }
7784
7885 if ($ this ->daemonConfigService ->getDaemonConfigByName ($ name ) !== null ) {
7986 $ output ->writeln (sprintf ('Skip registration, as daemon config `%s` already registered. ' , $ name ));
8087 return 0 ;
8188 }
8289
90+ $ secret = $ isHarp
91+ ? $ input ->getOption ('harp_shared_key ' )
92+ : $ input ->getOption ('haproxy_password ' ) ?? '' ;
93+
94+ $ deployConfig = [
95+ 'net ' => $ input ->getOption ('net ' ) ?? 'host ' ,
96+ 'nextcloud_url ' => $ nextcloudUrl ,
97+ 'haproxy_password ' => $ secret ,
98+ 'computeDevice ' => $ this ->buildComputeDevice ($ input ->getOption ('compute_device ' ) ?? 'cpu ' ),
99+ 'harp ' => $ isHarp ,
100+ ];
101+
83102 $ daemonConfig = $ this ->daemonConfigService ->registerDaemonConfig ([
84103 'name ' => $ name ,
85104 'display_name ' => $ displayName ,
0 commit comments