Skip to content

Instantly share code, notes, and snippets.

@allaire
Last active March 28, 2018 21:53

Revisions

  1. allaire revised this gist Mar 23, 2018. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions upload_erb.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    def template(from, to, as_root = false)
    def template(from, to, options = {})
    template_path = File.expand_path("../../templates/#{from}", __FILE__)
    template = ERB.new(File.new(template_path).read).result(binding)
    upload! StringIO.new(template), to

    sudo "chown root:root #{to}" if as_root == true
    end
    upload! StringIO.new(template), to, mode: 0644 # Otherwise it's set to 0640, which is not readable by other users (https://github.com/net-ssh/net-scp/blob/master/lib/net/scp/upload.rb#L63)
    sudo "chown root:root #{to}" if options[:as_root]
    end
  2. allaire revised this gist Mar 23, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion upload_erb.rb
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,5 @@ def template(from, to, as_root = false)
    template = ERB.new(File.new(template_path).read).result(binding)
    upload! StringIO.new(template), to

    sudo "chmod 644 #{to}" # ensure default file chmod
    sudo "chown root:root #{to}" if as_root == true
    end
  3. allaire revised this gist Dec 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion upload_erb.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    def template(from, to, as_root = false)
    template_path = File.expand_path("../templates/#{from}", __FILE__)
    template_path = File.expand_path("../../templates/#{from}", __FILE__)
    template = ERB.new(File.new(template_path).read).result(binding)
    upload! StringIO.new(template), to

  4. allaire renamed this gist Jan 14, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. allaire created this gist Jan 14, 2014.
    8 changes: 8 additions & 0 deletions task.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    def template(from, to, as_root = false)
    template_path = File.expand_path("../templates/#{from}", __FILE__)
    template = ERB.new(File.new(template_path).read).result(binding)
    upload! StringIO.new(template), to

    sudo "chmod 644 #{to}" # ensure default file chmod
    sudo "chown root:root #{to}" if as_root == true
    end