miércoles, 20 de enero de 2021

Ubuntu 20.04 Focal - Final makeups

Hi,

Here's a small list of personal tweaks applied after an upgrade from 18.04 Bionic to 20.04 Focal:

apt install kde-plasma-desktop

apt install plasma-nm

# Migrate networkd to NetworkManager in 5 steps

nano /etc/netplan/01-netcfg.yaml

netplan generate

netplan apply

systemctl daemon-reload

systemctl restart netplanXXX

# Disable/hide default virtual keyboard of vanilla SDDM

echo 'InputMethod=' >> /etc/sddm.conf

# reboot

# Disable/stop baloo_file

printf '\n[Basic Settings]\nIndexing-Enabled=false\n' >> .config/baloofilerc

# SDDM Theme : Sugar Candy :: Some minor tweaks

nano /usr/share/sddm/themes/sugar-candy/theme.conf.user


Hope you like it!

lunes, 28 de diciembre de 2020

Minimal Ubuntu 18.04 on Aspire One Cloudbook

 Hi,

Here's a cookbook of tips to setup a Aspire One Cloudbook 14 with a minimal (but usable for your parents) Ubuntu.

  1. Setup the BIOS
    1. Press F2 when the Acer logo appears, and then change the EFI system to legacy.
    2. Reboot and then press F12 when the logo appears (to choose the installing media).
  2. Installation. I have selected a Lubuntu 18.04 installation but it's not a critical choice. More on this onwards.
    1. When prompted, specify the following options for the partitions: discard (as the Cloudbook 14 has a eMMC drive) and noatime.
    2. When prompted, install nothing but "OpenSSH Server" (as it won't be a standard desktop)
  3. After-install setup
    1. Update the dependencies with apt update && apt upgrade.
    2. In other linux machine, download and compile a recent kernel (currently 5.10.3):
      1. make clean menuconfig; make -j $(nproc);
      2. make bindeb-pkg # as we're going to scp the generated kernel to the aspire1
        In the parent directory there'll be a "linux-image-5.10.3*.deb" file
    3. In the Cloudbook, scp the remote .deb file into local (i.e. scp john@remotelinux:/tmp/linux-image-5.10.3*.deb .)
    4. Install it with sudo apt install ./linux-image-5.10.3*.deb and reboot.
    5. Now you're running with the latest trouble-free kernel.
    6. Additional installations:
      1. apt install python x11-utils x11-apps xinit xterm xinput xserver-xorg-input-synaptics openbox firefox pm-utils
      2. (optional) apt install lxterminal.
    7. Try the X system with the command xinit. Everything should be fine here: an xterm window is ready and the trackpad clicks perfectly.
      If you exit the terminal window you'll be back to the console.
    8. Prepare the graphical system to launch automatically the browser with (remember it's targeted to your parents) echo 'openbox & firefox' > $HOME/.xinitrc

Hope you like it!

sábado, 23 de mayo de 2020

Working like WSL2 (without having it)

TL;DR

Here is an approach to work with a non-WSL Linux guest (with VirtualBox or VmWare) and launching native Windows commands (f.e. MS Office Excel)

--

Hi all,

Some people have WSL2. Some people not, like me, and we are in the middle-of-nowhere with WSL1, as we are not able to do real stuff with Docker, Kubernetes, and so on, because WSL1 lacks the needed capabilities that a real Linux kernel has, so the only solution (see rants section below) is to stick with VirtualBox (or VmWare if you prefer) and work isolated from Windows apps.

But here's a way to overcome such limitations.

The idea is to run a small agent in the Windows side (the host) that will be capable of running whatever command you send from the Linux side (the guest).

In order to do that, you'll need:
  • Windows:
    • Java 11 (https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot)
    • Groovy (https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.4.zip)
  • Linux:
    • Netcat

Once you have them installed, you'll have to do:

1. Create the agent in Groovy

Create a file (f.e. c:\GroovySocketServer1070.groovy) with the following content:

new groovy.ui.GroovySocketServer (new GroovyShell(), // false"println line.execute().text", // true1070);

That's all: A poor-man's telnet server written in three lines of Groovy, that will execute whatever command it receives at port 1070!
There's a caveat: If there's an error it will be lost, as STDERR is not captured.

You can run the agent  with a command like (the paths must reflect the exact locations of the Java and Groovy installations) this:

C:\>PATH=C:\p\groovy-3.0.4\bin;C:\p\jdk-11\bin;%PATH% C:\>groovy C:\GroovySocketServer1070.groovy


2. Launch the commands from Linux

From the Linux guest you can launch any Windows program like this:

$ echo "C:\\Windows\\System32\\cmd.exe /C dir" | nc -N 10.0.2.2 1070 $ echo "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE" | nc -N realhost 1070 &

Bonus point: The GroovySocketServer allows multiple concurrent executions (so you don't have to wait for the termination of other commands)!

Sweet and easy: You can execute any host program from the guest.

Hope you like it!

Rants

domingo, 20 de mayo de 2018

EXT4 virtual disk optimization (2nd edition)

Hi,

Following the previous post, if you want to create a brand-new ext4 filesystem with most of the performance settings activated, you can do it this way:

# mkfs
mkfs.ext4 -T news -m 1 -I 128 -v -O "^has_journal,^dir_index,^dir_nlink,^huge_file,^metadata_csum,^quota" /dev/sda1
# tune2fs
tune2fs -o "journal_data_writeback,^user_xattr,^acl,nobarrier,discard" /dev/sda1
And then, in the /etc/fstab file you can use the following mount-point parameters:
# /etc/fstab
noacl,nouser_xattr,async,noatime,data=writeback,barrier=0,nobh,commit=1234567,inode_readahead_blks=2,delalloc,discard


ALERT
No implicit nor explicit warranty of any kind is stated here. These commands and/or settings may cause data loss. Use them wisely at your own risk!

lunes, 31 de julio de 2017

EXT4 virtual disk optimization

Hi all,

These are my tweaks in order to squeeze the performance of a EXT4 virtual disk (in example /dev/sdb1).

ALERT
No implicit nor explicit warranty of any kind is stated here. These commands and/or settings may cause data loss. Use them wisely at your own risk!

tune2fs -o journal_data_writeback /dev/sdb1
tune2fs -O ^has_journal /dev/sdb1
sudo e2fsck -f /dev/sdb1
#
tune2fs -o ^user_xattr /dev/sdb1
tune2fs -o ^acl /dev/sdb1
tune2fs -o nobarrier /dev/sdb1
tune2fs -o discard /dev/sdb1
#
tune2fs -O ^dir_index /dev/sdb1
tune2fs -O ^dir_nlink /dev/sdb1
tune2fs -O ^huge_file /dev/sdb1
tune2fs -O ^metadata_csum /dev/sdb1
tune2fs -O ^quota /dev/sdb1
tune2fs -r 0 /dev/sdb1
#

dumpe2fs /dev/sdb1 | less


References and Kudos:

  1. https://developer.ridgerun.com/wiki/index.php/High_performance_SD_card_tuning_using_the_EXT4_file_system

sábado, 1 de abril de 2017

JSF 2.1 within embedded Tomcat 8 (2017)

This post relates about configuring the following aspects to get a working JSF 2.1 application:
  • Maven 3
  • JSF 2.1.7
  • Embedded Tomcat 8

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>eu.altotek</groupId>
 <artifactId>spa-jsf-generator</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <name>spa-jsf-generator Maven Webapp</name>
 <url>http://maven.apache.org</url>

 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
  <java.version>1.8</java.version>

  <jsf.version>2.1.7</jsf.version>
  <jsp-api.version>2.2.1-b03</jsp-api.version>

  <tomcat.version>8.0.28</tomcat.version>
 </properties>

 <dependencies>
  <!-- JSF -->
  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-api</artifactId>
   <version>${jsf.version}</version>
   <scope>runtime</scope>
  </dependency>
  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-impl</artifactId>
   <version>${jsf.version}</version>
   <scope>runtime</scope>
  </dependency>

  <!-- Java standards -->
  <dependency>
   <groupId>org.glassfish.web</groupId>
   <artifactId>el-impl</artifactId>
   <version>2.2</version>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
  </dependency>
  <dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>${jsp-api.version}</version>
  </dependency>

  <!-- Tomcat -->
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-core</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-logging-juli</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-jasper</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jasper</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jasper-el</artifactId>
   <version>${tomcat.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>tomcat-jsp-api</artifactId>
   <version>${tomcat.version}</version>
  </dependency>

  <!-- Testing -->
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.12</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
 <build>
  <finalName>spa-jsf-generator</finalName>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin.version}</version>
    <configuration>
     <source>${java.version}</source>
     <target>${java.version}</target>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>

web.xml

<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">

 <context-param>
  <param-name>javax.faces.PROJECT_STAGE</param-name>
  <param-value>Development</param-value>
 </context-param>

 <welcome-file-list>
  <welcome-file>/jsf/home.jsf</welcome-file>
 </welcome-file-list>

 <listener>
  <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>

 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>

</web-app>

Main.java

package eu.altotek.spa_jsf_generator;

import java.io.File;

import org.apache.catalina.WebResourceRoot;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.DirResourceSet;
import org.apache.catalina.webresources.StandardRoot;

public class Main {

 public static void main(final String[] args) throws Exception {

  final String webappPath = new File("src/main/webapp").getAbsolutePath();
  final Tomcat tomcat = new Tomcat();

  final StandardContext ctx = (StandardContext) tomcat.addWebapp("/", webappPath);

  // Declare an alternative location for your "WEB-INF/classes" dir
  // Servlet 3.0 annotation will work
  final String targetClassesPath = new File("target/classes").getAbsolutePath();
  final WebResourceRoot resources = new StandardRoot(ctx);
  resources.addPreResources(new DirResourceSet(//
    resources, "/WEB-INF/classes", //
    targetClassesPath, "/"));
  ctx.setResources(resources);

  tomcat.start();
  tomcat.getServer().await();
 }
}

webapp/jsf/home.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JSF Tutorial!</title>
</head>

<body>
#{helloWorld.message}
</body>
</html>

HelloWorld.java

package eu.altotek.spa_jsf_generator.jsf;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HelloWorld {

 public HelloWorld() {
  System.out.println(this + "started!");
 }

 public String getMessage() {
  return "Hello " + this;
 }
}

References & kudos

  • https://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/
  • http://musingsofaprogrammingaddict.blogspot.com.es/2009/12/running-jsf-2-on-embedded-jetty.html
  • https://www.mkyong.com/jsf2/jsf-2-0-tomcat-it-appears-the-jsp-version-of-the-container-is-older-than-2-1/
  • https://www.tutorialspoint.com/jsf/jsf_first_application.htm
  • http://alexgorbatchev.com/SyntaxHighlighter/

viernes, 15 de enero de 2016

Instalación paso a paso de Linux Mint 17 via PXE/Netboot

Hola,

Después de un breve descanso, he querido instalar un linux en un portátil un poco antiguo, y la distrubución escogida ha sido Linux Mint 17.3 (Rosa).

Aquí están las instrucciones para hacer una instalación desde red (mediante PXE+dnsmasq+TFTP+NFS) :

NOTA: Hay que cambiar la IP 192.168.0.159 por la tuya!!

sudo bash
apt-get install dnsmasq nfs-kernel-server nfs-common syslinux

# archivos
mkdir -p /srv/tftp/pxelinux.cfg
ln -s /cdrom /tmp/cdrom

# dhcp/tftp
cat <<EOF > /srv/tftp/pxelinux.cfg/default
DEFAULT /cdrom/casper/vmlinuz
KERNEL cdrom/casper/vmlinuz
APPEND ip=dhcp netboot=nfs boot=casper root=/dev/nfs nfsroot=192.168.0.159:/tmp/cdrom/ initrd=/cdrom/casper/initrd.lz splash --
EOF

cat <<EOF >> /etc/dnsmasq.conf

interface=eth0
dhcp-range=192.168.0.240,192.168.0.250,1h
dhcp-boot=pxelinux.0,mint,192.168.0.159
enable-tftp
tftp-root=/srv/tftp
EOF
service dnsmasq restart

# nfs
cat <<EOF >> /etc/exports

/tmp/cdrom       *(ro,sync,fsid=0,no_subtree_check)
EOF
service nfs-kernel-server restart ; exportfs -a

A disfrutar!