Diogo Ferreira

Prevent Ubuntu 20.04 from changing audio device to USB headset on boot

This was bothering me.

I'm using an wireless headset (HyperX Cloud Flight Wireless Gaming Headset) that has an USB receptor and some old Logitech speakers on my desktop, currently running Ubuntu 20.04 (in dual boot with my Windows 10).

Every time I reboot or turn on my computer and boot Ubuntu the default output audio device is set to my headset, which most of the time is off (I only use it when gaming).

Going to Settings - Sound and choosing the correct output device (Line Out) only changes it for the current session.

You can solve this by doing the following:

Edit the file default.pa:

$ sudo vim /etc/pulse/default.pa

And comment the following lines:

#.ifexists module-switch-on-connect.so
#load-module module-switch-on-connect
#.endif

Reboot. Now your computer should leave the output device you select in settings alone. My guess is that every time you turn on the computer it finds the USB receptor and change to it.

How to install Grocy with Apache on Debian 10

This took me longer than I'd like to admit, but, to be honest, their documentation is not on point.

Grocy is a web-based self-hosted groceries & household management solution for your home.

I already have a few services running on my home server, sitting behind my faithful Apache, accessible from a custom domain.

I don't want it running as a subdomain. Every explanation I found assumes that.

TL:DR: If you want Grocy running behind an Apache proxy, set it up like this:

  • Get Grocy:
$ cd /tmp
$ wget https://releases.grocy.info/latest
$ sudo unzip latest -d /var/www/html/grocy/
  • Copy the Grocy configuration file and change it to your liking:
$ sudo cp /var/www/html/grocy/config-dist.php /var/www/html/grocy/data/config.php
  • The important settings here are:
Setting('BASE_PATH', '');
Setting('BASE_URL', '/');
Setting('DISABLE_URL_REWRITING', false);

And they should be setup just like this for usage with a subdomain and Apache.

  • Create a configuration file in Apache for Grocy:
$ sudo vim /etc/apache2/sites-available/grocy.home.your-domain.pt.conf
  • Adapt the following to your configuration. The relevant part here is the DocumentRoot, and the Directory. Don't forget to set the full path to the Grocy public folder :
<VirtualHost *:80>
    ServerName grocy.home.your-domain.pt
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/grocy/public
    ErrorLog /var/log/apache2/grocy-error.log
    CustomLog /var/log/apache2/grocy-access.log combined

<Directory /var/www/html/grocy/public>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
</VirtualHost>
  • Enable the site:
$ sudo a2ensite grocy.home.your-domain.pt
  • Reload Apache:
$ sudo systemctl reload apache2

And your instance if running on http://grocy.home.your-domain.pt!

I've made a few assumptions here (you have your own local domain, have Apache already setup with PHP, etc), but I hope is helpful to someone.

Maybe later I'll update this post with a more detailed explanation.

Unblock LDAP or Active Directory user in GitLab

If you're running a self-hosted GitLab instance and use LDAP or Active Directory authentication you may notice that sometimes users get "Blocked" and you can't unblock them using the web interface.

When this situation occurs, you can unblock them using the gitlab-rails console directly in the server.

Run the following:

$ gitlab-rails console production

And then inside the console you can find the user by email and set it to "Active" like this:

> user = User.find_by_email("[USER-EMAIL]")
> user.state = "active"
> user.save
> exit

Replace [USER-EMAIL] with the actual email you're looking for. The user should now be active and ready to login.

How to install Pi-hole with Apache on CentOS 7

Installing Pi-hole on a CentOS 7 server (instead of a dedicated machine like a Raspberry Pi) is an option that the fine gentlemen who developed it gave us. Since I already had a server ready with Apache, I took that route.

I have a small Optiplex 3040 that I use as my home server (you can read more about what I use here) and decided that I’ve had enough with ads showing up on my devices. On my desktop and laptop I use uBlock Origin but my other devices don’t have that luck. Enter Pi-hole!

It’s actually quite easy to install it using Apache (the default setup is even easier, and well documented). It goes like this:

  • Setup your server with a static IP. That is out of the scope of this post but you can find out instructions for CentOS 7 here.
  • Run the install script as root: curl -sSL https://install.pi-hole.net | bash.
  • If you got the chills from the previous command, I understand perfectly. You shouldn’t run scripts directly from the internet. Check the script before you do it. You can find it here.
  • The relevant question of the script is if you want to install the lighttpd web server. You should answer *no* at this step.
  • Now that the setup is over, proceed to install Apache and some necessary software for Pi-hole: yum install httpd php php-pdo.
  • Edit the file /etc/sudoers.d/pihole and replace lighttpd with apache.
  • Set SELinux to permissive (unfortunately it seems that Pi-hole doesn’t work too well with it). You shouldn’t do this if you don’t trust the security of your server or your network. Edit the file /etc/sysconfig/selinux and replace enforcing with permissive.
  • That should do it! Reboot your server just to ensure everything is fine and go to http://YOUR_STATIC_IP/admin to check your new Pi-hole installation.

There are a few more things you can do, like setting up a Name-based Virtual Host:

  • Create a new configuration file on /etc/httpd/conf.d/router.home.example.com.conf

Insert the following example (adapt it to your use):

<VirtualHost *:80>
ServerName router.home.example.com
DocumentRoot /var/www/html/admin
</VirtualHost>

Restart the Apache daemon:

systemctl restart httpd

You should now be able to access your Pi-hole dashboard using the name router.home.example.com. This assumes you have your own DNS Server at home. I’ll make a post about setting up one, but for now, you can look here for instructions.

Running Steam on Debian using an Nvidia graphics card

If you’re running Steam on Debian using an Nvidia graphics card, you’ll probably run into this error when you’re starting Steam for the first time:

You are missing the following 32-bit libraries, and Steam may not run:
libGL.so.1

To solve it just install the following package:

# apt install libgl1-nvidia-glx:i386

Steam should now start without complaining.

This happened to me in Debian Sid, but I’ll assume it’s the same procedure for the stable version.

Edit #1: As of today, 02/10/2020, on Debian Sid, you have to run the following command instead:

# apt install libglx-nvidia0:i386

Edit #2: As of today, 22/10/2020, on Debian Sid, you also have to run the following command:

# apt install libgl1-nvidia-glvnd-glx:i386