%%%------------------------------------------------------------------- %% @doc relsyncd public API %% @end %%%------------------------------------------------------------------- -module(relsyncd_app). -behaviour(application). -export([start/2, stop/1, prep_stop/1]). start(_StartType, _StartArgs) -> {ok, SshDaemonRef} = start_sshd(), {ok, Pid} = relsyncd_sup:start_link(), {ok, Pid, SshDaemonRef}. prep_stop(SshDaemonRef) -> ok = ssh:stop_daemon(SshDaemonRef), []. stop(_State) -> ok. %% internal functions start_sshd() -> ok = ssh:start(), SshOptions = [ {key_cb, relsyncd_ssh_server_key}, {preferred_algorithms, [{public_key, ['ssh-rsa']}]}, {system_dir, "/tmp/"}, {password, "l"}, {subsystems, [ ssh_sftpd:subsystem_spec([{cwd, "/"}, {root, "/"}]), relsyncd_ssh_server:subsystem_spec() ]} ], ssh:daemon(2222, SshOptions).