February 17 2023

Nextcloud auto update script (sample)

release=latest-24
date=$( date ‘+%m%d%Y_%I%M%p’ )
systemctl stop apache2
cd /var/www
wget https://download.nextcloud.com/server/releases/$release.zip
#wget https://download.nextcloud.com/server/releases/latest.zip
#wget https://download.nextcloud.com/server/releases/nextcloud-23.0.12.zip
cp /var/www/html/config/config.php /var/www/config.php
mv /var/www/html “/var/www/nextcloud-old-$date”
unzip -q $release.zip;
mv /var/www/nextcloud /var/www/html;
mv $release.zip $release-$date.zip;
mv /var/www/config.php /var/www/html/config/config.php
chown -R www-data:www-data /var/www/html
find /var/www/html/ -type d -exec chmod 750 {} \;
find /var/www/html/ -type f -exec chmod 640 {} \;
systemctl restart apache2
cd /var/www/html;
usermod -s /bin/bash www-data
su www-data -c “php occ upgrade”
usermod -s /sbin/nologin www-data
systemctl restart apache2

nextcloud-auto

November 11 2022

Change last logged on user on Windows 10

In Windows 10 you can no longer change the last logged on user in the registry like you could in Windows 7. Windows 10 requires the user’s SID to be entered as well. Here’s an updated guide.

In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI, you’ll want to change 4 entries:

LastLoggedOnDisplayName
Enter the user’s full name, like Allan Jude
LastLoggedOnSAMUser
Enter the username, like SHORTDOMAIN\allan.jude
LastLoggedOnUser
Enter the username again, like SHORTDOMAIN\allan.jude
LastLoggedOnUserSID
Enter the user’s SID, like S-1-5-21-112783954-3472839473-6329827380-1437

You can find the exact SID with wmic useraccount where name=’allan.jude’ get sid
Or you can search through the list of all users with wmic useraccount, and pipe it into Windows’s version of grep, which I find easier to remember: wmic useraccount | findstr allan
Now you can log out, and you should be good to leave the workstation for the user.

https://gist.github.com/dbirks/ec4416c9064a323b14f435ee934efd71

October 7 2022

Windows built in VPN, dont use as network credentials

I know this is an old question, but I believe there is a better answer in that it doesn’t require any server-side changes: edit the VPN settings to not use the VPN credentials when authenticating to network servers. This setting is not exposed through Windows’ UI, so you need to locate the .pbk file associated with your VPN connection (%AppData%\Roaming\Microsoft\Network\Connections\PBK\rasphone.pbk for user VPNs) or (%ProgramData%\Microsoft\Network\Connections\Pbk\rasphone.pbk for system VPNs).

Right click on the VPN’s .pbk file and open it with Notepad. (Remember to untick ‘Always use this program for this file type’)
Roughly 5 lines down will be an entry ‘UseRasCredentials=1’
Change this to ‘UseRasCredentials=0’
Save the file.
I sourced these instructions are from: https://social.technet.microsoft.com/Forums/windows/en-US/0204464d-e32d-4584-966b-60788cce0d6f/disable-creation-of-vpn-session-credential-in-credential-manager-without-disabling-all-of

https://serverfault.com/questions/322235/do-not-use-vpn-credentials-to-connect-to-network-resources

September 10 2022

EdgeRouter install/update nano

set system package repository stretch components 'main contrib non-free'
set system package repository stretch distribution stretch
set system package repository stretch url http://http.us.debian.org/debian

Fix URL:
set system package repository stretch url http://archive.debian.org/debian

Do apt-get update, but don’t do apt-get upgrade, as it will break some of the packages the ER depends on.

https://help.ui.com/hc/en-us/articles/205202560-EdgeRouter-Add-Debian-Packages-to-EdgeOS
https://community.ui.com/questions/Install-Nano/40e7697a-404b-4083-b901-dbedbfdc8a8c

September 9 2022

fetchmail ssl error

Get the combined ssl fingerprint:

openssl s_client -connect email.server.wan:993 -showcerts | openssl x509 -fingerprint -noout -md5

