Skip to content

Author: xavier

How to shutdown a second or additional server from one Unraid machine

Found this interesting post that helped me set it up.

https://forums.unraid.net/topic/53944-how-to-shutdown-2-servers-on-1-ups

Yes, if you are using the unraid stock ups software (apcupsd). On the slave server set the cable type to Ether, the ups type to Net, and the device to <master_server_name_or_ip>:3551

Make SURE that the conditions to shutdown are set to keep the master on long enough to allow the slave server to shutdown first.

Personally, I have the master machine set to shut down after 300 seconds on battery, and the slave after 270 seconds. If the power around here is off more than a minute, it’s going to be out a while.

BTW, this also works for VM’s. I have apcupsd set up in all my VM’s to initiate shutdown after 60 seconds of no power, so they have plenty of time to finish up what they are doing and shutdown cleanly before unraid pulls the rug out from under them

Leave a Comment

bash script to clean up directories

#!/bin/bash
# Define the directory to search (you can change this to the desired directory)
DIR="/temp"

# Array of file extensions to delete
EXTENSIONS=("*.txt" "*.srt" "*.nzb" "*.sup" "*.ac3" "*.dts" "*.sample.*" "*.srr")

# Counters for deleted files and directories
deleted_files=0
deleted_directories=0

# Loop through the array and delete the files, counting each deletion
for EXT in "${EXTENSIONS[@]}"; do
    count=$(find "$DIR" -type f -name "$EXT" -print -delete | wc -l)
    deleted_files=$((deleted_files + count))
done

# Find and delete empty directories, counting each deletion
count=$(find "$DIR" -type d -empty -print -delete | wc -l)
deleted_directories=$((deleted_directories + count))

# Output the counts
echo "Deleted $deleted_files files with extensions ${EXTENSIONS[*]}."
echo "Deleted $deleted_directories empty directories."

For the most up-to-date version, follow the links below.

https://snippets.cacher.io/snippet/b554e570d8ffc0431ad9

https://gist.github.com/xavier-hernandez/f4979b4ce174068ce5428a26ae08be32

Leave a Comment

Unraid BTRFS Issues

One of my BTRFS pools, which was RAID 1 corrupted and wouldn’t mount.

I want to say docker updates overloaded the size of the docker file.

I probably did this all wrong, but I got a lot of the data from it, so I provided some commands that might help others in the future.

Make sure to put Unraid into maintenance mode.

Below are just examples since I didn’t record exactly what I did.

To mount the degraded RAID configuration. Choose the primary partition/drive to mount somewhere.

#mount degraded RAID
mount -o degraded /dev/mapper/[partition] /mnt

# to unmount
umount /mnt

To check the filesystem and hopefully fix the filesystem issue.

#shows you the filesystem
btrfs fi show /dev/sdd

#starts the scrub process
btrfs scrub start /mnt

#checks the scrub process status
btrfs scrub status /mnt

You can also use this to monitor the status instead of running the last line above over and over again.

#this will check the status of the scrub every second

watch -n 1 btrfs scrub status /mnt

I was told not to use this since it might screw up the filesystem, but my filesystem was already screwed up 🙂 This checks and tries to repair the filesystem.

btrfs check --repair /dev/sdd
Leave a Comment

“Lookalike” Warnings in Google Chrome

I recently started hosting a website and didn’t realize it was throwing the error below in Chrome.

The site you just tried to visit looks fake. Attackers sometimes mimic sites by making small, hard-to-see changes to the URL.

After a lot of googling, I finally found an answer on how to get rid of it. I just started the process and will update the post later to see if it worked.

https://chromium.googlesource.com/chromium/src/+/master/docs/security/lookalikes/lookalike-domains.md#automated-warning-removal

Leave a Comment

Unraid – Unmountable: Volume not encrypted

So I got this error on my Unraid server for a drive, “Unmountable: Volume not encrypted” for a drive I had used on another server. There was nothing on the drive I wanted so I just wanted to overwrite or format it.

Finally found a link to just overwrite the filesystem.

https://unix.stackexchange.com/questions/315063/mount-wrong-fs-type-bad-option-bad-superblock

mkfs.ext4 /dev/sXXX

Leave a Comment

Install MS Dynamics CRM Tools

Had to do this recently.

Got this code from https://crmtipsbyprm.wordpress.com/2018/06/22/download-dynamics-365-tools-from-nuget/

Works out of the box.

$sourceNugetExe = “https://dist.nuget.org/win-x86-commandline/latest/nuget.exe”
$targetNugetExe = “.\nuget.exe”
Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose

##
##Download Plugin Registration Tool
##
./nuget install Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -O .\Tools
md .\Tools\PluginRegistration
$prtFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match ‘Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.’}
move .\Tools$prtFolder\tools\*.* .\Tools\PluginRegistration
Remove-Item .\Tools$prtFolder -Force -Recurse

