wiki.getshifting.com

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


start

SHIFT-WIKI - Sjoerd Hooft's InFormation Technology

This WIKI is my personal documentation blog. Please enjoy it and feel free to reach out through blue sky if you have a question, remark, improvement or observation. See below for the latest additions, or use the search or tags to browse for content.


Windows Firewall GPO

Summary: How to configure a firewall GPO for Windows.
Date: Around 2014
Refactor: 1 March 2025: Checked links and formatting.

This is how to configure the firewall of your workstations in a domain. There are two configs, one for computers connected to the domain and one for computers who are not connected to the domain, for example, a laptop user working at home.

→ Read more...

2025/06/01 11:59

Bash: a script to check if all files are present

Summary: Bash: a script to check if all files are present
Date: 6 June 2011
Refactor: 1 March 2025: Checked links and formatting.

This is a remake of a script that is designed to check consistency in file order. The second line inside the file holds a unique number that is always 1 higher than the previous one. They also need to be on time, but only between 8 and 17 during workdays. As since, this script is scheduled according so through cron.

#!/bin/bash
########################################################################################################################
# Author : Sjoerd Hooft
# Date Initial Version: 6 June 2011
# Comments: sjoerd_ @ _getshifting.com
#
# Description:
# This is the script to check consistency in files.
#
# Recommendations:
# The script is designed for a 120 column terminal.
# The running user must be the root user
#
# Changes:
# Please comment on your changes to the script (your name and email address, line number, description):
########################################################################################################################
 
# Script Variables
HOSTNAME_SHORT=`hostname -s`
BASEDIR=`dirname $0`
LOGFILE="$BASEDIR/file.log"
WHATAMI=`basename $0`
DATE=`date +%d%m%y`
# Send all output to logfile
exec > $LOGFILE 2>&1
 
# Mail Variables
. "$BASEDIR/mail.txt"
MAILTOALARM="alarm_@_getshifting.com sjoerd_getshifting.com"
MAILTOALARMCC="ccmail1_getshifting.com ccmail2_getshifting.com"
 
# File Variables
FILEDIR="/DIR/files"
TEMPSEQFILE="./seqnr.tmp"
 
mailFunction() {
   if [[ "$failstatus" -eq "1" ]]; then
      cat $LOGFILE | mail -s "Possible failure files" -c $MAILTOALARMCC $MAILTOALARM
   else
      cat $LOGFILE | mail -s "File report" $MAILTOSUCCESS
   fi
}
 
# Determine file sequence number
# Needs input of file to check
fileseqnrFunction() {
   LINE_COUNT=0
   while read LINE
      do
      # Need to skip first line, as sequence number is on second line
      if [[ $LINE_COUNT -eq 1 ]] ; then
         # Set variable and cut the ^m (new line) from the line
         FILESEQNR=`echo $LINE | cut -f1 -d" "`
         echo "The sequence number of $(echo $1 | cut -f5 -d"/") = $FILESEQNR"
         echo
         echo $FILESEQNR >> $TEMPSEQFILE
         break
      fi
      LINE_COUNT=$(($LINE_COUNT+1))
   done < $1
}
 
# Determine all file today and set them into an array
todaysfilesFunction() {
   declare -a FILEARRAY
   FILEARRAY=($(find $FILEDIR/. -name "${DATE}*" -print))
   for file in "${FILEARRAY[@]}"
      do
      echo "Checking this todays file: $file"
      fileseqnrFunction $file
   done
}
 
# Checking for missing sequence numbers
sequenceFunction() {
   declare -a SEQNRARRAY
   SEQNRARRAY=($(cat $TEMPSEQFILE | sort))
   echo "There are ${#SEQNRARRAY[@]} files so far today that need to be checked."
   echo
   lastelement=${#SEQNRARRAY[@]}
   #uncomment for troubleshooting echo "So the array exists from elements ${SEQNRARRAY[0]} to ${SEQNRARRAY[@]: -1} "
   while [ "$lastelement" != "1" ]
   do
      # Array is zero indexed, so start with retracting 1
      secondtolastelement=$(($lastelement - 2))
      lastelement=$(($lastelement - 1))
      check=$((${SEQNRARRAY[$lastelement]}-${SEQNRARRAY[$secondtolastelement]}))
      if [ "$check" != "1" ]; then
         echo "The difference between ${SEQNRARRAY[$lastelement]} and ${SEQNRARRAY[$secondtolastelement]} is $check. There is a file missing. Oh oh... "
         failstatus=1
      else
         echo "The difference between ${SEQNRARRAY[$lastelement]} and ${SEQNRARRAY[$secondtolastelement]} is $check. Nice. There are no files missing."
      fi
   done
}
 
timeFunction() {
   hour="10#`date +%H`"
   # find must be non recursive on AIX, use prune and * see [[scriptbashfind#using_prune]]
   find=`find $FILEDIR/* -prune -type f -mmin -120 -print | wc -l`
   echo "This is the report from `date +%H` hour and there are $find files in the last two hours. "
   # if time before 10 AM and there are no files
   if [[ "$hour" -lt "10" ]] && [[ "$find" -le "1" ]]; then
      echo "There are not enough files yet to check for sequence numbers but it's still early. We'll check again next hour."
      mailFunction
      exit
   fi
   if [[ "$hour" -ge "10" ]] && [[ "$find" -eq "0" ]]; then
      echo
      ls -lrt $FILEDIR | tail
      echo "Oh oh, the latest file is already more than two hours old. Is there something wrong? "
      failstatus=1
   else
      echo "Latest file is recent enough. Very well."
      echo
   fi
}
 
timeFunction
todaysfilesFunction
sequenceFunction
rm $TEMPSEQFILE
mailFunction
 
exit
2025/06/01 11:59

Creating a Password Policy with a GPO

Summary: How to set a password policy using a gpo.
Date: Around 2008
Refactor: 31 December 2024: Checked links and formatting.

→ Read more...

2025/06/01 11:59

Federated Login for AWS with Azure AD

Summary: How to log in to the AWS console using your Entra ID credentials.
Date: Around 2018
Refactor: 1 March 2025: Checked links and formatting.

After Getting Started With AWS and Getting Started With Office 365 I now also want to login to the AWS console using Azure Active Directory. This article describes the steps to do so. Used technologies:

  • AWS IAM
  • Azure AD
  • Azure AD Enterprise App

Note that the goal here is to keep user provisioning in Azure Active Directory, something that is already common for many organizations and that I don't want to create users in AWS IAM. I just want to login to AWS using the original account.

→ Read more...

2025/06/01 11:59

<< Newer entries | Older entries >>

This wiki has been made possible by:

start.txt · Last modified: by sjoerd