Install php8.1 ubuntu 20.04

Update system

sudo apt update
sudo apt upgrade

Add repository

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Install php8.1

sudo apt install php8.1

Install features

sudo apt install php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-redis php8.1-intl -y

Enable php8.1 disable php7.4

sudo a2enmod php8.1
sudo a2dismod php7.4

Restart apache

sudo service apache2 restart

running multiple versions: How To Install Multiple PHP Versions with Apache on Ubuntu 22.04/20.04/18.04 (tecadmin.net)

Export powershell scripts from intune

Source: Intune/Get-DeviceManagementScripts.ps1 at master · okieselbach/Intune · GitHub
Source: Get back your Intune PowerShell Scripts – Modern IT – Cloud – Workplace (oliverkieselbach.com)

Import-Module Microsoft.Graph.Intune
Connect-MSGraph

####################################################

#region Initialization code

$m = Get-Module -Name Microsoft.Graph.Intune -ListAvailable
if (-not $m)
{
    Install-Module NuGet -Force
    Install-Module Microsoft.Graph.Intune
}
Import-Module Microsoft.Graph.Intune -Global

#endregion

####################################################

Function Get-DeviceManagementScripts(){
<#
.SYNOPSIS
Get all or individual Intune PowerShell scripts and save them in specified folder.
 
.DESCRIPTION
The Get-DeviceManagementScripts cmdlet downloads all or individual PowerShell scripts from Intune to a specified folder.
Initial Author: Oliver Kieselbach (oliverkieselbach.com)
The script is provided "AS IS" with no warranties.
 
.PARAMETER FolderPath
The folder where the script(s) are saved.
.PARAMETER FileName
An optional parameter to specify an explicit PowerShell script to download.
.EXAMPLE
Download all Intune PowerShell scripts to the specified folder
Get-DeviceManagementScripts -FolderPath C:\temp 
.EXAMPLE
Download an individual PowerShell script to the specified folder
Get-DeviceManagementScripts -FolderPath C:\temp -FileName myScript.ps1
#>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true)][String] $FolderPath,
        [Parameter(Mandatory=$false)][String] $FileName
    )

    $graphApiVersion = "Beta"
    $graphUrl = "https://graph.microsoft.com/$graphApiVersion"

    $result = Invoke-MSGraphRequest -Url "$graphUrl/deviceManagement/deviceManagementScripts" -HttpMethod GET

    if ($FileName){
        $scriptIds = $result.value | Select-Object id,fileName | Where-Object -Property fileName -eq $FileName
        $script = Invoke-MSGraphRequest -Url "$graphUrl/deviceManagement/deviceManagementScripts/$($scriptId.id)" -HttpMethod GET
        [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($($script.scriptContent))) | Out-File -Encoding ASCII -FilePath $(Join-Path $FolderPath $($script.fileName))
    }
    else{
        $scriptIds = $result.value | Select-Object id,fileName
        foreach($scriptId in $scriptIds){
            $script = Invoke-MSGraphRequest -Url "$graphUrl/deviceManagement/deviceManagementScripts/$($scriptId.id)" -HttpMethod GET
            [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($($script.scriptContent))) | Out-File -Encoding ASCII -FilePath $(Join-Path $FolderPath $($script.fileName))
        }
    }
}

Connect-MSGraph | Out-Null

Get-DeviceManagementScripts -FolderPath C:\temp

Rotate screen raspberry pi

Source: https://howchoo.com/pi/raspberry-pi-display-rotation

Open file

sudo nano /boot/config.txt

Rotate the display

display_rotate=0 # Normal (landscape)
display_rotate=1 # 90 degrees (portrait, upside down)
display_rotate=2 # 180 degrees (landscape)
display_rotate=3 # 270 degrees (portrait, upside down)
display_rotate=0x10000 # horizontal flip
display_rotate=0x20000 # vertical flip

Rotate touch input

lcd_rotate=0 # default (normal landscape)
lcd_rotate=1 # 90 degrees (portrait, upside down)
lcd_rotate=2 # 180 degrees (landscape)
lcd_rotate=3 # 270 degrees (portrait, upside down)

Reboot the device

Autostart script linux

Maak een script aan sudo nano start.sh

#!/bin/sh
sleep 10
cd /
cd home/pi/
sudo python ip.py &
cd /

Wijzig de rechten sudo chmod 775 start.sh

sudo crontab -e
Voeg volgende lijn toe @reboot sudo sh /home/pi/start.sh >/home/pi/logs/cronlog 2>&1

Maak een log file
mkdir logs
chmod 775 logs

Ubuntu opstartscript

TTP IP

# TomTech Productions IP
import time, os
import requests, socket, uuid

## INSERT YOUR KEY AND MAIL HERE ##
domain = "" #company domain
mail = "tom.schelles@live.be" #your email
## INSERT YOUR KEY AND MAIL HERE ##

url = 'https://ttpm.be/data/online/post.php'
mac = uuid.getnode()

def get_lan_address():
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(("8.8.8.8", 80))
        return s.getsockname()[0]

while(1):
    lan = get_lan_address()
    name = socket.gethostname()

    myobj = {'lan' : lan, 'mac': mac, 'name': name, 'domain': domain, 'mail': mail }

    try:
        x = requests.post(url, data = myobj)

        if (x.text == "reboot"):
            os.system("shutdown -t 0 -r -f")

        if (x.text == "lock"):
            os.system("shutdown -l")

        if (x.text == "shutdown"):
            os.system("shutdown -t 0 -s -f")

    except:
        print('NO CONNECTION TO SERVICE')
    #update gegevens lokaal om de 10 seconden
    time.sleep(30)

Linux KIOKS mode Chrome

source: https://bloggerbrothers.com/2016/12/27/boot-your-pixel-based-pi-into-chromium-kiosk/

Install following software

sudo apt-get install -y x11-xserver-utils unclutter

Create a new file

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Copy this code into the file

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash
#@point-rpi
@xset s off
@xset -dpms
@xset s noblank
@sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium/Default/Preferences
@chromium-browser --incognito --noerrdialogs --kiosk tomtechproductions.be/example
@unclutter -idle 0.1 -root
Backup files linux

Backup files linux

An easy way to backup files to a local share

The example backup’s the files from the /var/www/html directory

#change to website folders
cd /var/www/html/

#find all subsites
for D in *; do
    if [ -d "${D}" ]; then
        echo "Generating backup for $D > " `date +%Y-%m-%d_%H-%M-%S`-${D}   # your processing here
        tar -zcvf "/mnt/srv-ttp-nas/server/"`date +%Y-%m-%d_%H-%M-%S`-${D}.tar.gz ${D}
    fi
done

#remove stale files
find /mnt/srv-ttp-nas/server/* -mtime +14 -exec rm {} \;

Add crontab to run backup every night at 3

sudo crontab -e
0 3 * * * /home/tom/backup_files.sh

Preview of data on share