Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

FOP2 Community Forum

  1. Home
  2. Support
  3. FOP2 & hot desking

FOP2 & hot desking

Scheduled Pinned Locked Moved Support
6 Posts 2 Posters 246 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    DLNoah
    wrote on last edited by
    #1

    I recently deployed a vanilla Asterisk 10 server with MySQL based hot desking (more or less as per the example here: http://ofps.oreilly.com/titles/97805965 ... sk-DB.html). Since I'm not using the "private queue" workaround for the hot desk users, I don't really have a fixed device to monitor for my users other than a custom device I'm manipulating through dialplan magic, and FOP2 kicks a fuss if I try to tell it to use [Custom/${EXTEN}] (I fill in the substitution myself, but for example's sake...)

    Two questions:

    1. Is there a straightforward way for me to get FOP2 to monitor my users instead of a device?
    2. Is there a supported way to get FOP2 to use the login credentials out of my existing MySQL database for the hotdesking, so I can let people have the same PIN for logging into both the phones and FOP2?
    1 Reply Last reply
    0
    • N
      N
      nicolas
      wrote on last edited by
      #2

      Fop2 supports hotdesking via freepbx device&user mode, if you can replicate that in your setup, fop2 will work, the button definition will have to be

      [USER/200]

      The thing is that the mode in freepbx requires several astdb entries to be set in a kind of unorganized manner, and also userevents in the manager should be fired whenever a user logs in or out.

      Regarding the user/passwords, you can customize the autoconfig-users-freepbx.sh to your needs or write any custom script accesing any kind of database or system.

      Best regards,

      1 Reply Last reply
      0
      • D
        D
        DLNoah
        wrote on last edited by
        #3

        Okay, thank you. Does anyone have a sample of what the buttons.cfg file winds up "looking like" in device&user mode for FreePBX to give me a nudge in the right direction?

        1 Reply Last reply
        0
        • N
          N
          nicolas
          wrote on last edited by
          #4

          The button config file is easy, I posted the important part above:

          [USER/200]
          type=extension
          extension=200
          domain=from-internal
          label=John

          The hard part is to replicate the ASTDB entries and fire the proper UserEvents when a user logs in or out. I do not recall from memory, and it is not straightforward at all, it seems in FreePBX the feature was an after though or a kind of convoluted implementation, because there are several ASTDB entries to set/check.

          Here is an example entry:

          /AMPUSER/1002/device : 1002
          /DEVICE/1002/dial : SIP/john

          Whit those entries, fop2 will monitor SIP/john for USER/1002

          Then the manager userevent should have this information when a user logs in or out:

          Event: UserDeviceAdded
          Data: 1002,SIP/john

          Event: UserDeviceRemoved
          Data: 1002,SIP/john

          Best regards,

          1 Reply Last reply
          0
          • D
            D
            DLNoah
            wrote on last edited by
            #5

            Thank you very much! That worked as you said it should.

            My magics for other poor souls that might stumble across this via google or whatever...

            1. For the sake of getting up and going, I manually created /AMPUSER/EXTEN/device: EXTEN entries in my AstDB. I probably should set up some sort of bash script or something that goes through my hotdesk MySQL table and keeps the extensions up to date, but that'll be a "later" project.

            2. Within the dialplan, when a user successfully logs in, fire this dialplan logic (besides the part to log the user in). Note that ${LOCATION} is the SIP device the user logged into, and ${E} is the user's extension.

            same => n,UserEvent(UserDeviceAdded,${E},SIP/${LOCATION})
            same => n,Set(DB(DEVICE/${E}/dial)=SIP/${LOCATION})
            
            1. Within the dialplan, when a user successfully logs out, fire this dialplan logic (besides the part to log the user out). NOte that ${LOCATION} is the SIP device the user logged out of, and ${E} is the user's extension.
            same => n,UserEvent(UserDeviceRemoved,${E},SIP/${LOCATION})
            same => n,Set(LOGOUT=${DB_DELETE(DEVICE/${E}/dial)})
            
            1. Within the FOP2 config files:
              fop2.cfg:
            #exec autousers.sh
            buttonfile=autobuttons.cfg
            

            autousers.sh:

            #!/bin/bash
            DBNAME=MyDBName
            DBUSER=MyDBUser
            DBPASSWORD=MyDBPassword
            DBHOST=MyDBHost
            
            while read EXTEN PIN
            do
            	echo "user=${EXTEN}:${PIN}:all"
            done < <(mysql -h ${DBHOST} ${DBNAME} -u ${DBUSER} -p${DBPASSWORD} -se "SELECT extension, pin FROM ast_hotdesk")
            

            autobuttons.cfg:

            #exec autobuttons.sh
            *snip My Static Buttons (Queues, Trunks, etc)*
            

            autobuttons.sh:

            #!/bin/bash
            DBNAME=MyDBName
            DBUSER=MyDBUser
            DBPASSWORD=MyDBPassword
            DBHOST=MyDBHost
            
            while read EXTEN VMCONTEXT NAME
            do
            	echo "[USER/${EXTEN}]"
            	echo "type=extension"
            	echo "extension=${EXTEN}"
            	echo "context=MyContext"
            	echo "label=${NAME}"
            	echo "mailbox=${EXTEN}@${VMCONTEXT}"
            done < <(mysql -h ${DBHOST} ${DBNAME} -u ${DBUSER} -p${DBPASSWORD} -se "SELECT extension, vmcontext, cid_name FROM ast_hotdesk ORDER BY extension ASC")
            

            It's important to have cid_name last in your mysql query if you have spaces in your cid_names, otherwise the bash script will split on the space within the cid_name and everything will be messy.


            I do have two questions. I see some reference in the documentation to "when fop2 is reloaded". Is it possible to fire an event that will reload fop2 from within the Asterisk dialplan?

            Related... If I am logged into FOP2 in IE when I change the buttons config file on the server and run service fop2 restart from the server CLI, when IE "reconnects" to FOP2, it doesn't pickup the changed buttons config (and usually this winds up with the "existing" buttons being horribly messed up). Is there a way to fix this, or something I have misconfigured that is causing it?

            1 Reply Last reply
            0
            • N
              N
              nicolas
              wrote on last edited by
              #6

              Thanks for your detailed example, I am sure it will help other users!

              I do have two questions. I see some reference in the documentation to "when fop2 is reloaded". Is it possible to fire an event that will reload fop2 from within the Asterisk dialplan?

              A module reload in asterisk should trigger a FOP2 reload too.

              Related... If I am logged into FOP2 in IE when I change the buttons config file on the server and run service fop2 restart from the server CLI, when IE "reconnects" to FOP2, it doesn't pickup the changed buttons config (and usually this winds up with the "existing" buttons being horribly messed up). Is there a way to fix this, or something I have misconfigured that is causing it?

              The client is supposed to detect button configuration changes and force a reload when that happens, but now that I think of it, it might do that on reload only and not on restart. I will make some tests next monday/tuesday and try to remember to update this post with my findings.

              Best regards,

              1 Reply Last reply
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              Powered by NodeBB Contributors
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups