<< Masa.20101201-update-bbmb-ch-update-spreadsheet | 2010 | Masa.20101129-install-win7-update-bbmb >>
Memo
masa@masa ~/ywesee/bbmb.ch $ grep -r hwyss *|grep -v user-stories|grep -v test|grep -v bbmb
Setting pure-ftpd
masa@masa ~ $ sudo groupadd ftp_group masa@masa ~ $ sudo chgrp ftp_group ftp_share masa@masa ~ $ ls -l drwxr-xr-x 2 masa ftp_group 1 30. Nov 07:45 ftp_share masa@masa ~ $ sudo useradd -g ftp_group -d /home/masa/ftp_share ftp_user masa@masa ~ $ sudo pure-pw useradd ftp_user1 -u ftp_user -g ftp_group -d /home/masa/ftp_share -m Password: Enter it again: masa@masa ~ $ sudo /etc/init.d/pure-ftpd restart * You need to setup /etc/conf.d/pure-ftpd first! * ERROR: pure-ftpd failed to start
Note
Reference
masa@masa ~ $ vim /etc/conf.d/pure-ftpd IS_CONFIGURED="yes" SERVER="-S 21" MAX_CONN="-c 30" MAX_CONN_IP="-C 10" DAEMON="-B" DISK_FULL="-k 90%" AUTH="-lpuredb:/etc/pureftpd.pdb" MISC_OTHER="-A -E -X -U 177:077 -d -4 -L100:5 -I 15"
Set up again
masa@masa ~ $ sudo userdel ftp_user masa@masa ~ $ sudo useradd -g ftp_group -d /dev/null -s /etc ftp_user masa@masa ~ $ vim /etc/passwd ftp_user:x:1001:1008::/dev/null:/etc masa@masa ~ $ vim /etc/group ftp_group:x:1008: masa@masa ~ $ sudo pure-pw userdel ftp_user1 masa@masa ~ $ sudo pure-pw useradd ftp_user1 -u ftp_user -d /home/masa/ftp_share -m Password: Enter it again: masa@masa ~ $ sudo pure-pw show ftp_user1 masa@masa ~ $ sudo /etc/init.d/pure-ftpd restart * Caching service dependencies... [ok] * Starting Pure-FTPd...
Note
Check login
masa@masa ~ $ lftp ftp_user1@localhost Passwort: lftp ftp_user1@localhost:~> ls -rw-r--r-- 1 1000 1003 6 Nov 30 08:31 hello.dat lftp ftp_user1@localhost:/> exit masa@masa ~ $ ls ftp_share/ -l insgesamt 4 -rw-r--r-- 1 masa masa 6 30. Nov 08:31 hello.dat masa@masa ~ $ ps aux|grep ftp root 3787 0.0 0.0 25956 756 ? Ss 08:28 0:00 pure-ftpd (SERVER)
1. git clone
2. src/testenvironment.rb
#!/usr/bin/env ruby puts 'loading testenvironment' class BbmbApp < SBSM::DRbServer puts "disabling UPDATER" remove_const :RUN_UPDATER RUN_UPDATER = false end module BBMB class CustomBehaviorGag < CustomBehavior remove_const :MAIL_RECIPIENTS, :MAIL_RECIPIENTS_CC, :MAIL_INJECT_RECIPIENTS, :MAIL_PDF_RECIPIENTS, :MAIL_PDF_RECIPIENTS_CC, :MAIL_PDF_FROM MAIL_RECIPIENTS = ['mhatakeyama@ywesee.com'] MAIL_RECIPIENTS_CC = [] MAIL_INJECT_RECIPIENTS = ['mhatakeyama@ywesee.com'] MAIL_PDF_RECIPIENTS = ['mhatakeyama@ywesee.com'] MAIL_PDF_RECIPIENTS_CC = [] MAIL_PDF_FROM = 'mhatakeyama@ywesee.com' end end
3. src/custom/lookandfeelgag.rb (updated
))
#!/usr/bin/env ruby # LookandfeelGag -- bbmb -- hwyss@ywesee.com require "sbsm/lookandfeelwrapper" module BBMB class LookandfeelGag < SBSM::LookandfeelWrapper DICTIONARIES = { "de" => { :new_customer_mail => "mailto:mhatakeyama@ywesee.com?subject=Neukunde BBMB - bitte Passwort generieren&", :partner => "Masapharm AG", :welcome => "Willkommen bei Masapharm", } } ENABLED = [ :bcreader_usb, ] end end
4. src/util/bbmbconfig.rb
#!/usr/bin/env ruby # BbmbConfig -- bbmb -- 09.04.2003 -- hwyss@ywesee.com module BBMB DEFAULT_FLAVOR = 'gag' #SERVER_URI = ["druby://localhost:9999", "druby://192.168.0.35:9876"] SERVER_URI = ["druby://localhost:9999", "druby://localhost:9876"] def primary_uri if(SERVER_URI.is_a? Array) SERVER_URI.first else SERVER_URI.to_s end end module_function :primary_uri YAML_ODDB_URI = "druby://localhost:10004" end
5. replace doc/resources/gag/logo.gif
6. src/util/session.rb#http_protocol
def http_protocol #'https' 'http' end
7. /etc/apache2/vhosts.d/05_bbmbch_vhost.conf
<Directory /home/masa/ywesee/bbmb.ch/doc> Options ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> <VirtualHost *:80> DocumentRoot /home/masa/ywesee/bbmb.ch/doc ServerName masapharm.bbmb.ch DirectoryIndex index.rbx RubyAddPath /home/masa/ywesee/bbmb.ch/src RubyRequire 'sbsm/trans_handler' SetHandler ruby-object RubyTransHandler SBSM::FlavoredTransHandler.instance </VirtualHost>
8. Start bbmb.ch/bin/bbmbd
Access to http://masapharm.bbmb.ch
Result
1. bbmb.ch/etc/accessgag.rb
#!/usr/bin/env ruby # CustomBehavior -- bbmb -- hwyss@ywesee.com module BBMB class CustomBehaviorGag < CustomBehavior REMOTE_ACCESS = 'ftp://ftp_user1:passwd@localhost' end end
Note
Root user is defined in the code
INITIAL_VALUES = { :email => "aa@bb.cc", :pass_hash => "47bce5c74f589f4867dbd57e9ca9f808", }
Note
def recognizes? session #puts "#{session[:email].inspect} <=> #{@attributes[:email].inspect}" #puts "#{session[:pass].inspect} <=> #{@attributes[:pass_hash].inspect}" return false unless session[:email] && session[:pass] print "session[:pass]=" p session[:pass] print "@attributes[:pass_hash]=" print @attributes[:pass_hash] print "session[:email]=" p session[:email] print "@attributes[:email]=" p @attributes[:email] rec = (session[:pass] == @attributes[:pass_hash]) && (@attributes[:email] == session[:email]) if(rec) @attributes[:last_login] = Time.now end rec end
Reboot bbmb.ch/bin/bbmbd
Login by root user
Result
Quesion
Experiment (add Admin user from browser)
grep search
masa@masa ~/ywesee/bbmb.ch $ grep -r admin * src/custom/lookandfeelbase.rb: :new_admin => "Neuer Administrator", src/custom/lookandfeelbase.rb: :new_subadmin => "Neuer Administrator",
Notes
Debugging
module BBMB class AdminState < GlobalState DIRECT_EVENT = :show_admin VIEW = AdminView def init @model = @session.user.show_admin(@session) end def save p "getin AdminState#save" begin mandatory = [ :address, :email, :location, :plz, :reseller_name, :reseller_short, ] keys = mandatory + [ :uid, ] input = user_input(keys, mandatory) print "input=" p input print "error?=" p error? unless(error?) p "passin error?" if(input[:uid].to_s == 'new') @session.create_admin(@session) else @session.save_admin(@session) end trigger(:admins) end rescue BBMB::IllegalActionException => e puts e end end
Result
Note
PLZ/Ort
also must be entered
Debugging
#!/usr/bin/env ruby # AdminState -- bbmb -- 16.04.2004 -- hwyss@ywesee.com require 'state/global' require 'view/admin' module BBMB class AdminState < GlobalState DIRECT_EVENT = :show_admin VIEW = AdminView def init @model = @session.user.show_admin(@session) end def save p "getin AdminState#save" begin mandatory = [ :address, :email, :location, :plz, :reseller_name, :reseller_short, ] keys = mandatory + [ :uid, ] input = user_input(keys, mandatory) print "input=" p input print "error?=" p error? unless(error?) p "passin error?" if(input[:uid].to_s == 'new') @session.create_admin(@session) else @session.save_admin(@session) end trigger(:admins) end rescue BBMB::IllegalActionException => e p "BBMB::IllegalActionExcepion" puts e end end def change_pass self end end end
def create_admin session p "getin create_admin" unless session.user.instance_of?(BBMB::RootUser) raise BBMB::IllegalActionException.new(:create_admin) end create_user(BBMB::AdminUser, session, session.user) end def create_hospital(session) unless session.user.allowed?(:create, 'hospital') raise BBMB::IllegalActionException.new(:create_hospital) end create_user(BBMB::HospitalUser, session, session.user) end def create_user(klass, session, creator) p "getin create_user" values = klass.prepare(session) command = BBMB::Transaction.new(AddUserCommand.new(klass, values, creator)) @prevalence.executeTransaction(command) end def create_subadmin(session) p "getin create_subadmin" create_user(BBMB::SubAdminUser, session, session.user) end def create_supplier_user(session) p "getin create_supplier_user" create_user(BBMB::SupplierUser, session, session.user) end
Reboot bbmb.ch/bin/bbmbd
Register admin user again
Result
"getin AdminState#save" input={:address=>"mmm", :reseller_short=>"gag", :plz=>"1111", :uid=>"new", :reseller_name=>"mhatakeyama@ywesee.com", :location=>"mmm", :email=>"mhatakeyama@ywesee.com"} error?="getin error?" @errors={} false "getin error?" @errors={} "passin error?" "getin create_admin" "getin create_user" :email "mhatakeyama@ywesee.com" :e_duplicate_email
Question
git status check
masa@masa ~/ywesee/bbmb.ch $ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: doc/resources/gag/logo.gif # modified: src/custom/lookandfeelgag.rb # modified: src/model/root.rb # modified: src/model/user.rb # modified: src/state/admin.rb # modified: src/util/bbmbapp.rb # modified: src/util/bbmbconfig.rb # modified: src/util/session.rb # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # log/ # src/testenvironment.rb no changes added to commit (use "git add" and/or "git commit -a")
Experiment
masa@masa ~/ywesee/bbmb.ch $ rm -rf log
Register admin user again
Result
Notes
But
masa@masa ~/ywesee/bbmb.ch $ bin/bbmbd /usr/lib64/ruby/1.8/net/protocol.rb:206:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED) from /usr/lib64/ruby/1.8/net/protocol.rb:206:in `new' from /usr/lib64/ruby/1.8/net/protocol.rb:206:in `old_open' from /usr/lib64/ruby/1.8/timeout.rb:62:in `timeout' from /usr/lib64/ruby/1.8/timeout.rb:93:in `timeout' from /usr/lib64/ruby/1.8/net/protocol.rb:206:in `old_open' from /usr/lib64/ruby/1.8/net/smtp.rb:392:in `do_start' from /usr/lib64/ruby/1.8/net/smtp.rb:377:in `start' from /home/masa/ywesee/bbmb.ch/src/custom/behavior.rb:350:in `mail_send' ... 12 levels... from /home/masa/ywesee/bbmb.ch/src/util/bbmbapp.rb:520:in `run_statistics' from /home/masa/ywesee/bbmb.ch/src/util/bbmbapp.rb:302:in `initialize' from bin/bbmbd:9:in `new' from bin/bbmbd:9
Note
# @statistics = run_statistics if RUN_STATISTICS
1. Login as superuser (aa@bb.cc)
2. Click an admin user (mhatakeyama@ywesee.com)
3. Click 'Administratoren 0'
4. Click 'Neuer Administrator'
5. Input items
Result
Next
Question
There are 5 types of users defined
def login @session.login case @session.user when RootUser state = AdminsState.new(@session, nil) state.extend(RootState) state when AdminUser state = HospitalsState.new(@session, nil) state.extend(AdminUserState) state when SubAdminUser state = HospitalsState.new(@session, nil) state.extend(SubAdminUserState) state when HospitalUser state = CurrentOrderState.new(@session, nil) state.extend(HospitalUserState) state when SupplierUser state = BackordersState.new(@session, nil) state.extend(SupplierUserState) state else self end end
Question
Note
def run_updater puts "running updater thread" Thread.new { Thread.current.priority=-10 Thread.current.abort_on_exception = true today = (UPDATE_HOUR > Time.now.hour) ? Date.today : Date.today.next loop { next_run = Time.local(today.year, today.month, today.day, UPDATE_HOUR) sleep(next_run - Time.now) update() today = Date.today.next } } end
Note
Experiment
1. put a cosutomer file (ywskund) in the ftp directory
masa@masa ~ $ ls ftp_share/ywesee/Out/ ywskund masa@masa ~ $ cat ftp_share/ywesee/Out/ywskund 584674;584674;22;ywesee;;Hatapharm AG;;hoge hoge 11;;CH;8000;hogehoge;011 / 111 22 33;;;011 / 111 22 44;hatapharm@ywesee.com;
2. Set REMOTE_ACCESS constant
src/custom/behavior.rb
REMOTE_ACCESS = 'ftp://ftp_user1:passwd@localhost'
3. Modify in order to run 'update_users' quickly
src/util/bbmbapp.rb
def run_updater puts "running updater thread" Thread.new { Thread.current.priority=-10 Thread.current.abort_on_exception = true #today = (UPDATE_HOUR > Time.now.hour) ? Date.today : Date.today.next today = Date.today loop { #next_run = Time.local(today.year, today.month, today.day, UPDATE_HOUR) next_run = Time.local(today.year, today.month, today.day, Time.now.hour, Time.now.min+1) print "now=" p Time.now print "next_run=" p next_run sleep(next_run - Time.now) update() today = Date.today.next } } end
Reboot bbmbd
Login as a superuser (aa@bb.cc)
Result
Test login as a customer
Note
Important