-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change system time feature #1730
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
#change time using hwclock and date -s | ||
|
||
clear | ||
|
||
echo -e -n "Please enter the date and time you wish to set\n" | ||
|
||
get_date () { | ||
echo -e -n "enter the $1 please ($2-$3) (enter for $2)\n" | ||
read -n $4 value | ||
echo -e "\n" | ||
#if enter | ||
if [[ $value = "" ]]; then | ||
value=$2 | ||
fi | ||
|
||
#must be a $4 digits number between $2 and $3 | ||
while [[ ! $value =~ ^[0-9]{$4} ]] || [[ ${value#0} -lt $2 ]] || [[ ${value#0} -gt $3 ]]; | ||
do | ||
echo -e -n "wrong $1, you enter "$value" please enter it again, must be a $4 digits number between $2 and $3 (press enter for $2) \n" | ||
read -n $4 value | ||
echo -e "\n" | ||
if [[ $value = "" ]]; then | ||
value=$2 | ||
fi | ||
done | ||
} | ||
|
||
get_date "year" "2024" "2200" "4" | ||
year=$value | ||
get_date "month" "01" "12" "2" | ||
month=$value | ||
get_date "day" "01" "31" "2" | ||
day=$value | ||
get_date "hour" "00" "23" "2" | ||
hour=$value | ||
get_date "min" "00" "59" "2" | ||
min=$value | ||
get_date "sec" "00" "59" "2" | ||
sec=$value | ||
|
||
##getting the output of date -s | ||
OUTPUT=$(date -s "$year-$month-$day $hour:$min:$sec" 2>&1) | ||
|
||
##if output is starting with the letter d which is the beginning of the error message then we do the script again | ||
if [[ ${OUTPUT} == d* ]]; then | ||
echo "The date is not correct, press any key to set it again" | ||
echo -e "\n" | ||
read -n 1 noting | ||
clear | ||
change-time | ||
else | ||
hwclock -w | ||
echo -e "the date has been sucessfully set to $year-$month-$day $hour:$min:$sec" | ||
echo -e "\n" | ||
|
||
echo -e "press any key to return to the menu" | ||
echo -e "\n" | ||
read -n 1 nothing | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,6 +438,7 @@ show_options_menu() | |
'C' ' Reencrypt LUKS container -->' \ | ||
'P' ' Change LUKS Disk Recovery Key passphrase ->' \ | ||
'R' ' Check/Update file hashes on root disk -->' \ | ||
'h' ' Change system time' \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
'x' ' Exit to recovery shell' \ | ||
'r' ' <-- Return to main menu' \ | ||
2>/tmp/whiptail || recovery "GUI menu failed" | ||
|
@@ -476,6 +477,9 @@ show_options_menu() | |
R ) | ||
root-hashes-gui.sh | ||
;; | ||
h ) | ||
change-time | ||
;; | ||
x ) | ||
recovery "User requested recovery shell" | ||
;; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GMT/UTC and reference to pure HTML5 url for user to look for GMT timezone clock with seconds like https://time.is/GMT or better