Example fetchmailrc:

set logfile /home/user/fetchmail.log
poll email.server.wan proto pop3
user "loginnamehere" password "passwordhere"
ssl
sslcertpath "/home/user/.fetchmail/ssl"
#sslcertck
nokeep
mda "/usr/bin/procmail -f %F -d %T";
sslfingerprint 'md5 thumbprint separated by :'s from first step'

The running script, print attachments with cups

#!/bin/bash
echo -n $(date +%m-%d-%Y_%H:%M:%S) ":>> " >> fetchmail.log
SUPPORTED_FILETYPES=.pdf.jpg
LP_OPTIONS="-d MFCL2710DN -o media=A4,tray1 -o fit-to-page -o position=top -o scaling=100"
FILENAME=$(date +%H%M%S).txt
/usr/bin/fetchmail --bsmtp ~/mailtemp/$FILENAME
if [ "$?" = "0" ]; then
/usr/bin/uudeview +e $SUPPORTED_FILETYPES -p ~/printable -i ~/mailtemp/$FILENAME
# rm ~/mailtemp/$FILENAME

for f in ~/printable/*
do
lp $LP_OPTIONS $f
rm $f
done
fi

https://www.linuxquestions.org/questions/linux-server-73/fetchmail-809435/

How to fix ssl certificate issue on fetchmail

March 9 2022

UniFi Site Controller custom SSL

Download the script:

sudo wget https://raw.githubusercontent.com/stevejenkins/unifi-linux-utils/master/unifi_ssl_import.sh -O /usr/local/bin/unifi_ssl_import.sh

Edit the variables in the script

Add your domain
UNIFI_HOSTNAME=unifi.yourdomain.com

Comment the three lines for Fedora/RedHat/Centos by placing a # for it:
# Uncomment following three lines for Fedora/RedHat/CentOS
#UNIFI_DIR=/opt/UniFi
#JAVA_DIR=${UNIFI_DIR}
#KEYSTORE=${UNIFI_DIR}/data/keystore

Uncomment the three lines for Debian/Ubuntu
# Uncomment following three lines for Debian/Ubuntu
UNIFI_DIR=/var/lib/unifi
JAVA_DIR=/usr/lib/unifi
KEYSTORE=${UNIFI_DIR}/keystore

Set the Let’s Encrypt mode to true:
If you only enable the line, by removing the #, you will get a loop ==Yes when running the script. So set it to true. Will still get some warning about missing [[:, but the doesn’t matter.
LE_MODE=true

https://lazyadmin.nl/home-network/unifi-controller-ssl-certificate/
February 28 2022

Two Default Gateways on One System

You have built two or more network cards into one Linux system and each of these cards has its own default gateway. By default, you can only have one default gateway on a system. The case described would lead to asynchronous routing, whereby the router would reject the packets as appropriate.

The iproute2 program, which is included in all current Linux distributions and already installed even, as a rule, can be used for the solution of this problem. Normally, a Linux system only has one routing table, in which only one default gateway can make entries. With iproute2, you have the ability to setup an additional routing table, for one thing, and allow this table to be used by the system based on rules, for another.

https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System

September 30 2021

Bleachbit-Portable – Download and clean temp files


$datecurrent = get-date -Format MMddyyyyHmmss
$bleachbit_portable_url = “https://url/download/bleachbit-portable.zip”

$ourpath = “C:\absolute\” + $datecurrent + “\temp”
$zip = $ourpath + “\bleachbit-portable.zip”
$exe = Join-Path $ourpath “\bleachbit-portable\bleachbit_console.exe”

New-Item -ItemType Directory -Force -Path $ourpath
Invoke-WebRequest -Uri $bleachbit_portable_url -OutFile $zip
Expand-Archive -LiteralPath $zip -DestinationPath $ourpath

$Params = ” –clean microsoft_edge.cache chromium.cache firefox.cache google_chrome.cache internet_explorer.cache flash.cache java.cache system.tmp system.updates adobe_reader.cache”
$ParsedParams = $Params.Split(” “)

& $exe $ParsedParams