Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Initial version of dokuen-shell"

This reverts commit 267d03e.
  • Loading branch information...
commit ab1df46ca0b0162a000ed623eeabd717adbbfb06 1 parent 662c2c2
@peterkeen authored
View
22 bin/dokuen-shell
@@ -1,22 +0,0 @@
-#!/usr/bin/env ruby
-
-$stdout.sync = true
-
-require "rubygems"
-
-begin
- require 'dokuen'
-rescue LoadError => e
- path = File.expand_path '../../lib', __FILE__
- $:.unshift(path) if File.directory?(path) && !$:.include?(path)
- require 'dokuen'
-end
-
-begin
- Dokuen::Shell.new(ARGV[0], ENV['SSH_ORIGINAL_COMMAND'], ARGV[1]).run()
-rescue Dokuen::ExitCode => e
- if e.code != 0
- $stderr.puts e.message
- exit e.code
- end
-end
View
2  lib/dokuen.rb
@@ -10,7 +10,6 @@ def self.template(name, bind)
raise "Unknown template: #{name}"
end
end
-
end
require "dokuen/cli"
@@ -18,4 +17,3 @@ def self.template(name, bind)
require "dokuen/application"
require "dokuen/wrapper"
require "dokuen/platform"
-require "dokuen/shell"
View
21 lib/dokuen/cli.rb
@@ -136,33 +136,12 @@ def run_command(*args)
app.run_command(args)
end
- desc "grant USER", "Grant USER permissions for application"
- def grant(user)
- # pass
- end
-
- desc "revoke USER", "Remove USER permissions for application"
- def revoke(user)
- # pass
- end
-
- desc "addkey USER", "Add a user's public key from stdin"
- def addkey(user)
- # pass
- end
-
- desc "removekey USER", "Remove a user's public key"
- def removekey(user)
- # pass
- end
-
private
def setup_dirs
dirs = [
'apps',
'env',
- 'perms',
'ports',
'nginx',
'bin'
View
85 lib/dokuen/shell.rb
@@ -1,85 +0,0 @@
-require 'shellwords'
-
-class Dokuen::ExitCode < StandardError
-
- attr_reader :code, :message
-
- def initialize(code, message)
- @code = code
- @message = message
- end
-
-end
-
-class Dokuen::Shell
-
- attr_reader :command, :commandv, :user, :application, :basedir
-
- def initialize(basedir, command, user)
- @basedir = basedir
- @command = command
- @user = user
- @commandv = Shellwords.split(command)
- @application = determine_appname
- end
-
- def determine_appname
- if match = command.match(/--application=(\w+)/)
- return match[1]
- elsif match = command.match(/(\w+)\.git/)
- return match[1]
- else
- raise Dokuen::ExitCode.new(1, "Could not determine appname from #{command}")
- end
- end
-
- def _check_permissions_file(filename, user)
- if File.exists?(filename)
- lines = File.read(filename).split("\n")
- return lines.include?(user)
- end
- end
-
- def check_permissions
- if _check_permissions_file("#{basedir}/superusers", user)
- return
- end
- if ! _check_permissions_file("#{basedir}/perms/#{application}", user)
- raise Dokuen::ExitCode.new(2, "User #{user} not permitted for app #{application}")
- else
- if commandV[0] != "create"
- raise Dokuen::ExitCode.new(3, "App #{application} does not exist")
- end
- end
- end
-
- def run_git_command
- repo = "#{basedir}/repos/#{commandV[1]}"
- system("#{commandV[0]} '#{repo}'")
- raise Dokuen::ExitCode.new($?.exitstatus, '')
- end
-
- def run_dokuen_subcommand
- system("#{basedir}/bin/dokuen #{command}", :in => $stdin, :out => $stdout, :err => $stderr)
- raise Dokuen::ExitCode.new($?.exitstatus, '')
- end
-
- def run
-
- if command.nil?
- $stderr.puts "Shell access rejected"
- exit(1)
- end
-
- check_permissions
-
- case commandv[0]
- when "git-receive-pack"
- run_git_command
- when "git-upload-pack"
- run_git_command
- else
- run_dokuen_subcommand
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.