Split Tunnels for WARP client

If my PC was left connected to Cloudflare WARP, I would not be able to remote access it via Splashtop from an external location. Also Dropbox is blocked when connected. The way I solved this is to add Split Tunnels in the Cloudflare backend to bypass domains used by Dropbox and Splashtop.

*.dropbox.com
*.dropboxusercontent.com
*.dropboxapi.com
*.dropboxstatic.com
*.api.splashtop.com
*.relay.splashtop.com

Turning cache off for specific files

Today I wanted to solve the issue of caching on the email signature banners once and for all. I don’t want any browsers or email clients to cache the image, so I started searching for solutions.

The best one I could find was this one:

<Files {FILENAME}>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Files>

So specifically to stop caching on the email signature file, I created an .htaccess file containing this:

<Files emailsignature.gif>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Files>

And saved the file here:

windeurope.org/wp-content/uploads/images/banners/.htaccess

Allowing sudo command

How to Add Users to Sudo Group

By default, Redhat-based linux has a user group called the “wheel” group. Members of the wheel group are automatically granted sudo privileges. Adding a user to this group is a quick and easy way to grant sudo privileges to a user.

Step 1: Verify the Wheel Group is Enabled

Your CentOS 7 installation may or may not have the wheel group enabled.

Open the configuration file by entering the command:

visudo

Scroll through the configuration file until you see the following entry:

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

If the second line begins with the # sign, it has been disabled and marked as a comment. Just delete the # sign at the beginning of the second line so it looks like the following:

%wheel        ALL=(ALL)       ALL

Then save the file and exit the editor.

Step 2: Add User to Group

To add a user to the wheel group, use the command:

usermod -aG wheel NewUser

As usual, replace NewUser with the name of the user receiving sudo privileges.

 


 

If the above doesnt work: Add User to Sudoers Configuration File

If there’s a problem with the wheel group, or administrative policy prevents you from creating or modifying groups, you can add a user directly to the sudoers configuration file to grant sudo privileges.

Step 1: Open the Sudoers File in an Editor

In the terminal, run the following command:

visudo

This will open the /etc/sudoers file in a text editor.

Step 2: Add the New User to File

Scroll down to find the following section:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL

Right after this entry, add the following text:

NewUser ALL=(ALL) ALL

Replace NewUser with the username you created in Step 2. This section should look like the following:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
NewUser ALL=(ALL) ALL

Save the file and exit.

Find tables without primary keys

Some plugins create tables in MYSQL without primary keys which may break exporting and importing actions.

We can identify where exactly with this SQL script:

SELECT
t.TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES AS t
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS k
ON (
t.TABLE_NAME = k.TABLE_NAME
AND k.CONSTRAINT_SCHEMA = t.TABLE_SCHEMA
AND k.constraint_name = 'PRIMARY'
)
WHERE
t.TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys')
AND t.TABLE_SCHEMA = 'database name' -- put database name here
AND k.constraint_name IS NULL;

Delete all your Tweets at once

If you have a big Twitter account and you want to completely delete all your old tweets in one go, here is how to do it:

Tutorial: How to delete all your Tweets for free (code and userscript in comments)
byu/lucahammer inTwitter

  1. Log into your Twitter account.
  2. Export your Twitter data archive.
    How to: https://twitter.com/settings/download_your_data
    (It may take 1-2 days depending on the volume of your data)
  3. Unzip the file after downloading and locate a file called tweet-headers.js.
  4. Copy script from https://gist.github.com/lucahammer/a4d1e957ec9e061e3cccafcbed599e16#file-tweetxer-js
  5. Back on your Twitter profile page, hit F12, then select the Console tab.
  6. Type “allow pasting” and hit enter.
  7. Then paste the script from Step 4 and hit enter.
  8. Select tweet-headers.js from Step 3.
  9. Watch all your tweets being deleted one by one.

/boot partition is full

On some of our servers, the /boot partition get’s 100% full and then things like yum updates stop working.

Instead of attempting a dangerous and complicated manoeuvre to resize the (boot!) partition we can just take the following steps to stop the /boot partition from filling up in the first place:

Delete all old kernel versions

# dnf remove --oldinstallonly

Then edit the yum conf:

# vi /etc/yum.conf

Update the install limit to 2:

[main]
gpgcheck=1
installonly_limit=2
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False

Locked out of Webmin after IP address changed

Sometimes your provider changes your IP address and if you have IP Access Control turned on, you will not be able to access Webmin anymore. And of course you won’t be able to update your IP address in Webmin if you can’t access it anymore.

So in that case you need to use SSH and edit this config file:

# vi /etc/webmin/miniserv.conf

Look for the line “allow” and edit the IP address(es) as needed:

error_handler_404=404.cgi
error_handler_403=403.cgi
error_handler_401=401.cgi
allow=151.248.55.185 77.109.118.242 80.211.197.221
alwaysresolve=0
libwrap=
trust_real_ip=0

CentOS 8 yum breaks

Doing a yum update, I received this error and the update quit:

Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

Because CentOS 8 reached end-of-life, the yum repositories at “mirrorlist.centos.org” stopped working and need to be updated to new CentOS 8 Stream repos.

You can batch edit all the files in /etc/yum.repos.d/ with these commands:

sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

The content of the repo files will change like this:

[baseos]
name=CentOS Stream $releasever - BaseOS
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=http://vault.centos.org/$contentdir/$stream/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

Missing primary keys in MySQL

Some hosting providers (like DigitalOcean’s DBaaS) are very strict about importing a database which contains missing primary keys.
So to locate where those tables are, we can run the following query:

SELECT
t.TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES AS t
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS k
ON (
t.TABLE_NAME = k.TABLE_NAME
AND k.CONSTRAINT_SCHEMA = t.TABLE_SCHEMA
AND k.constraint_name = 'PRIMARY'
)
WHERE
t.TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys')
AND k.constraint_name IS NULL;

From here:
https://moiseevigor.github.io/programming/2015/02/17/find-all-tables-without-primary-key-in-mysql/

Gandi servers stuck on reboot (GRUB)

The Gandi servers suck so bad that when you reboot them, sometimes they don’t come back online. If this happens, you need to do this:

  1. Launch the emergency SSH console.
  2. At the GRUB > prompt, enter:
    configfile (xen/xvda1)/boot/grub2/grub.conf
  3. Select the newest kernel version (at the top) and click “e” to continue with editing.
  4. Scroll to the bottom of the config info and delete the 16 from linux16 and initrd16
    linux16  /boot/................
    initrd16 /boot/................
  5. Next type Ctrl+X to boot the machine up.
  6. Say a prayer and cross your fingers.