2023-11-24 00:20:16 +01:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
|
|
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
|
|
|
|
|
|
require "shellwords"
|
|
|
|
require "./abstract_filesystem_config"
|
|
|
|
require "./concerns/base"
|
|
|
|
|
|
|
|
module GX::Models
|
|
|
|
class SshFSConfig < AbstractFilesystemConfig
|
|
|
|
getter remote_path : String = ""
|
|
|
|
getter remote_user : String = ""
|
|
|
|
getter remote_host : String = ""
|
|
|
|
getter remote_port : String = "22"
|
|
|
|
|
|
|
|
include Concerns::Base
|
|
|
|
|
|
|
|
def _mounted_prefix()
|
|
|
|
"#{@remote_user}@#{@remote_host}:#{@remote_path}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def mounted_name()
|
|
|
|
@name
|
|
|
|
end
|
|
|
|
|
|
|
|
def _mount_action()
|
|
|
|
mount_point_safe = @mount_point
|
2023-11-24 10:25:30 +01:00
|
|
|
raise InvalidMountpointError.new("Invalid mount point") if mount_point_safe.nil?
|
2023-11-24 00:20:16 +01:00
|
|
|
|
|
|
|
process = Process.new(
|
|
|
|
"sshfs",
|
|
|
|
[
|
|
|
|
"-p", remote_port,
|
|
|
|
"#{@remote_user}@#{@remote_host}:#{@remote_path}",
|
|
|
|
mount_point_safe
|
|
|
|
],
|
|
|
|
input: STDIN,
|
|
|
|
output: STDOUT,
|
|
|
|
error: STDERR
|
|
|
|
)
|
2023-11-24 19:25:21 +01:00
|
|
|
return process.wait
|
2023-11-24 00:20:16 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|