Skip to content

Commit

Permalink
utils: remove rand tz in package.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed Feb 1, 2024
1 parent 13089db commit 56cee0d
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions utils/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,23 @@

START_TIME=$EPOCHSECONDS

# Get original timezone
OG_TIMEZONE=$(timedatectl show | grep Timezone)
OG_TIMEZONE=${OG_TIMEZONE/Timezone=/}
set_og_timezone() { sudo timedatectl set-timezone "$OG_TIMEZONE"; }

title() { printf "\n\e[1;93m%s\e[0m\n" "============================ $1 ============================"; }
check() {
local CODE=$?
if [[ $CODE = 0 ]]; then
printf "${BASH_LINENO} | %s ... \e[1;92mOK\e[0m\n" "$1"
else
printf "${BASH_LINENO} | %s ... \e[1;91mFAIL\e[0m\n" "$1"
set_og_timezone
exit $CODE
fi
}
int() {
printf "\n\n%s\n" "Exit detected, resetting timezone to [${OG_TIMEZONE}]"
set_og_timezone
exit 1
}

trap 'int' INT

# Check sudo (for changing timezone)
title "Basic checks"
sudo -v; check "sudo"
# Check for needed files
[[ -d skel ]]; check "skel"
[[ -f skel/CHANGELOG.md ]]; check "skel/CHANGELOG.md"
Expand Down Expand Up @@ -60,11 +50,7 @@ title "Windows folder check"

# Get random date for tar/zip
title "RNG Date"
RNG=$((EPOCHSECONDS-RANDOM*4)); check "RNG ... $RNG"
DATE=$(date -d @${RNG}); check "DATE ... $DATE"
RNG_TIMEZONE=$(timedatectl list-timezones | sed -n "$((RANDOM%$(timedatectl list-timezones | wc -l)))p"); check "RNG_TIMEZONE ... $RNG_TIMEZONE"
# Set random timezone
sudo timedatectl set-timezone "$RNG_TIMEZONE"; check "set rng timezone"

# Tar Linux Bundle
title "Tar Linux"
Expand Down Expand Up @@ -138,5 +124,4 @@ check "Changelog into clipboard"

# Reset timezone
title "End"
set_og_timezone; check "Reset timezone"
printf "\n%s\n" "package.sh ... Took [$((EPOCHSECONDS-START_TIME))] seconds ... OK!"

0 comments on commit 56cee0d

Please sign in to comment.