Appendix A. Tools (Advanced)

Table of Contents

Server Commands (server-command)
Available Commands
Database Tool (db-tools)
export-db Command
import-db Command
init-db Command
delete-old-logs Command
The XML Web Services API
Web Services Example Code
Security
SSL/HTTPS Key Generation
Using a custom SSL Key
User Client Options
Stopping and Starting the Application Server
Stopping/Starting the server on Windows
Automating / Streamlining Installation on Windows

This appendix outlines the command line tools and advanced programming tools that come with PaperCut NG. Using these tools has been discussed throughout this manual, however this provides a reference guide to these tools and their use.

Caution

The advanced tools provided with PaperCut NG are very powerful and offer opportunities for all manner of customizations and enhancements. However, if used incorrectly, these tools could lead to unexpected results. Many of the advanced tools are written for software and script developers. It is expected that readers intending to use advanced tools are comfortable with using the command-prompt, and developing system management and server monitoring programs.

Server Commands (server-command)

The server-command tool provides access to dozens of server operations ranging from user management, system maintenance, account manipulation and printer control. The server-command tool is ideal for controlling the PaperCut NG Application Server via the command-line or automating via scripts.

Some examples of how an Administrator may choose to use the server-command tool:

  • Scheduling of online backups and data snapshots.

  • Scheduling user and/or group synchronization tasks.

  • Automating the addition of new users after the accounts are added to the network.

  • Performing account transactions such as adding funds/quota to user accounts.

  • Automating user account creation using custom scripts.

  • Disabling/Enabling printers.

  • Disabling/Enabling printing for users.

  • Controlling user restriction levels.

  • Managing shared accounts.

The server-command program is a command-line tool. It accepts the commands as arguments and outputs the results of the command on the console (standard-out). For security reasons only users with read access to the server.properties (normally only the Administrators group) have rights to execute the commands.

Typical use on a Windows system:

Add $10.00 to a user named 'testuser':

    C:\> cd [app-dir]\server\bin\win
    C:\> server-command adjust-user-account-balance "testuser" 10.00 \
        "Added $10.00 to your account"
            

Note: backslash indicates text should be on the same line.

Available Commands

A full list of commands is available via server-command --help.

Usage: server-command COMMAND [ARGS...]

   COMMAND  : The server command name.
   ARGS     : A list of arguments to supply to the command.