##
##Download CoreTools
##
./nuget install  Microsoft.CrmSdk.CoreTools -O .\Tools
md .\Tools\CoreTools
$coreToolsFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match ‘Microsoft.CrmSdk.CoreTools.’}
move .\Tools$coreToolsFolder\content\bin\coretools\*.* .\Tools\CoreTools
Remove-Item .\Tools$coreToolsFolder -Force -Recurse

##
##Download Configuration Migration
##
./nuget install  Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf -O .\Tools
md .\Tools\ConfigurationMigration
$configMigFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match ‘Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf.’}
move .\Tools$configMigFolder\tools\*.* .\Tools\ConfigurationMigration
Remove-Item .\Tools$configMigFolder -Force -Recurse

##
##Download Package Deployer
##
./nuget install  Microsoft.CrmSdk.XrmTooling.PackageDeployment.WPF -O .\Tools
md .\Tools\PackageDeployment
$pdFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match ‘Microsoft.CrmSdk.XrmTooling.PackageDeployment.Wpf.’}
move .\Tools$pdFolder\tools\*.* .\Tools\PackageDeployment
Remove-Item .\Tools$pdFolder -Force -Recurse

##
##Remove NuGet.exe
##
Remove-Item nuget.exe
Leave a Comment

All of my RAM is not showing up in Unraid

So I bought some RAM recently in one of those bins on clearance because it was opened, etc. I installed it with another two sticks I already had. All four sticks are DDR4, of course, but the old ones were 2x8GB 26666, and the new ones are 2×16 GB 3200. Unraid would only show 16GB usable rather than the 48GB. Unraid did notice them, but they were unable to be used.

After some googling which didn’t get me anywhere, I decided to remove all the sticks and just use the new ones in A2 and B2. Well, now Unraid shows 32GB of RAM usable. So next, I put in the other two sticks in A1 and B1. Boom!!! Now it can use all 48GB. I assume it has to do with a mismatch in either speed or capacity.

Motherboard: Asrock B450M Pro4

Leave a Comment

traefik v3 example with uptime-kuma

Here is an example of Traefik, using Uptime-Kuma as an example with a domain for it plus using letsencrypt to secure the domain. We also redirect HTTP to HTTPS.

The Traefik dashboard is not secure, so please implement security or a firewall.

This is just an example.

version: "3"

services:
 uk1:
    image: louislam/uptime-kuma:1
    container_name: uk1
    volumes:
      - ./uk1-data:/app/data
    ports:
      - 3001:3001  # <Host Port>:<Container Port>
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.uk1.tls.certresolver=myresolver"
      - "traefik.http.routers.uk1-http.entrypoints=web"
      - "traefik.http.routers.uk1-http.rule=Host(`your_domain_here`)"
      - "traefik.http.routers.uk1-http.middlewares=uk1-https"
      - "traefik.http.middlewares.uk1-https.redirectscheme.scheme=https"
      - "traefik.http.routers.uk1.entrypoints=websecure"
      - "traefik.http.routers.uk1.rule=Host(`your_domain_here`)"
      - "traefik.http.routers.uk1.tls=true"
    depends_on:
      - traefik
 traefik:
  image: traefik:v3.0
  command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.myresolver.acme.email=your_email_address_here"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
  ports:
    - 80:80
    - 443:443
    - 8080:8080
  volumes:
    - "./letsencrypt:/letsencrypt"
    - /var/run/docker.sock:/var/run/docker.sock

https://gist.github.com/xavier-hernandez/48042d5cdb66a89ac5e92a92ecfeb7b5

Leave a Comment

tls: failed to verify certificate: x509: certificate signed by unknown authority

In building a docker image for a Go application using the Apline image, I kept getting this error “tls: failed to verify certificate: x509: certificate signed by unknown authority”. I thought it was something with the code I was writing, but it had to do with the docker image.

Adding this to your Dockerfile should fix the problem. The problem is that the docker container doesn’t have the necessary certs to validate the connection. You might also get around this issue by adding the “ca-certificates” package to the image, but I didn’t try that.

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

or (depends on how your building your image)

COPY /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
Leave a Comment

Install dotnet core on Ubuntu 22.04

These are the steps I used to install dotnet core on Ubuntu 22.04, both the SDK and the runtime.

apt update
apt install -y apt-transport-https
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt update
apt install -y dotnet-sdk-7.0
apt update
apt install -y aspnetcore-runtime-7.0

To verify installation run the following commands. If the below doesn’t work try to open a new ssh session or terminal.

dotnet --list-runtimes

Microsoft.AspNetCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

dotnet --list-sdks

7.0.102 [/usr/share/dotnet/sdk]
root@srv4311:~# 

If you tried previously to install version 7.0 make sure you remove/purge the old version from the system. Something like below.

apt remove --purge dotnet-sdk-6.0 dotnet-runtime-6.0
apt auto-remove

Also maybe delete the .dotnet folder in your home directory.

Leave a Comment