hotspotlogin 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -6
- data/bin/hotspotlogin.rb +24 -4
- data/lib/hotspotlogin/app.rb +2 -0
- data/lib/hotspotlogin/config.rb +25 -4
- data/lib/hotspotlogin/constants.rb +1 -1
- metadata +5 -19
- data/bin/hotspotlogin_ctl.rb +0 -13
data/README.rdoc
CHANGED
@@ -18,16 +18,15 @@ Installation:
|
|
18
18
|
|
19
19
|
On the command-line:
|
20
20
|
|
21
|
-
$
|
21
|
+
$ hotspotlogin.rb [options]
|
22
22
|
|
23
|
-
|
24
|
-
run in foreground. Daemons gem documentation for more info.
|
23
|
+
==== Options
|
25
24
|
|
26
|
-
|
25
|
+
--daemon daemonize
|
27
26
|
|
28
|
-
|
27
|
+
--log log file (ignored when no --daemon)
|
29
28
|
|
30
|
-
|
29
|
+
--pid pid file (ignored when no --daemon)
|
31
30
|
|
32
31
|
--port [default 4990]
|
33
32
|
|
@@ -42,6 +41,10 @@ Or directly
|
|
42
41
|
--conf <FILE> YAML configuration file, see examples/
|
43
42
|
|
44
43
|
See also chilli.conf(5) manual page.
|
44
|
+
|
45
|
+
==== Unix Signals
|
46
|
+
|
47
|
+
USR1 sync/update log file (flush buffered I/O)
|
45
48
|
|
46
49
|
== LICENSE:
|
47
50
|
|
data/bin/hotspotlogin.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
# Don'use this hack, since it breaks /proc/<pid>/cmdline
|
4
|
+
# $0 = 'hotspotlogin.rb'
|
4
5
|
|
5
6
|
require 'rubygems'
|
6
7
|
require 'sinatra/base'
|
@@ -15,7 +16,26 @@ require File.expand_path(
|
|
15
16
|
File.dirname(file) + "/../lib/hotspotlogin"
|
16
17
|
)
|
17
18
|
|
18
|
-
HotSpotLogin.config!
|
19
|
-
|
20
|
-
HotSpotLogin::App.run!
|
19
|
+
config = HotSpotLogin.config!
|
21
20
|
|
21
|
+
if config['daemon']
|
22
|
+
pid = fork do
|
23
|
+
if config['log']
|
24
|
+
STDOUT.reopen(config['log'], 'a')
|
25
|
+
STDERR.reopen(config['log'], 'a')
|
26
|
+
Signal.trap('USR1') do
|
27
|
+
STDOUT.flush
|
28
|
+
STDERR.flush
|
29
|
+
end
|
30
|
+
end
|
31
|
+
HotSpotLogin::App.run!
|
32
|
+
FileUtils.rm config['pid'] if config['pid'] and File.exists? config['pid']
|
33
|
+
end
|
34
|
+
if config['pid'] =~ /\S/
|
35
|
+
File.open config['pid'], 'w' do |f|
|
36
|
+
f.write pid
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
HotSpotLogin::App.run!
|
41
|
+
end
|
data/lib/hotspotlogin/app.rb
CHANGED
data/lib/hotspotlogin/config.rb
CHANGED
@@ -9,7 +9,10 @@ module HotSpotLogin
|
|
9
9
|
|
10
10
|
def self.config; @@config; end
|
11
11
|
|
12
|
-
def self.config=(h)
|
12
|
+
def self.config=(h)
|
13
|
+
@@config = h
|
14
|
+
config_sinatra!
|
15
|
+
end
|
13
16
|
|
14
17
|
# Parses command line and configuration file
|
15
18
|
def self.config!
|
@@ -25,6 +28,18 @@ module HotSpotLogin
|
|
25
28
|
|
26
29
|
# Command line switches override configuration file.
|
27
30
|
|
31
|
+
opts.on('--daemon', 'become a daemon') do
|
32
|
+
@@config['daemon'] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on('--log FILE', 'log file (overwrite existing)') do |filename|
|
36
|
+
@@config['log'] = filename
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on('--pid FILE', 'pid file') do |filename|
|
40
|
+
@@config['pid'] = filename
|
41
|
+
end
|
42
|
+
|
28
43
|
opts.on('--uamsecret PASS', 'as in chilli.conf(5)') do |uamsecret|
|
29
44
|
@@config['uamsecret'] = uamsecret
|
30
45
|
end
|
@@ -47,11 +62,17 @@ module HotSpotLogin
|
|
47
62
|
|
48
63
|
end.parse!
|
49
64
|
|
50
|
-
|
65
|
+
self.config_sinatra!
|
66
|
+
|
67
|
+
return @@config
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def self.config_sinatra!
|
51
73
|
App.set :host, @@config['listen-address']
|
52
74
|
App.set :port, @@config['port']
|
53
75
|
App.set :logging, @@config['log-http']
|
54
|
-
|
55
76
|
end
|
56
|
-
|
77
|
+
|
57
78
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Guido De Rosa
|
@@ -29,23 +29,10 @@ dependencies:
|
|
29
29
|
version: "0"
|
30
30
|
type: :runtime
|
31
31
|
version_requirements: *id001
|
32
|
-
|
33
|
-
name: daemons
|
34
|
-
prerelease: false
|
35
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
segments:
|
40
|
-
- 0
|
41
|
-
version: "0"
|
42
|
-
type: :runtime
|
43
|
-
version_requirements: *id002
|
44
|
-
description: Traditionally, a PHP or Perl/CGI web page has been used to login unauthenticated users to a Network Acces Controller like ChilliSpot; this hotspotlogin implementation is based on Ruby and Sinatra (the classy web framework).
|
32
|
+
description: Traditionally, a PHP or Perl/CGI web page has been used to login unauthenticated users to a Network Access Controller like ChilliSpot; this hotspotlogin implementation is based on Ruby and Sinatra (the classy web framework).
|
45
33
|
email: guidoderosa@gmail.com
|
46
|
-
executables:
|
47
|
-
|
48
|
-
- hotspotlogin_ctl.rb
|
34
|
+
executables: []
|
35
|
+
|
49
36
|
extensions: []
|
50
37
|
|
51
38
|
extra_rdoc_files:
|
@@ -57,7 +44,6 @@ files:
|
|
57
44
|
- views/hotspotlogin.erb
|
58
45
|
- views/404.erb
|
59
46
|
- views/_login_form.erb
|
60
|
-
- bin/hotspotlogin_ctl.rb
|
61
47
|
- bin/hotspotlogin.rb
|
62
48
|
- lib/hotspotlogin.rb
|
63
49
|
- lib/hotspotlogin/constants.rb
|