Friday, 6 November 2020

How to update ntp server in CENTOS 7-8?

Managing System Time and NTP in Linux

Keeping your server’s time accurate is crucial — whether it’s for logging, cron jobs, or secure connections. Here’s a quick guide to checking and setting time on a Linux system, along with enabling NTP for automatic synchronization.


🔍 Check the Current Time

Check the hardware clock (BIOS/RTC):

hwclock

Check the system clock (software):

timedatectl

⏱ Enable NTP (Network Time Protocol)

To let your system automatically sync with time servers, enable NTP:

timedatectl set-ntp yes

🕒 Manually Set the Time

If you need to set the time manually (e.g., no NTP available):

timedatectl set-time HH:MM:SS

(Replace HH:MM:SS with your desired time.)


⚙️ Start and Enable NTP Daemon

For continuous synchronization with NTP servers, start and enable the ntpd service:

sudo systemctl start ntpd
sudo systemctl enable ntpd

🌍 Sync with a Specific NTP Server

You can manually sync your system clock to a specific NTP server and then update the hardware clock:

ntpdate -u clock.ncbs.res.in && hwclock -w

✅ That’s it! Now your Linux system should stay in sync with accurate time.


Tuesday, 30 June 2020

Update Drupal 8 using composer

How to Update Drupal 8 Using Composer

Keeping Drupal up to date is essential for security, performance, and compatibility. If you’re using Composer to manage your project (which is the recommended way), here’s a step-by-step guide to safely update Drupal 8.


📝 Step 1: Check Your Current Version

Before updating, it’s a good idea to see which version of Drupal core you’re running and if updates are available.

composer show drupal/core-recommended --check
composer outdated "drupal/*"

💾 Step 2: Take Backups

Always back up your site and database before making updates. You can use Drush for this:

drush sql:dump > /root/drush-backups/site-$(date +%F).sql
drush archive-dump > /root/drush-backups/site-archive-$(date +%F).tar.gz

🛠 Step 3: Enable Maintenance Mode

Put the site into maintenance mode so users don’t run into issues while the update is in progress.

drush state:set system.maintenance_mode 1
drush cache:rebuild

🔄 Step 4: Update Drupal Core

Run the Composer update command for core-recommended (which ensures the correct set of dependencies).

composer update drupal/core-recommended --with-dependencies

Then rebuild the cache:

drush cache:rebuild

✅ Step 5: Disable Maintenance Mode

Once the update is complete, bring your site back online:

drush state:set system.maintenance_mode 0
drush cache:rebuild

🔧 Optional Commands

Depending on your setup, you might also find these useful:

  • Update drupal/core directly (not always recommended):

    composer update drupal/core --with-dependencies
    
  • Update to a specific version:

    composer require 'drupal/core-recommended:^8.9' --update-with-all-dependencies
    
  • Use the development branch (not recommended for production):

    composer require drupal/core-recommended:8.9.x-dev --update-with-all-dependencies
    

That’s it! Your Drupal 8 site should now be running the latest version.


Monday, 15 June 2020

How to build an Android app for production using Native-script?

How to Build an Android App Using NativeScript

If you’re building Android apps with NativeScript, one of the important steps is preparing your app for production. This includes signing the app, generating a release build, and choosing the right file type for distribution.

Here’s a complete guide to help you through the process.


🔑 Step 1: Create a .jks Keystore File

Before you can publish your app, you’ll need a Java Keystore (.jks) file. This file is used to sign your app and is required every time you release an update.

👉 Important:

  • Store your .jks file in a safe location.

  • You must use the same .jks file for every update.

  • If you lose it, you’ll be forced to create a new .jks file and publish your app under a new package name.

📖 Official guide: Android App Signing


📦 Step 2: Build the Release Version

NativeScript gives you three options for building a production-ready Android app.


1) Generate an APK file

This is the traditional Android app package format.

tns build android --release \
--key-store-path [path-to-your.jks] \
--key-store-password [your-key-password] \
--key-store-alias [your-alias] \
--key-store-alias-password [your-alias-password]

The .apk file can then be uploaded directly to the Play Store or shared with users.


2) Generate an AAB file (Recommended)

Google now recommends the Android App Bundle (AAB) format because it reduces app size by delivering only the required resources for each device.

tns run android --release \
--key-store-path [path-to-your.jks] \
--key-store-password [your-key-password] \
--key-store-alias [your-alias] \
--key-store-alias-password [your-alias-password] \
--aab

3) Generate a Customized AAB file

You can optimize your app further with flags like --bundle, --env.uglify, --env.aot, and --env.snapshot. These options reduce size and improve performance.

tns run android --bundle --env.uglify --env.aot --env.snapshot \
--release \
--key-store-path [path-to-your.jks] \
--key-store-password [your-key-password] \
--key-store-alias [your-alias] \
--key-store-alias-password [your-alias-password] \
--aab --copy-to app1.aab

This will create an optimized .aab file named app1.aab.


⚠️ Note on App Size

A blank NativeScript project for Android is typically around 12MB. This is because it includes three versions of the NativeScript runtime to support different Android CPU architectures.

 Final Thoughts 

Always use the same .jks file for updates.

  • Prefer AAB over APK for smaller, more efficient app delivery.

  • Use build optimization flags for production-ready performance.

With these steps, you’re ready to publish your NativeScript Android app to the Play Store! 🎉


Tuesday, 5 May 2020

How to install Drush using CGR and Composer.

How to install Drush using CGR and Composer 

 

* Tested on Ubuntu 18.04


1. Install the composer Globally using the below commands 


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 
'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24
ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } 
else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
 

2. Move the downloaded 


mv composer.phar /usr/local/bin/composer 
 
* If you like to install it only for your user and avoid requiring root permissions,
you can use ~/.local/bin instead which is available by default on some
Linux distributions.
 

3. Install CGR


Add the path in /etc/environment like 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$HOME/.config/composer:$HOME/.config/composer/vendor/bin"

Export the path in ~/.bashrc like 
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
export PATH="$(composer config -g home)/vendor/bin:$PATH"

cd ~
composer global require consolidation/cgr


4. Install Drush using CGR


cgr drush/drush [For the latest version]

cgr drush/drush:7.* [For drush 7]


5. Create symbolic link inside the /usr/bin to work on drush Globally