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

Backup all mysql databases

Backup all mysql databases

I created an easy way to backup all mysql databases
/mnt/srv-ttp-nas/ is a location on a local NAS

#!/bin/sh
sleep 10

DB_USER="username"
DB_PASS="password"
BACKUP_DIR = "/mnt/srv-ttp-nas/bu/databases"

#find all databasses and backup them
databases=`mysql --user=$DB_USER --password=$DB_PASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`

for db in $databases; do
        echo "Dumping database: $db"
        mysqldump $db -u $DB_USER -p --password=$DB_PASS | gzip > "/mnt/srv-ttp-nas/databases/"`date +%Y-%m-%d_%H-%M-%S`-$db.sql.gz
done

#remove files older than one month
find /mnt/srv-ttp-nas/databases/* -mtime +31 -exec rm {} \;

The power of this script is that if you add a new database this will automaticly be added.

Add to crontab to backup every 6 hours.

sudo crontab -e
0 0,6,12,18 * * * /home/tom/backup.sh

Preview of data on share

Update Unifi AP using SSH

Update Unifi AP using SSH

Download the correct software from Ubiquiti.

Change the name from the downloaded file to fwupdate.bin

Open WinSCP and connect to the AP using SCP protocol.

Copy the fwupdate.bin file to /tmp folder.

Close WinSCP and open Putty. Connect to the AP using ssh.

Issue the command syswrapper.sh upgrade2 & after this your session will close automatic and the AP will start the upgrade.

MDT Cheat sheet

The unattend files you will need to capture an MDT image file.

HideShell=True –> Important if computer skips last steps

Rules

[Settings]
Priority=Default
Properties=MyCustomProperty

[Default]
OSInstall=Y
SkipBDDWelcome=YES
SkipCapture=YES
SkipAdminPassword=YES
SkipProductKey=YES
SkipComputerBackup=YES
SkipBitLocker=YES
_SMSTSOrgName=SNOR ICT Bezig met installeren Windows 10
SkipDomainMembership=YES
SkipFinalSummary=YES
SkipLocaleSelection=YES
SkipPackageDisplay=YES
SkipProductKey=YES
SkipSummary=YES
SkipTimeZone=YES
SkipUserData=YES
SkipComputerName=NO
TimeZoneName=Romance Standard Time

UILanguage=nl-NL
UserLocale=nl-BE
Systemlocale=nl-NL
KeyboardLocal=0813:00000813

SkipAppsOnUpgrade=YES
SkipFinalSummary=YES
FinishAction=REBOOT

WindowsUpgradeAdditionalOptions=/compat IgnoreWarning

JoinDomain=sint-norbertus.be
DomainAdmin=####
DomainAdminDomain=###
DomainAdminPassword=####

TaskSequenceID=INSTALL
SkipTaskSequence=YES

EventService=http://####:9800

HideShell=YES 

Bootstrap

[Settings]
Priority=Default

[Default]
UserID=####
UserDomain=#####.##
UserPassword=####

KeyboardLocalPE=0813:00000813

DeployRoot=\#####\#####$

SkipBDDWelcome=YES
SkipTimezone=YES

Task sequense
You can skip capture user / group state in every step, this way the install takes less long. Restore from domain in last step of postinstall is issued for problems when computer won’t end the installation.

Change MDT language to nl_BE

This has to be done between updating deployment img and after creating task sequence.

Open file
#deployment share#\Control\INSTALL\Unattend.xml

Change

<InputLocale>0409:00000409</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>

To

<InputLocale>0813:00000813</InputLocale>
<SystemLocale>nl-NL</SystemLocale>
<UILanguage>nl-NL</UILanguage>
<UserLocale>nl-BE</UserLocale>