wait for NTP time sync before starting install

old-commit-hash: 0fa10e4dd7d6f28229612e026cbcff689ae95d32
This commit is contained in:
Comma Device
2020-01-19 05:25:15 +00:00
parent 4a6c5c1507
commit 345fc452f1
3 changed files with 17 additions and 2 deletions

View File

@@ -37,6 +37,14 @@
extern const uint8_t str_continue[] asm("_binary_continue_" BRAND_S "_sh_start");
extern const uint8_t str_continue_end[] asm("_binary_continue_" BRAND_S "_sh_end");
static bool time_valid() {
time_t rawtime;
time(&rawtime);
struct tm * sys_time = gmtime(&rawtime);
return (1900 + sys_time->tm_year) >= 2019;
}
static int use_pre_checkout() {
int err;
@@ -94,6 +102,13 @@ static int fresh_clone() {
static int do_install() {
int err;
// Wait for valid time
while (!time_valid()){
usleep(500 * 1000);
printf("Waiting for valid time\n");
}
struct stat sb;
if (stat(PRE_CHECKOUT_FOLDER, &sb) == 0 && S_ISDIR(sb.st_mode)) {
printf("Pre-checkout found\n");

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5345da01b3fc29935587d279916435e7c057e75277eece582234655ef2ae9237
oid sha256:bb1c814cc3273badbb59c768c58219d78b1df65c11bd7d5828dc9940d0e6d788
size 538912

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a5cb802fe9e53dcba02d46b42db87bee43d5fee19a03006051fb44dff30dd24f
oid sha256:129f7dbb9afe7f9187f6ebd8cafc25efe3782b60460f98ac11235778b85bb57d
size 538912