Sync OpenWrt Date from Custom Domain



About

Tentang

How This Script Work

  1. When OpenWrt restarting, script will checking for network connection.
  2. If no network detected, script will re-checking connection until device reconnected.
  3. After device connected to internet, script will synchronize OpenWrt time.
  4. If device have running VPN/Tunneling, script will restarting VPN app before time sync.

Cara Kerja Script Ini

  1. Setelah OpenWrt restart, script akan memeriksa koneksi internet terlebih dahulu.
  2. Jika internet belum tersedia, script akan mengulangi pemeriksaan koneksi sampai koneksi terhubung.
  3. Ketika koneksi sudah terhubung, script akan melakukan sinkronisasi waktu.
  4. Jika ada aplikasi VPN/Tunneling yang berjalan, script akan merestart aplikasi VPN yang digunakan sebelum melakukan sinkronisasi waktu.

Installation

  1. Install needs dependencies first by opening Terminal/Putty/XTERM/etc:

     opkg update && opkg install curl wget
    
  2. Download jam.sh script by copy and paste command below to terminal (choose only one of below commands)

    wget installation:

     wget --no-check-certificate "https://raw.githubusercontent.com/vitoharhari/sync-date-openwrt-with-bug/main/jam.sh" -O /usr/bin/jam.sh && chmod +x /usr/bin/jam.sh
    

    curl installation:

     curl -sL raw.githubusercontent.com/vitoharhari/sync-date-openwrt-with-bug/main/jam.sh > /usr/bin/jam.sh && chmod +x /usr/bin/jam.sh
    
  3. Run command below to add jam.sh to LuCI -> System -> Startup -> Local Startup

     echo -e "#jam.sh autoboot\n/usr/bin/jam.sh time2.google.com" > /etc/rc.local
    
  4. If you desire to use LuCI -> System -> Schedule Tasks or crontab (check connection every hour, then restart vpn if no connection available), just run command below:

     echo -e "#jam.sh cron\n0 * * * * /usr/bin/jam.sh time2.google.com cron\n" > /etc/crontabs/root
    
    • For cron time customization, see crontab.guru to create your own cron time.

Pemasangan

  1. Install paket yang dibutuhkan terlebih dahulu dengan membuka terminal/putty/dsb:

     opkg update && opkg install curl wget
    
  2. Jalankan command dibawah untuk memasang script jam.sh (pilih salah satu saja)

    Pemasangan menggunakan wget

     wget --no-check-certificate "https://raw.githubusercontent.com/vitoharhari/sync-date-openwrt-with-bug/main/jam.sh" -O /usr/bin/jam.sh && chmod +x /usr/bin/jam.sh
    

    Pemasangan menggunakan curl

     curl -sL raw.githubusercontent.com/vitoharhari/sync-date-openwrt-with-bug/main/jam.sh > /usr/bin/jam.sh && chmod +x /usr/bin/jam.sh
    
  3. Jalankan command dibawah di terminal untuk menambahkan jam.sh ke LuCI -> System -> Startup -> Local Startup:

     echo -e "#jam.sh autoboot\n/usr/bin/jam.sh time2.google.com" > /etc/rc.local
    
  4. Jika menggunakan LuCI -> System -> Schedule Tasks atau disebut juga crontab (memeriksa koneksi setiap jam, lalu me-restart vpn jika koneksi tidak tersedia), jalankan perintah dibawah ini:

     echo -e "#jam.sh cron\n0 * * * * /usr/bin/jam.sh time2.google.com cron\n" > /etc/crontabs/root
    
    • Untuk kustomisasi waktu cron lainnya dapat dilihat di crontab.guru

Advanced Usage

Pemakaian Lanjutan

Developers