forked from glenux/mfm
Compare commits
5 commits
feature/1-
...
develop
Author | SHA1 | Date | |
---|---|---|---|
c21f175217 | |||
7953f9f3a7 | |||
3a8d9239b2 | |||
5f775ac45f | |||
37710103ec |
6 changed files with 44 additions and 13 deletions
2
Makefile
2
Makefile
|
@ -24,7 +24,7 @@ test:
|
|||
install:
|
||||
install \
|
||||
-m 755 \
|
||||
bin/code-preloader \
|
||||
bin/mfm \
|
||||
$(PREFIX)/bin
|
||||
|
||||
.PHONY: spec test build all prepare install
|
||||
|
|
|
@ -16,7 +16,7 @@ module GX
|
|||
class Cli
|
||||
Log = ::Log.for("cli")
|
||||
|
||||
@config : GX::Config
|
||||
@config : GX::Config
|
||||
|
||||
def initialize
|
||||
# Main execution starts here
|
||||
|
|
|
@ -94,14 +94,37 @@ module GX
|
|||
exit(1)
|
||||
end
|
||||
|
||||
## PASS 1
|
||||
file_data = File.read(config_path)
|
||||
file_patched = Crinja.render(file_data, {"env" => ENV.to_h})
|
||||
|
||||
file_patched = Crinja.render(
|
||||
file_data,
|
||||
{
|
||||
"env" => ENV.to_h,
|
||||
"mfm" => {
|
||||
"global" => {"mount_point_base" => "" }
|
||||
}
|
||||
}
|
||||
)
|
||||
root = Models::RootConfig.from_yaml(file_patched)
|
||||
|
||||
mount_point_base_safe = root.global.mount_point_base
|
||||
raise Models::InvalidMountpointError.new("Invalid global mount point") if mount_point_base_safe.nil?
|
||||
|
||||
## PASS 2
|
||||
file_patched = Crinja.render(
|
||||
file_data,
|
||||
{
|
||||
"env" => ENV.to_h,
|
||||
"mfm" => {
|
||||
"global" => {"mount_point_base" => mount_point_base_safe }
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
root = Models::RootConfig.from_yaml(file_patched)
|
||||
mount_point_base_safe = root.global.mount_point_base
|
||||
raise Models::InvalidMountpointError.new("Invalid global mount point") if mount_point_base_safe.nil?
|
||||
|
||||
root.filesystems.each do |selected_filesystem|
|
||||
if !selected_filesystem.mount_point?
|
||||
selected_filesystem.mount_point =
|
||||
|
|
|
@ -31,6 +31,6 @@ Log.setup do |config|
|
|||
end
|
||||
end
|
||||
|
||||
app = GX::Cli.new
|
||||
app.parse_command_line(ARGV)
|
||||
app.run
|
||||
cli = GX::Cli.new
|
||||
cli.parse_command_line(ARGV)
|
||||
cli.run
|
||||
|
|
|
@ -13,6 +13,7 @@ module GX::Models
|
|||
getter remote_user : String = ""
|
||||
getter remote_host : String = ""
|
||||
getter remote_port : String = "22"
|
||||
getter options : Array(String) = [] of String
|
||||
|
||||
include Concerns::Base
|
||||
|
||||
|
@ -28,13 +29,19 @@ module GX::Models
|
|||
mount_point_safe = @mount_point
|
||||
raise InvalidMountpointError.new("Invalid mount point") if mount_point_safe.nil?
|
||||
|
||||
options = [] of String
|
||||
# merge sshfs options
|
||||
@options.each do |option|
|
||||
options.push("-o", option)
|
||||
end
|
||||
options.push("-p", remote_port)
|
||||
options.push(
|
||||
"#{@remote_user}@#{@remote_host}:#{@remote_path}",
|
||||
mount_point_safe
|
||||
)
|
||||
process = Process.new(
|
||||
"sshfs",
|
||||
[
|
||||
"-p", remote_port,
|
||||
"#{@remote_user}@#{@remote_host}:#{@remote_path}",
|
||||
mount_point_safe,
|
||||
],
|
||||
options,
|
||||
input: STDIN,
|
||||
output: STDOUT,
|
||||
error: STDERR
|
||||
|
@ -43,3 +50,4 @@ module GX::Models
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue