1
0
Fork 0
forked from glenux/mfm

Compare commits

..

5 commits

Author SHA1 Message Date
c21f175217 feat(config): enable reuse of mfm configuration variables
This change introduces a two-pass parsing approach to allow reuse of mfm
configuration variables within other configuration parts. This initial
implementation does not handle recursive dependencies, which is
acceptable for the current requirements.

- Implemented a two-pass parsing mechanism for configuration files.
- Added mfm configuration variables to the Crinja render context in both
  passes.
- Ensured the global mount point base is safely retrieved and validated
  in each pass.

Signed-off-by: Glenn Y. Rolland <glenux@glenux.net>
2025-04-11 12:32:23 +02:00
7953f9f3a7 fix(install): correct binary name in Makefile
The previous binary name was incorrect, which could lead to installation
failures.

- Changed the binary name from 'bin/code-preloader' to 'bin/mfm' in the
  install section of the Makefile.

Signed-off-by: Glenn Y. Rolland <glenux@glenux.net>
2025-04-11 12:29:44 +02:00
3a8d9239b2 Merge pull request 'feat: add support for sshfs option (-o) in config' (#51) from feature/50-add-support-for-sshfs-options into develop
Reviewed-on: glenux/mfm#51
2024-10-05 12:44:14 +00:00
5f775ac45f feat: add support for sshfs option (-o) in config 2024-10-05 10:54:40 +02:00
37710103ec Update README.md 2024-05-14 07:33:09 +00:00
7 changed files with 44 additions and 42 deletions

29
Jenkinsfile vendored
View file

@ -1,29 +0,0 @@
pipeline {
agent any
stages {
stage('Build') {
agent {
docker {
image 'crystallang/crystal:1.11.0-alpine'
reuseNode true
}
}
steps {
sh 'shards install'
sh 'shards build --production --static'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}

View file

@ -24,7 +24,7 @@ test:
install: install:
install \ install \
-m 755 \ -m 755 \
bin/code-preloader \ bin/mfm \
$(PREFIX)/bin $(PREFIX)/bin
.PHONY: spec test build all prepare install .PHONY: spec test build all prepare install

View file

@ -180,5 +180,5 @@ By contributing, you agree to our code of conduct and license terms.
## License ## License
GNU GPL-3 GNU GPL-3

View file

@ -16,7 +16,7 @@ module GX
class Cli class Cli
Log = ::Log.for("cli") Log = ::Log.for("cli")
@config : GX::Config @config : GX::Config
def initialize def initialize
# Main execution starts here # Main execution starts here

View file

@ -94,14 +94,37 @@ module GX
exit(1) exit(1)
end end
## PASS 1
file_data = File.read(config_path) 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) root = Models::RootConfig.from_yaml(file_patched)
mount_point_base_safe = root.global.mount_point_base mount_point_base_safe = root.global.mount_point_base
raise Models::InvalidMountpointError.new("Invalid global mount point") if mount_point_base_safe.nil? 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| root.filesystems.each do |selected_filesystem|
if !selected_filesystem.mount_point? if !selected_filesystem.mount_point?
selected_filesystem.mount_point = selected_filesystem.mount_point =

View file

@ -31,6 +31,6 @@ Log.setup do |config|
end end
end end
app = GX::Cli.new cli = GX::Cli.new
app.parse_command_line(ARGV) cli.parse_command_line(ARGV)
app.run cli.run

View file

@ -13,6 +13,7 @@ module GX::Models
getter remote_user : String = "" getter remote_user : String = ""
getter remote_host : String = "" getter remote_host : String = ""
getter remote_port : String = "22" getter remote_port : String = "22"
getter options : Array(String) = [] of String
include Concerns::Base include Concerns::Base
@ -28,13 +29,19 @@ module GX::Models
mount_point_safe = @mount_point mount_point_safe = @mount_point
raise InvalidMountpointError.new("Invalid mount point") if mount_point_safe.nil? 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( process = Process.new(
"sshfs", "sshfs",
[ options,
"-p", remote_port,
"#{@remote_user}@#{@remote_host}:#{@remote_path}",
mount_point_safe,
],
input: STDIN, input: STDIN,
output: STDOUT, output: STDOUT,
error: STDERR error: STDERR
@ -43,3 +50,4 @@ module GX::Models
end end
end end
end end