COMMANDS: 
    user-exists <username>
        Test to see if a user exists.
        <username> - the username to test.

    get-user-account-balance <username>
        Get a user's current account balance.
        <username> - the user's username.

    get-user-property <username> <property>
        Gets a user property.
        <username> - the name of the user.
        <property> - the name of the property to get. Valid properties include:
            balance - the user's current account balance
            card-number - the user's card number
            department - the user's department
            disabled-net - whether or not the user's internet access is
                           currently disabled
            disabled-print - whether or not the user's printing is currently
                             disabled
            email - the user's email
            full-name - the user's full name
            notes - notes for the user
            office - the user's office
            print-stats.job-count - the total print job count for the user
            print-stats.page-count - the total printed page count for the user
            restricted - whether or not the user is currently restricted

    set-user-property <username> <property> <value>
        Sets a user property.
        <username> - the name of the user.
        <property> - the name of the property to set. Valid properties and
                     values include:
            balance - the user's current account balance (a decimal number)
            card-number - the user's card number (any text)
            department - the user's department (any text)
            disabled-net - whether or not the user's internet access is
                           currently disabled (TRUE or FALSE)
            disabled-print - whether or not the user's printing is currently
                             disabled (TRUE or FALSE)
            email - the user's email (an email address, or any text)
            full-name - the user's full name (any text)
            notes - notes for the user (any text)
            office - the user's office (any text)
            restricted - whether or not the user is currently restricted
                         (TRUE or FALSE)
        <value> - the value to set (see <property> for valid values).

    adjust-user-account-balance <username> <adjustment> <comment>
        Adjust a user's account balance.
        <username> - the user's username.
        <adjustment> - the adjustment amount as a number. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    adjust-user-account-balance-if-available <username> <adjustment> <comment>
        Adjust a user's account balance if there is enough credit available.
        <username> - the user's username.
        <adjustment> - the adjustment amount as a number. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    adjust-user-account-balance-if-available-leave-remaining \
                     <username> <adjustment> <leave-remaining> <comment>
        Adjust a user's account balance if there is enough credit available
        to leave the given amount available in the account.
        <username> - the user's username.
        <adjustment> - the adjustment amount as a number. +ve or -ve.
        <leave-remaining> - the amount to leave in the account.
        <comment> - a comment to be associated with the transaction.

    adjust-user-account-balance-by-group <group> <adjustment> <comment>
        Adjust the account balance for all users in a group.  This process 
        happens in the background.
        <group> - the group for which all users' accounts are to be adjusted.
        <adjustment> - the adjustment amount as a number. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    adjust-user-account-balance-by-group-up-to <group> <adjustment> <limit>
                                               <comment>
        Adjust the account balance for all users in a group, but don't increase
        user balance beyond the given limit.  This process happens in the
        background.
        <group> - the group for which all users' accounts are to be adjusted.
        <adjustment> - the adjustment amount as a number. +ve or -ve.
        <limit> - don't increase user balance beyond this limit.
        <comment> - a comment to be associated with the transaction.

    set-user-account-balance <username> <balance> <comment>
        Set a user's account balance to a set value.
        <username> - the user's username.
        <balance> - set the account to this value. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    set-user-account-balance-by-group <group> <balance> <comment>
        Set the balance for each member of a group to the given value.  This 
        process happens in the background. 
        <group> - the group for which all users' balance is to be set.
        <balance> - the value to set all users' balance to. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    reset-user-counts <username> <reset_by>
        Reset the page and job counts associated with a user.
        <username> - the user's username.
        <reset_by> - name of the user/script/process resetting the counts.

    disable-printing-for-user <username> <minutes_disabled>
        Disable printing for a user for a set period of time.
        <username> - the name of the user to disable printing for.
        <minutes_disabled> - the time in minutes to disable. -1 indicates 
        forever.

    add-new-user <username>
        Trigger the process of adding a new user account. Assuming the user 
        exists in the OS/Network/Domain user directory, the account will be 
        created with the correct initial settings as defined by the rules 
        set up in the admin interface under the Groups section.
        <username> - the user's system username.

    rename-user <current_username> <new_username>
        Rename the given existing user. Use this method with care. Renaming a
        user should be performed in conjunction with renaming the user in the
        OS/Network/Domain.
        <current_username> - the name of the user to rename.
        <new_username> - the user's new name.

    delete-existing-user <username>
        Delete a user account from the system.  Use this method with care. 
        Calling this will perminantly delete the user account from the user 
        list (print history records remain).
        <username> - the user's system username.

    list-user-accounts
        List the names of all the user accounts in the system, sorted by
        username, one per line.


    shared-account-exists <account_name>
        Test to see if a shared account exists.
        <account_name> - the shared account name to test.

    get-shared-account-account-balance <account_name>
        Get shared account's current account balance.
        <account_name> - the shared acount's full name.
    
    get-shared-account-property <account_name> <property>
        Gets a shared account property.
        <account_name> - the name of the user.
        <property> - the name of the property to get. Valid properties include:
            access-groups - the shared account's access groups)
                            (a comma separated list)
            access-users - the shared account's access users
                           (a comma separated list)
            balance - the shared account's current balance
            comment-option - the shared account's commenting option
            disabled - whether or not the shared account is currently disabled
            invoice-option - the shared account's invoicing option
            notes - notes for the shared account
            pin - the shared account's PIN
            restricted - whether or not the shared account is currently
                         restricted

    set-shared-account-property <account_name> <property> <value>
        Sets a shared account property.
        <account_name> - the name of the shared account.
        <property> - the name of the property to set. Valid properties and
                     values include:
            access-groups - the shared account's access groups)
                            (a comma separated list)
            access-users - the shared account's access users
                           (a comma separated list)
            balance - the shared account's current balance (a decimal number)
            comment-option - the shared account's commenting option. One of:
                NO_COMMENT - no comment may be entered
                COMMENT_REQUIRED - a comment must be entered
                COMMENT_OPTIONAL - the user may enter a comment or not
            disabled - whether or not the shared account is currently disabled
                       (TRUE or FALSE)
            invoice-option - the shared account's invoicing option. One of:
                ALWAYS_INVOICE - print jobs will always be invoiced
                NEVER_INVOICE - print jobs will never be invoiced
                USER_CHOICE_ON - the user can choose (default on/yes)
                USER_CHOICE_OFF - the user can choose (default off/no)
            notes - notes for the shared account (any text)
            pin - the shared account's PIN (any text, must be unique)
            restricted - whether or not the shared account is currently
                         restricted (TRUE or FALSE)
        <value> - the value to set (see <property> for valid values).

    adjust-shared-account-account-balance <account_name> <adjustment> <comment>
        Adjust a shared account's account balance.
        <account_name> - the shared account's full name.
        <adjustment> - the adjustment amount as a number. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    set-shared-account-account-balance <account_name> <balance> <comment>
        Set a shared account's balance to a set value.
        <account_name> - the shared account's full name.
        <balance> - set the account to this value. +ve or -ve.
        <comment> - a comment to be associated with the transaction.

    add-new-shared-account <shared_account_name>
        Add a new shared account.
        <shared_account_name> - the name of the shared account.

    delete-existing-shared-account <shared_account_name>
        Delete a shared account from the system.  Use this method with care.
        Calling this will permanently delete it from the shared account list
        (print history records will remain).
        <shared_account_name> - the name of the shared account to delete.

    add-shared-account-access-user <shared_account_name> <username>
        Allow the given user access to the given shared account without using
        a pin.
        <shared_account_name> - the name of the shared account to allow access
                                to.
        <username> - the name of the user to give access to.

    add-shared-account-access-group <shared_account_name> <group_name>
        Allow the given group access to the given shared account without using
        a pin.
        <shared_account_name> - the name of the shared account to allow access
                                to.
        <group_name> - the name of the group to give access to.

    remove-shared-account-access-user <shared_account_name> <username>
        Revoke the given user'- access to the given shared account.
        <shared_account_name> - the name of the shared account to revoke access
                                to.
        <username> - the name of the user to revoke access for.

    remove-shared-account-access-group <shared_account_name> <group_name>
        Revoke the given group's access to the given shared account.
        <shared_account_name> - the name of the shared account to revoke access
                                to.
        <group_name> - the name of the group to revoke access for.


    get-printer-property <server_name> <printer_name> <property>
        Gets a printer property.
        <server_name> - the name of the server the printer is hosted on.
        <printer_name> - the name of the printer.
        <property> - the name of the property to get. Valid properties include:
            disabled - whether or not the printer is currently disabled

    set-printer-property <server_name> <printer_name> <property> <value>
        Sets a printer property.
        <server_name> - the name of the server the printer is hosted on.
        <printer_name> - the name of the printer.
        <property> - the name of the property to set. Valid properties and
                     values include:
            disabled - whether or not the user is currently disabled
                       (TRUE or FALSE)
        <value> - the value to set (see <property> for valid values).

    reset-printer-counts <server_name> <printer_name> <reset_by>
        Reset the page and job counts associated with a printer.
        <server_name> - the name of the server hosting the printer.
        <printer_name> - the printer's name.
        <reset_by> - name of the user/script/process resetting the counts.

    disable-printer <server_name> <printer_name> <minutes_disabled>
        Disable a printer for a set period of time.
        <server_name> - the name of the server hosting the printer.
        <printer_name> - the printer's name.
        <minutes_disabled> - the time in minutes to disable. -1 indicates 
        forever.

    use-card <user_name> <card_number>
        Redeem a card and place the credit on the user's account.
        <user_name> - the name of the user with the account to credit.
        <card_number> - the number of the card to use.

    perform-online-backup
        Start an online backup.  The back file is written to 
        ~/server/data/backups. as a dated, zipped XML file. This process 
        happens in the background.

    perform-group-sync
        Start the process of synchronizing the system's group membership with 
        the OS/Network/Domain's group membership. This process happens in the 
        background.

    perform-user-and-group-sync
        Start a full user and group synchronization. This is equivalent to 
        pressing on the "Synchronize Now" button in the admin user interface. 
        The of the sync process, such as deleting old users, is 
        determined by the current system settings as defined in the admin 
        interface. This process happens in background.

    perform-user-and-group-sync-advanced <delete_old_users> <update_details>
        An advanced version of the user and group syncronization process  
        providing control over the sync  This process will happen in 
        the background.
        <delete_old_users> - set to TRUE remove old users, else FALSE.
        <update_details> - set to TRUE if exist users details (e.g. email, 
                           full-name, etc. ) are to be updated.

    add-new-users
        Calling this method will start a specialized user and group  
        synchronization process optimized for tracking down adding any new 
        users that exist in the OS/Network/Domain user directory and not in 
        the system. Any existing user accounts will not be modified. A group 
        syncronization will only be performed if new users are actually added 
        to the system.

    batch-import-shared-accounts <import_file> <test>
                                 <delete_non_existent_accounts>
        Import the shared accounts contained in the given tab-delimited import
        file.
        <import_file> - the import file location relative to the application
                        server.
        <test> - If true, perform a test only. The printed statistics will show
                 what would have occurred if testing wasn't enabled. No accounts
                 will be modified.
        <delete_non_existent_accounts> - (true or false) If true, accounts that
                             do not exist in the import file but exist in the
                             system will be deleted.  If false, they will be
                             ignored.

    get-config <config-name>
        Gets the value of the given config value printing the result.
        If the config value does not exist, a blank string is displayed.
        <config-name> - the name of the config value to get.

    set-config <config-name> <config-value>
        Sets the value of the give config item.
        NOTE: Take care updating config values. You may cause serious
              problems which can only be fixed by reinstallation of
              the application. Use the set-config command at your own risk.
        <config-name> - the name of the config value to set.
        <config-value> - the value to set.
                

Tip

server-command is ideal for scripting via batch files or shell scripts. Administrators wishing to control PaperCut NG using a programming language such as C#, Java, Visual Basic, Perl, Ruby or Python should consider the XML Web Services API's. All commands available via the server-command tool are also accessible via calls to the Web Services layer.

More information on the XML Web Services API is available in the section called “The XML Web Services API”.