./bin/cli/nginx in lux-fw-0.1.17 vs ./bin/cli/nginx in lux-fw-0.1.35

- old
+ new

@@ -1,28 +1,34 @@ #!/usr/bin/env ruby command = ARGV[0] -@local_conf = './config/nginx.conf' -@nginx_conf = '/etc/nginx/sites-enabled/%s.conf' % Dir.pwd.split('/').last +ROOT = Dir.pwd +FOLDER = Dir.pwd.split('/').last +@local_conf = './config/nginx.conf' +@target_conf = '/etc/nginx/sites-enabled/%s.conf' % FOLDER + def build_conf conf = File.read(@local_conf) rescue LuxCli.die('Local conf %s not found' % @local_conf) LuxCli.die('$ROOT not found in config') unless conf.include?('$ROOT') - conf.gsub('$ROOT', Dir.pwd) + conf = conf.gsub(/`([^`]+)`/) { `#{$1}`.chomp } + conf = conf.gsub('$ROOT', ROOT) + conf = conf.gsub('$FOLDER', FOLDER) + conf end case command when 'show' puts build_conf when 'install' File.write './tmp/nginx.conf', build_conf puts '# run this manualy' puts - puts 'sudo cp ./tmp/nginx.conf %s && sudo nginx -t' % @nginx_conf + puts 'sudo cp ./tmp/nginx.conf %s && sudo nginx -t' % @target_conf else puts ' show # show rendered config' - puts ' install # install config/nginx.conf to %s' % @nginx_conf + puts ' install # install config/nginx.conf to %s' % @target_conf end