Skip to content

Instantly share code, notes, and snippets.

View mrpeardotnet's full-sized avatar

Pavel Hruska mrpeardotnet

View GitHub Profile
@mrpeardotnet
mrpeardotnet / SplitOutsideQuotes.cs
Last active August 17, 2021 10:20
C# extension methods to split the string by a separator char (or char array), but only when a separator char is outside the quotes. Supports escaping the quotes (\"), so it is possible to use the quotes character itself inside the source string. This solution does not use regex. Includes some additional options to fine tune split results.
/// <summary>
/// Splits the string by specified separator, but only when the separator is outside the quotes.
/// </summary>
/// <param name="source">The source string to separate.</param>
/// <param name="splitChar">The character used to split strings.</param>
/// <param name="trimSplits">If set to <c>true</c>, split strings are trimmed (whitespaces are removed).</param>
/// <param name="ignoreEmptyResults">If set to <c>true</c>, empty split results are ignored (not included in the result).</param>
/// <param name="preserveEscapeCharInQuotes">If set to <c>true</c>, then the escape character (\) used to escape e.g. quotes is included in the results.</param>
public static string[] SplitOutsideQuotes(this string source, char separator, bool trimSplits = true, bool ignoreEmptyResults = true, bool preserveEscapeCharInQuotes = true)
{
@mrpeardotnet
mrpeardotnet / PMG-Enable Avast Antivirus.md
Created January 30, 2020 09:50
Enable Avast AV (Avast Business Antivirus) security in Proxmox Mail Gateway (PMG)

Enable Avast AV (Avast Business Antivirus) security in Proxmox Mail Gateway (PMG) 6.x

This cheatsheet shows how to install and enable Avast antivirus (Avast Business Antivirus for Linux) on your PMG server.

Please note that Avast Business Antivirus for Linux is not provided for free and you need to buy license. You can test it for free after requesting trial license.

Prepare the apt package manager

Download and install avast.gpg key:

wget -q -O - https://files.avast.com/files/resellers/linux/avast.gpg | apt-key add -
@mrpeardotnet
mrpeardotnet / PVE-host-backup.md
Created December 17, 2019 18:03
Proxmox PVE Host Config Backup Script

Proxmox PVE Host Config Backup Script

This script can be used to backup essential configuration files from the Proxmox Virtual Enivronment (PVE) host.

The script will create backups using tar with specified backup prefix and date and time stamp in the file name. Script will also delete backups that are older then number of days specified.

Create backup script file

To create backup script that will be executed every day we can create backup script in /etc/cron.daily/ folder. We need to make it writeable by root (creator) only, but readable and executable by everyone:

touch /etc/cron.daily/pvehost-backup
@mrpeardotnet
mrpeardotnet / PVE-HP-ssacli-smart-storage-admin.md
Created November 25, 2019 22:10
HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

Why use HP Smart Storage Admin CLI?

You can use ssacli (smart storage administrator command line interface) tool to manage any of supported HP Smart Array Controllers in your Proxmox host without need to reboot your server to access Smart Storage Administrator in BIOS. That means no host downtime when managing your storage.

CLI is not as convenient as GUI interface provided by BIOS or desktop utilities, but still allows you to fully manage your controller, physical disks and logical drives on the fly with no Proxmox host downtime.

ssacli replaces older hpssacli, but shares the same syntax and adds support for newer servers and controllers.

Installation

Installing multipath tools on PVE Cluster with shared storage

This cheatsheet shows how to install and configure multipath tools on Proxmox PVE Cluster where multiple nodes share single storage with multipath configuration, for example SAN storage connected to each of the nodes by two independent paths.

Proxmox PVE version

This cheatsheet has been tested on Proxmox 5.x.

Note about sudo

I do not prepend sudo command to any of commands listed here, but keep in mind that nearly all commands requires su privileges, so use sudo if your account happen to not have root access.

@mrpeardotnet
mrpeardotnet / PVE-postinstall-5x.md
Last active March 20, 2024 10:43
PVE-postinstall-6.x

Proxmox PVE 6.x Post Installation Steps

This cheatsheet helps to set up your Proxmox Virtual Environment (PVE) host after fresh installation. Designed and tested on PVE version 6.x.

Note about sudo

I do not prepend sudo command to any of commands listed here, but keep in mind that nearly all commands requires su privileges, so use sudo if your account happen to not have root access.

How to edit config files

The simplest way to edit config file is to use vim.tiny editor, for example to edit vzdump.conf file use this command:

@mrpeardotnet
mrpeardotnet / Bind9-caching.md
Last active November 17, 2022 12:36
Configure BIND9 as caching nameserver

Install and configure BIND9 as caching DNS nameserver [Debian/Ubuntu]

This tutorial shows how to set-up and configure BIND9 as domain name server (DNS) in caching mode on Debian/Ubuntu based Linux system.

Instalation

sudo apt-get install bind9

BIND configuration