Skip to content

Instantly share code, notes, and snippets.

@chkp-mkoldov
Created December 29, 2020 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chkp-mkoldov/1f2ea190c6888be3f46091f815813d73 to your computer and use it in GitHub Desktop.
Save chkp-mkoldov/1f2ea190c6888be3f46091f815813d73 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Created by tvobruba
# version 001
# script is checking and changing expiration date for internal specific users in CP MGMT database
# usage: chmod 700 && ./script.sh <username>
user=$1
date=1609459162000 #setup checked date in ms epoch time
new_date="2035-01-15" #setup new desired date in ISO format
echo "Checking date/time of expired users..."
echo -e "";
expiration=`mgmt_cli -r true show user name "$user" --format json |jq '."expiration-date".posix'`
echo User: $user, $expiration
echo ""
if [ $date \> $expiration ];
then
echo "$user will expire before 31.12.2020 23:55";
echo "Setting new expiration date..."
echo ""
mgmt_cli -r true set user name "$user" expiration-date "$new_date" --format json
else
echo "$user will expire not before: `date -d @$( echo "($expiration + 500) / 1000" | bc)`";
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment