Thursday, 13 December 2018

Making your labtop battery last longer in Linux

So I went to Devoxx in Belgium, and I took my labtop along. Of course, it's in a Cinema, so there's no electrical sockets in the rooms.

I was looking to prolong the use of my labtop, so I was looking for extend the battery life.

There were several good articles about it (see below in the references.)

I choose to install the Xfce Desktop Environment, and I was pleasantly surprised my labtop managed to hold together for a lot longer.

Fedora has some notes on how to install it, it's basically running the package manager properly, and it's done.

It can be selected from the dropdown menu on the login screen.

I shall put the command line down here, so I do not forget:

sudo dnf install tlp tlp-rdw
sudo systemctl enable tlp

References

FOSS Post - 7 Tips to Reduce Battery Usage on Linux
https://fosspost.org/tutorials/7-tips-to-reduce-battery-usage-on-linux
Xfce Desktop Environment
https://www.xfce.org/
LXDE Desktop Environment for All
https://lxde.org/
Openbox - minimalistic window manager
http://openbox.org/wiki/Main_Page
Xfce In Fedora
https://fedoraproject.org/wiki/Xfce

Thursday, 6 December 2018

Adding MariaDB JDBC Connector to Wildfly 14

  1. install the database driver as a module
    1. create directory WILDFLY_HOME/modules/com/mariadb/main
      $ mkdir -p modules/com/mariadb/main
    2. copy database driver into that one
      $ cp ~/Downloads/mariadb-java-client-2.3.0.jar .
    3. Create the file module.xml in the same folder with the following content:
      <module xmlns="urn:jboss:module:1.3" name="com.mariadb">
          <resources>
              <resource-root path="mariadb-java-client-2.3.0.jar"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
  2. start Wildfly
    $ cd $WILDFLY_HOME/bin
    $ ./standalone.sh
  3. connect to http://localhost:9990/error/index.html
  4. run ./add-user.sh
    [mrbear@localhost bin]$ ./add-user.sh 

    What type of user do you wish to add? 
     a) Management User (mgmt-users.properties) 
     b) Application User (application-users.properties)
    (a): a

    Enter the details of the new user to add.
    Using realm 'ManagementRealm' as discovered from the existing property files.
    Username : mrbear
    Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
     - The password should be different from the username
     - The password should not be one of the following restricted values {root, admin, administrator}
     - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
    Password : 
    Re-enter Password :  
    What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: 
    About to add user 'mrbear' for realm 'ManagementRealm'
    Is this correct yes/no? yes
    Added user 'mrbear' to file '/home/mrbear/wildfly-14.0.1.Final/standalone/configuration/mgmt-users.properties'
    Added user 'mrbear' to file '/home/mrbear/wildfly-14.0.1.Final/domain/configuration/mgmt-users.properties'
    Added user 'mrbear' with groups  to file '/home/mrbear/wildfly-14.0.1.Final/standalone/configuration/mgmt-groups.properties'
    Added user 'mrbear' with groups  to file '/home/mrbear/wildfly-14.0.1.Final/domain/configuration/mgmt-groups.properties'
    Is this new user going to be used for one AS process to connect to another AS process? 
    e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
    yes/no? no
  5. click on "Try again" on the Website
  6. log on with the new added user
  7. Configuration - Subsystems - Datasources and drivers - JDBC drivers - [+]
  8. Fill out the following information:
    Driver namemariadb
    Driver Module Namecom.mariadb
    Module Slot
    Driver Class Nameorg.mariadb.jdbc.Driver
    Drive Datasource Class Name
    Driver XA Datasource Class Name
  9. Configuration - Subsystems - Datasources and drivers - Datasources - [+]
  10. Select "Add Datasource" to add a non-XA Datasource
  11. Select "Custom" template
  12. Attributes:
    Name[name]
    JNDI Namejava:/jdbc/[name]
  13. JDBC Driver
    Driver Namemariadb
    Driver Module Name[empty]
    Driver Class Name[empty]
  14. Connection:
    Connection URLjdbc:mariadb://localhost:3306/[databasename]
    User nameroot
    Passworditsasecret
    Security Domain[empty]
  15. Test connection
  16. Reload of server required - so reload the server
  17. Test connection: Successfully tested connection for datasource [name].

References

JDBC Driver / DataSource Setup
https://hal.gitbooks.io/dev/content/recipes/jdbc-driver-setup.html
About MariaDB Connector/J
https://mariadb.com/kb/en/library/about-mariadb-connector-j/
GitHub - Use MariaDB Connector/J Driver
https://github.com/MariaDB/mariadb-connector-j/blob/master/documentation/use-mariadb-connector-j-driver.creole
IronJacamar 1.1 - Userguide - Deploying DS Descriptor
http://www.ironjacamar.org/doc/userguide/1.1/en-US/html_single/index.html#deployingds_descriptor