Created
December 29, 2020 17:36
-
-
Save chkp-mkoldov/1f2ea190c6888be3f46091f815813d73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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